SPICE-0020: Deferred, type-safe references#1354
Conversation
6bd5bfc to
14a7c24
Compare
d7663a8 to
09ac8d7
Compare
c61ce90 to
0085962
Compare
ce06670 to
98a918f
Compare
Reference<T>| external property: String(key == null)? | ||
|
|
||
| /// If the access is access via subscript. | ||
| external isSubscript: Boolean |
There was a problem hiding this comment.
This is a binary condition; it's either property or entry access. Do we need two booleans?
There was a problem hiding this comment.
This is for ease/fluency of use: if a user is writing e.g. a function that transforms a Reference to a String, they may need to know whether each access is a subscript key or property; it may be necessary to check one way or the other and access.isSubscript is more meaningful than !access.isProperty (and vice versa).
Another alternative here is something like this:
type: "property" | "subscript"But that makes usage sites pretty verbose!
Curious if you have thoughts or alternative suggestions here.
There was a problem hiding this comment.
Is two booleans helpful? I suspect most code will look something like this:
if (access.isProperty) ".\(access.property)"
else "[\(access.key)]"There was a problem hiding this comment.
Yes, in the sense that the conditional may need to check if it's a subscript instead and
if (access.isSubscript)is more legible than
if (!access.isProperty)and both are preferable to
if (access.type == "subscript")or
if (access.property == null)2e0dc69 to
aa42423
Compare
| external property: String(key == null)? | ||
|
|
||
| /// If the access is access via subscript. | ||
| external isSubscript: Boolean |
There was a problem hiding this comment.
Is two booleans helpful? I suspect most code will look something like this:
if (access.isProperty) ".\(access.property)"
else "[\(access.key)]"75ac5ff to
8615a4a
Compare
… Module.output, and any property of an external class
d4deef5 to
af61e13
Compare
SPICE: apple/pkl-evolution#27
Resolves #912
[native-pkl-cli]