-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify Sequence Type Relationships #206
Comments
I think these remarks are all very specific to the Java Starlark, and more than that, the internal implementation of Java Starlark., Whereas this repo is only about the things that can be observed by the source Starlark code. For example there isn't a Sequence interface in Starlark, it's just a bunch of types that can be iterated over. Are you saying that in Java Starlark |
Hi @ndmitchell thanks for the response.
That's a fair point, I'll clarify this further below.
While there isn't a In your example of
So this is where it is a bit ambiguous and I'm asking if there needs to be clarification. Take for example the semantics behind a Python's collections.abc has a nice table that helps highlight all the operations available to a particular contract. I'm trying to understand if it makes sense to propose (and that's really the purpose of this Github issue) that the Starlark spec follows similar naming conventions and map the appropriate operations to the corresponding Starlark types. So, something like:
Of course, I think I was just trying to start a conversation to centralize the discussion before suggesting anything on the bazel repo itself. If it still is too Java implementation specific, I'm happy to close this issue and move it to that repo instead. |
Starlark only has three compound types - lists, tuples and dictionaries, with strings being a kinda-compound type. I think it's probably easier to remove all ambiguity from the spec and just say "slices work for lists, tuples and strings", "indexing works for lists, tuples, strings and dictionaries", "iteration works for lists, tuples and dictionaries". Given there are only 4 types, it's not too much to type and is 100% explicit. |
In the spec, under
Sequence types
, it states:However, in the Java implementation,
Dict
does not implement theSequence
interface. I think this is a mistake in the spec and should be removed:This exposes a few other questions that the spec mentions:
SetIndexable
currently does not exist. The Java implementation relies onEvalUtils#setIndex
but is hardcoded to onlyDict
andList
. Should there be aStarlarkSetIndexable
interface or should there be a patch to the existingStarlarkIndexable
, similar toEvalutils#setField
? For example:Mapping
is in the spec (as per dict() constructor should accept mappings #198), but does not exist. Should that be introduced alongside with the modification forSetIndexable
above? For example:This would also require a change in
Starlark#len()
.Sequence
extends thejava.util.List
interface. Are all sequences a sub-type ofList
? Did we meanCollection
?Interesting to hear your thoughts on this.
Thanks.
The text was updated successfully, but these errors were encountered: