You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it was a normal stdlib function, that could work.
The problem is get (and set) are used extensively and mostly auto-transformed at AST level (.field which we have recently added could be an exception, since it's for objects only).
But having to check if the attribute is there for normal array/dictionary access, apart from slow (performance-wise), it would be close to impossible... 😉
why not have get.default: in the stdlib, and transform it into a (hidden?) vm operation fetch when "compiling"?
AST transformation generally plays with the main tree structure when doing its magic. But attributes are not included.
If they were, it would defeat the very cascade-style nature of attributes in Arturo...
I mean...
do.default [
get ... ; is this a `get.default`? Could be, or could be not... we cannot know on the AST level
]
Technicalities aside, something that I actually wanted (probably for months lol) is a quick way to short-circuit a get, and that: x: (fetch d 'field) ?? "default" looks short enough...
The main idea:
get
with blocks, dictionaries, etcnull
fetch
x: (fetch d 'field) ?? "default"
The text was updated successfully, but these errors were encountered: