[nem-en] literal pattern matching
Michal Moskal
malekith at pld-linux.org
Sat Sep 25 00:05:07 CEST 2004
On Fri, Sep 24, 2004 at 11:02:20AM +0200, Wiktor Zychla wrote:
> >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".
In case of misspelling your code switches from catch-n to catch-all
behavior. We have considered this evil.
It also complicates semantics of matching. Patterns are quite simple
objects now, and adding external values inside the patterns increase
complexity.
There is one more reason -- we don't have real structural equality. So
doing this for anything except value types could get tricky.
--
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: ::: Logic is a nice contrast to the Real World. :: UL++++$ C++ E--- a?
More information about the devel-en
mailing list