[Logiweb] More about "sub ... end sub"

Frederik Eriksen frederikeriksen at get2net.dk
Sun May 14 14:17:43 CEST 2006


Frederik Eriksen wrote:

>> I'm trying to a understand the "sub * is * where * is * end sub" 
>> construct. Why does pyk complain about the following test? (For more 
>> details, see the eriksen/frozen page).
>>
>> "[ math test sub       object g equal object g
>> is                            object d equal object d
>> where object d is
>>         object g
>> end sub
>> end test
>> end math  ]"
>
Klaus Ebbe Grue wrote:

> The "sub ... end sub" is value defined (not macro defined). So 
> evaluation of "sub ... end sub" leads to evaluation of the parameters.
>
> "object g" has no value definition, so it evaluates to T by default.
> "object g equal object g" also evaluates to T. T is not a parse tree, 
> so "sub ... end sub" complains (i.e. returns F).
>
> Solution: put "quote ... end quote" around the parameters: "[ math 
> test sub quote object g equal object g end quote is quote ... ]".
>
Hi once more,

Putting quotes around the parameters didn't work. According to the 
definition of "sub ... end sub" on the "check" page, the first thing 
"sub ... end sub" does is to put quotes around its parameters. So I 
don't think the problem has anything to do with quotes.

What did work was adding the words "apply check" to the test, like this:

"[ math test sub object g equal object g
is                     object d equal object d
where object d is
          object g  
end sub apply check
end test
end math  ]"

I think the explanation is something like this: In reality, the "sub ... 
end sub" construct is a lamda function which must be applied to an 
argument to get off the ground. Writing "sub ... end sub apply check" 
applies "sub ... end sub" to the argument "check". The function doesn't 
use the argument for anything, so any construct will do in place of "check".

Best Regards
Frederik Eriksen.


More information about the Logiweb mailing list