Caching Binding Lookup, and "Attachment Binding"

Okay, that emulation is out the window, so let's drop it from consideration. (Though building an emulator in Ren-C would likely be relatively easy given the infrastructure, but that emulation would be a whole different evaluator.)

I wonder if people would be happy enough if it just did top-level declarations.

>> x: 10
== 10

>> (y: 20)
** Error: Y is not bound

>> (let y: 20)
== 20

>> y
** Error: Y is not bound

>> y: ~

>> (y: 20)
== 20

>> y: ~<used by some-func>~  ; <-- tripwires are so cool
== ~<used by some-func>~  ; anti

>> some-func: func [x] [y: x] 

>> some-func 20

>> y
== 20

If you need to make a bunch of variables in a context, the wrap command could help you:

>> wrap [x: 10 y: 20 z: 30, x + y + z]
== 60

>> z
** Error: z is not bound

So the console and whatever else could perhaps use a variant of that, where instead of using a fresh context you inject the variables into another one:

>> wrap* system.contexts.user [x: 10 y: 20 z: 30 x + y + z]
== 60

>> z
== 30

Could do it as a refinement to wrap, though it puts the argument at the tail which I find annoying.

wrap:inside [x: 10 y: 20 z: 30 x + y + z] system.contexts.user 

I think that covers the bases for me, but I'll have to try propagating this stuff in the system to find out.

If attachment binding disappeared, I'd shed no tears.


(Okay, I posted that 30 minutes ago, and I just booted a system with no attachment binding, so... yeah. I think it's time to let it go. People will write better code this way, strict mode is good.)

2 Likes