[e-lang] Call patterns
Mark S. Miller
markm at cs.jhu.edu
Sun Jul 23 01:09:50 EDT 2006
This is in reply to old e-lang message
http://www.eros-os.org/pipermail/e-lang/2006-May/011268.html
Kevin Reid wrote:
> 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)) { ... }
This seems very plausible - I like it. Let's decide on a pragma.enable/1
switch name for enabling it, so we can experiment with it before deciding to
add it officially to E. How about
pragma.enable("call-pattern")
?
What's its BNF?
The need to add this to E-on-Java is now bug
https://sourceforge.net/tracker/index.php?func=detail&aid=1527171&group_id=75274&atid=551529
--
Text by me above is hereby placed in the public domain
Cheers,
--MarkM
More information about the e-lang
mailing list