Hi,

> Finally, another question, (...) arised in this process:
>
> I never understood why
>
> -- start of console session --
> >> source func
> *func*: *func* [
>     "Defines a user function with given spec and body." [catch]
>     spec [block!] {Help string (opt) followed by arg words (and
opt type and string)}
>     body [block!] "The body block of the function"
> ][
>     throw-on-error [make function! spec body]
> ]
> >> source throw-on-error
> throw-on-error: *func* [blk][
>     if error? blk: try blk [throw blk]
>     :blk
> ]
> -- end of console session --
>
> doesn't leed to endless recursion.
>
> Thanks again,
> Regards
>
>    Christian
>    [EMAIL PROTECTED]
>

The reason is quite simple. You may try to execute the source :

*func*: *func* [
    "Defines a user function with given spec and body." [catch]
    spec [block!] {Help string (opt) followed by arg words (and
opt type and string)}
    body [block!] "The body block of the function"
][
    throw-on-error [make function! spec body]
]

with unset *func*, it wouldn't lead to any recursion, instead the
result is:

** Script Error: *func* has no value.
** Where: *func*: *func* [
    "Defines a user function with given spec and body." [catch]
    spec [block!] {Help string (opt) followed by arg words (and
opt type and
string)}
    body [block!] "The body block of the function"
] [
    throw-on-error [make function! spec body]
]

So, you can see, that it doesn't point to any recursion, instead
it simply doesn't work. What does that mean and how shall we read
that? My suggestion is as follows. Try to read the above as:

*func*: *done-by-hand-func* [
    "Defines a user function with given spec and body." [catch]
    spec [block!] {Help string (opt) followed by arg words (and
opt type and string)}
    body [block!] "The body block of the function"
][
    throw-on-error [make function! spec body]
]

, which means, that the *done-by-hand-func* behaved exactly like a
*func* function, but was done by a programmers' hand.

Regards
    Ladislav

Reply via email to