Joel Neely said:
A somewhat trivial example in REBOL is (cut-and-paste with
slight reformatting for readability):
>> curried-sum: func [
a [number!]
][
func [
b [number!]
][
a + b
]
]
>> do (curried-sum 3) 5
== 8
So far so good, but:
do (curried-sum 3) do (curried-sum 2) 1 == 5
do (curried-sum 2) do (curried-sum 3) 1 == 7
If an inner function in REBOL has any free variables, and you
attempt to return it, or pass it as an argument, the effect of
calling it is unpredictable. So I guess that not all functions
in REBOL are first-class -- only top-level functions or inner
functions with no free variables.
Gabrielle said:
Thing is, I don't think that's a bug. Have a look at my
other posts.
I have to disagree. When you return an inner function, you have
to use it before any other calls are made to the outer function,
(otherwise your free variables are clobbered). But having to
know if *any* calls to the outer function from *anywhere* have
occurred is in general undecidable. How could this be used
in a constructive manner?
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com