[e-lang] Call patterns

Kevin Reid kpreid at mac.com
Wed May 17 11:17:52 EDT 2006


This is something I'm playing with in E-on-CL.

   def a.b(c) := d

expands to

   via (__makeVerbFacet.curryCall(a, "match__b/1")) [c]

The idea is that call patterns are a form of extensible pattern which  
is more suitable than quasi-patterns for objects which do not  
naturally have a (semi-) textual syntax.

The receiver in a call pattern is an expression, the verb is  
constant, and the arguments are patterns, so it asks the receiver to  
match the specimen and return a list of components to be matched  
against the subpatterns.

For example:

     def Ref {
       ...
       to "match__broken/1"(r, ej) :any {
         if (Ref.isBroken(r)) {
           return [Ref.optProblem(r)]
         } else {
           throw.eject(ej, makeNotBrokenMismatch(r))
         }
       }
     }

   # without call-pattern
   if (Ref.optProblem(ref) =~ p :notNull) { ... }

   # with call-pattern
   if (ref =~ Ref.broken(p)) { ... }







-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list