google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.3k stars 209 forks source link

Outdated documentation regarding nested functions #322

Closed bpastene closed 3 years ago

bpastene commented 3 years ago

According to https://docs.bazel.build/versions/master/skylark/language.html, nested functions are not a supported feature of python.

Yet, the documentation at https://github.com/google/starlark-go/blob/e55f603d8c797b182566012861c5784481d00df4/doc/spec.md indicates that nested functions are supported. It even has examples of it: https://chromium.googlesource.com/external/github.com/google/starlark-go/+show/e55f603d8c797b182566012861c5784481d00df4/doc/spec.md#1374

Does https://docs.bazel.build/versions/master/skylark/language.html need updating?

alandonovan commented 3 years ago

(I assume you mean "not a supported feature of Starlark".)

The Go implementation of Starlark permits def statements to be nested, as in Python; it also permits the use of lambda. Neither of these is defined by the spec, and thus both features are controlled by flags (-nesteddef, -lambda). That said, I think the spec should permit both, and I plan to add support for them to the Java implementation and to update the spec.

Does https://docs.bazel.build/versions/master/skylark/language.html need updating?

Yes, but not for this reason, at least not yet.