Joe Marshall on Rebol 1.0 vs. Rebol 2.0 Binding

:star: :star: :star:

I've pointed out in my examples that indeed, everything starts unbound... with "trickling down" context giving the meaning:

>> doubler: func [x] [
      let code: copy [add x]
      append code to word! "x"
      print ["Doubled:" eval code]
      return none
  ]

>> doubler 10
Doubled: 20

That function body is fully unbound (and never becomes bound!) Since nothing tricky is going on with code composition, it works like any lexically scoped code would.

But then...

I show off this "interesting idea" in "Ren-C Binding in a Nutshell", where compositional code can take advantage of this.

>> x: 1000

>> doubler: func [x] compose [
      let code: copy ($[add x])
      append code to word! "x"
      print ["Doubled:" eval code]
      return none
  ]

>> doubler 10
Doubled: 2000

I don't think it is. You could always put a symbol in a list like (x) instead of x. But that costs more... and what if you need it to be a WORD! for the dialect to recognize it as the right "part of speech" for the functionality you want?

Hence you can (still) go down to the level of a single symbol:

>> x: 1000

>> add1000: func [x] compose:deep [
      let code: copy [add ($x)]
      append code to word! "x"
      print ["Added a Thousand:" eval code]
      return none
  ]

>> add1000 20
Added a Thousand: 1020

While this aspect of what Carl wanted is "unusual", it's important to have this granularity of control if you want to have a symbolic structure for the code that is hybridizing meanings from multiple sources.

(It just needed "lexical environments" as the baseline, with this finer-grained tweaking as a composition tool for when you need it.)

1 Like