bazelbuild / starlark

Starlark Language
Apache License 2.0
2.5k stars 164 forks source link

spec: convergence with Go #20

Open alandonovan opened 5 years ago

alandonovan commented 5 years ago

The Go implementation has a list of remaining differences from the Java implementation: https://github.com/google/starlark-go/blob/master/doc/spec.md#dialect-differences I'd like us to finish the wording of a spec that we can all be happy with, even if that spec allows for some differences among implementations. I'll go through the list of differences point by point:

kastiglione commented 5 years ago

Given that using Python in this way is a hack

Is there more context on this? I've found it exceedingly convenient to use Python's ast module to query over and do transformations of Bazel files, for small development tasks.

alandonovan commented 5 years ago

Is there more context on this? I've found it exceedingly convenient to use Python's ast module to query over and do transformations of Bazel files, for small development tasks.

The key word in this sentence is "convenient". :)

If you want to transform a Starlark program from Python, the right thing to do is write a Starlark parser in Python. It should be easy because you can just fork the Python parser and delete the parts you don't need.

The syntax of Starlark is, for now, a subset of Python, but longer term it could be improved by breaking compatibility. The most glaring problem is the syntax for load, which must use strings where identifiers are wanted. Tools that assume a Python parser is sufficient are taking an expedient short-cut at the expense of long term maintainability, which is the definition of a hack. The Bazel test tools I was alluding to go one step further and actually execute the Skylark program in a Python interpreter, which is very fragile indeed.

adonovan commented 5 years ago

I met with Laurent and Damien today and we agreed on the following spec changes:

alandonovan commented 4 years ago

Update: These are all done, except: