because pattern matching is desugared early, before lookup or typing, Felix
requires you to write
match x with | Int ?i => ...
You can also write
val ONE = 1;
match x with | $(ONE) => ...
to match a value, which just means
match x with | _ as tmp when tmp == ONE => ...
Anyhow the need for $ and ? is because we have to tell, syntactically,
the difference between a constructor name, a value, and a pattern variable.
So plain names are constructors, values need a $, and pattern variables
need a ? in front.
It's inconsistent, because really one should regard function calls and val
bindings as pattern matches:
let ?x = 1 in ..
looks plain ugly.
However, this is almost unambiguous:
match x with | Int i => ...
Given we don't allow values except in $(expr) that i pretty clearly meant to be
a variable.
The confusing case is this one:
match x with | true => ..
i.e. where we have an constant constructor. Note the argument of Int might also
be
a constant constructor, we cannot be sure. However, ATS solves this problem
by simply requiring "argumentless" constructors to really have a unit argument
in some sense, and writing it:
match x with | true () => ...
The extra () here (which in Felix might be rewritten #true) is only needed in
patterns,
and if we insisted on this we can dispense with the need for ? before variables
by
observing that constructors always have arguments .. so something without an
argument is a pattern variable. It might be a pain to write
true () or even #true
in code everywhere (though the latter is not bad) but we're only talking about
patterns here.
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language