3 ms·
I am not familiar with Rebol but from what I gathered from the "So...What Can't Be Done?" section of the article is that `use` is more like a code walker that d
by sedachv 11y ago
I am not familiar with Rebol but from what I gathered from the "So...What Can't Be Done?" section of the article is that `use` is more like a code walker that does lexical binding before the given expression is expanded and evaluated (hence the need for `compose`).
If I understand things correctly this is a lot like the `defmacro!` and sub-lexical scoping that Doug Hoyte writes about in _Let Over Lambda_. There the intention of code walking and rewriting is to prevent unwanted variable capture (walking over the code and replacing certain names with unique ones that have their own unique locations is basically implementing lexical scoping).
So where `progv` might run into trouble is:
(progv '(msg) '("Hello") (greater10 20 '(foobar msg)))
Where foobar is something like:
(defmacro foobar (x)
`(let ((msg "abc"))
,x))
And a Common Lisp `use` might be something like:
(defmacro use (var binding expression)
(let ((var1 (gensym)))
`(let ((,var1 ,binding))
,(subst var1 var expression))))
- draegtun 11y agoYou should find this of interest because this is how USE is written in Rebol: >> source use use: make function! [[ "Defines words local to a block." vars [block! word!] "Local word(s) to the block" body [block!] "Block to evaluate" ][ apply make closure! reduce [to block! vars copy/deep body] [] ]]