[nem-en] literal pattern matching

Wiktor Zychla wzychla at vulcan.edu.pl
Fri Sep 24 11:02:20 CEST 2004


>> Note, that k is bound inside the method body and should probably not
>> be treated like a free-variable to match with any value of n. Instead,
>> as bound variable, it probably should be matched "by value".
>
> (IMHO you used these adjectives are backward. You want it to be
> *bound* by the match, not *free* i.e. referring to a value defined
> outside.)

this is how it works in Nemerle: the name becomes bound by the match.

what I ask is: if the name was bound before, should it be bound again?

>
> How would you distinguish whether an identifier means "bind the
> variable here" or "compare with its value"?
>
> If you would do this by checking whether it has been defined, it
> would be a bad idea, because the only way to ensure that this is
> its definition would be to check that it has not been defined in
> any active scope. Such "negative checks" should not be required.

It is clear that to distinguish free variables from bound ones one has to 
check if the variable name is defined in any active scope. However, I still 
do not understand why it woule be a "bad idea".

Wiktor 






More information about the devel-en mailing list