Re: pattern matching on fields of the argument

Adam Megacz <[email protected]> Wed, 04 Aug 2004 22:15:50 -0700
Newsgroups gmane.comp.lang.nice.devel
Organization Myself
Message-ID <[email protected]>
Daniel Bonniot <[email protected]> writes:
> foo(Foo f) if (f.a == null) = ...

Yes, this could be much more useful in certain situations!

However, in most of the situations I'm dealing with, it could be
worse... for example:

class Expr { ... }
class Apply { ?Expr e1; ?Expr e2; }
class Lambda { String id; ... }

foo(?Expr)
foo(Apply(e1:Lambda(id:"foo"), e2:null))

This would require two null-checks, two instanceof checks, an ==
check, and an .equals() check.  Ideally I'd like most of these
functions to be one-liners so they appear like a table when viewed in
a text editor...

What would you say is the most difficult challenge in implementing
something like this?

  - a



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com