Hi Ladislav,


At 11:22 PM 12/5/99 +0100, you wrote:
>Hi, Elan,
>
>As I understand now, your point of view is, that the definition:
>
>
>samef: func [f [any-function!]] [func [x] [f x]] ; (1)
>
>isn't allowed in Rebol "because it doesn't work in Rebol for some reasons
>..." 

I never said that. Apparently you enjoy ignoring the contents of my email
and replacing what I say by your own inventions. Not smart or courteous.
How about, I'll define the contents of my email and you define yours? You
quote statements I never made, namely 

>> it isn't allowed "because it doesn't work in REBOL for some reaons ...", 

1. I didn't say it is not allowed. Nor do I believe or suggest that it is
not allowed. I don't even leave it up to the reader to conclude that
perhaps I believe it is not allowed.
2. I didn't I say it doesn't work. Nor do I believe or suggest that it
doesn't work. I don't even leave it up to the reader to conclude that
perhaps I believe it doesn't work.

samef: func [f [any-function!]] [func [x] [f x]] 

This function is a permissible function and it will do something useful.
What it will do is NOT what you expected this function to do.  Too bad. 

In my last email I described for your benefit what the function does and
contrasted it with what you intended for the function to do. I then showed
you a sample function that does do what you wanted this function to do. And
I finally commented on how the example function I used to illustrate the
difference differs from your implementation of samef.

Since you apparently didn't read my explanation, here it is again:

Your samef function returns a function, namely 

func [x] [f x]

when that function is evaluated, to words are dereferenced, x and f. x is
bound to the argument passed to the function func [x] [f x]. f is bound to
a value in the context of samef's argument block:

samef: func [f [any-function!]] [func [x] [f x]] 

Therefore, REBOL will look up f's value in samef's argument block and
retrieve whichever value was last bound to f, when samef was last
evaluated. What the function 

func [x] [f x] 

will do when it is evaluated depends on f's value, which in turn is defined
in samef's argument block. 

Now, if you want f to be bound to the function you passed as an argument to
samef at the time func [x] [f x] was bound to a word:

a: samef :id

then you have to implement samef in such a way, that f is dereferenced at
the time that a is assigned the reference to the newly created function. 

What your version of samef does is it does not dereference f at the time a
is created, instead it assigns f as the instruction to dereference f at the
time a is evaluated. 

The value f will be bound to at the time a is evaluated may be the value
passed to samef at the time samef was used to create a. It may be a
different value. It will definitely be the value that was passed to samef
when samef was last evaluated.

Knowing that you can formulate a function samef, which dereferences f at
the time a is created, as I demonstrated. 

The whole point is to know that there is such a thing, namely that words
are bound in contexts and that their value depends on 
a) the context they are bound in, and
b) the value they are associated with in that context at the time they are
dereferenced, and
c) when they will be dereferenced.

Ignoring these three things is what led you to misunderstand the function
you implemented. You were therfore surprised at the results you obtained. 

Saying this is a far cry from saying  that you may not do something, or
that something isn't working properly in REBOL.

If you've read and understood my email up to here, let me know.

Take Care,

Elan

Reply via email to