Open hiiamboris opened 2 years ago
What about safe
as a refinement/routine name? Aligns with do-safe
and attempt/safer
. There's also a slight mismatch in behavior today, because set
does not error when trying to set a word that doesn't exist in a context. Just as do-safe
is marked for internal use, get-safe
aligns with that as a routine. I can see people wanting to use it regularly though, simply because checking for none
seems nicer in many cases than handling errors.
The object in the example should be: o: object [a: 2x3 b: none]
else there would be uncaught error:
>> all [o o/a o/a/x]
*** Script Error: cannot access a in path o/a
Indeed. Copied something else :D
I often have to write long code to guard against path errors, e.g.:
width: all [layout layout/size layout/size/x]
This is a long known pain point since Rebol with no good solution.
attempt [layout/size/x]
is often used in this situation, but it's only acceptable in low-performance code parts (which in my code are usually very few):I propose adding an efficient
get/quiet 'layout/size/x
call which if any of the path items are not accessible, instead of erroring out would returnnone
.