Using LAMBDA/FUNC as a Generalized Binding Tool

When I said "an alternative choice" I meant "an alternative choice to using UNUSE" (clarified) e.g. the choice of using unbound code.

But as for the question of whether quoted code must be unbound... it could also be that all things are bound under evaluation, quoted or not, but you can UNBIND them.

You could write:

keep: does [print "Outer KEEP"]
code: unbind '(keep <example>)
collect compose/deep [
    repeat 1 [
        repeat 1 [
            repeat 1 [(code)]
        ]
    ]
 ]  ; would generate [<example>] block

It would be easier to make bound non-inert arrays (GROUP!, SET-BLOCK!s, etc)... otherwise you'd need something like as group! [some block] or bind-to-current '(some group).

This would let lambda [x] [get 'x] work, and thus be more compatible with today's expectations.

But as I said, I like the idea that what happens when a quote level is dropped has parity with what happens when a variable is fetched.

And on that point, quoted things aren't unbound from evaluation... they just don't change the binding from what they "contain" when evaluated.

>> original: [print "Hi"]
== [print "Hi"]

>> do original
Hi

>> generated: do compose [(quote original)]  ; or ['(original)]
== [print "Hi"]

>> do generated
Hi

For me, this is what really drives the "don't bind" rule for quotes... because it needs to be "don't interfere" for cases that don't have a WORD! reference available to shield from the evaluator's influence. Then it just so happens that all scanned material would start off unbound, so quoted source material would evaluate to being unbound.

Anyway, reducing the amount of stray bindings sounds very appealing, this feels like a good direction to be taking.

2 Likes