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

starlark: add 'bytes' data type, for binary strings #330

Closed alandonovan closed 3 years ago

alandonovan commented 3 years ago

This change defines a 'bytes' data type, an immutable string of bytes. In this Go implementation of Starlark, ordinary strings are also strings of bytes, so the behavior of the two is very similar. However, that is not required by the spec. Other implementations of Starlark, notably in Java, may use strings of UTF-16 codes for the ordinary string type, and thus need a distinct type for byte strings.

alandonovan commented 3 years ago

Hi Jon, Jay,

I have updated this change to the Go impl, and the spec change in https://github.com/bazelbuild/starlark/pull/161 to clean up the following primary parts of the problem:

The remaining parts of the problem are:

To make this process more manageable and reduce the number of rounds of review on an increasingly large pair of PRs, I propose that we aim to commit the spec change and the Go implementation once we are happy with the "phase 1" features, and then make follow-up changes to address the "phase 2" items. Given that no-one is yet using bytes, I don't think this will be disruptive.

cheers alan

alandonovan commented 3 years ago

PTAL; thanks.