Hi Ladislav, 

you wrote:
>I give you another example:
>Your composite function:
>composite: func ['f 'g][func [x] compose [(f) (g) x]]
>f: func [x [any-function!]] ["OK"]
>g: func [x] [:x]
>x: func [x] ["OK"]
>fg: composite f g
>
>[correcting the typo:]
>
>>> result: fg :x
>** Script Error: x is missing its x argument.
>** Where: result: fg x

Composite works properly. x is an active function. x is supplied as an
argument to the composite function. The following will be executed:

compose [(f) (g) x]

f becomes the func [x [any-function!]] ["OK"]
g becomes func [x [any-function!]] ["OK"]

g wants an argument x, so REBOL grabs the x in compose [(f) (g) x]

REBOL evaluates x's body because it is a function and whatever the body
evaluates to will be used as g's argument. x is a function that takes an
argument. You didn't supply an argument for 'x, so REBOL reports an error.


Hope this helps,

Elan

Reply via email to