Felix has a few funny symbols, like @T, stuff with $ and #,
and a lot of syntax is overloaded in a way that isn't always so consistent.
Only one character is unused: ` (backtick).

Now, in considering the idea we write

        @T = opt[T]

so we can write

        @+T 

for a possibly NULL incrementable pointer, I find I would prefer

        ?T

for an option type. Agrees with regexp notation. A bit more obvious.

At the same time we have this horrible wart:

        match .. with | Some ?x => .. | None => ...

and it turns out this doesn't conflict at all with ?T. However
this case does:

        typematch .. with | ?D -> ?C => ...

because type patterns are parsed as expressions not patterns,
whereas value patterns have their own syntax (there's a reason:
we may want "pattern calculus" for type patterns where the pattern
is an evaluable expression).

Now, i could change the value pattern syntax:

        match .. with
        | Some x => ... // no ? needed!
        | #None =>  .. // the # is the price for ?


The trick is to parse

        name name

as

        constructor pattern-variable

since you cannot have applications in patterns.  Although we cannot
do curried constructors at the moment, this should still work.

This leaves the problem with type matches. You would have to write

        typematch .. | #int => ..

to match an int. Type matches don't support constructors at the moment.
[There are no meta-unions .. yet!]  Type matches are harder to deal
with because whereas value literals are clear: 1, "hello" etc,
any non-polymorphic type expression is a literal in a type match.
So the type literals must be distinguished from type pattern variables
and the "application" trick cannot distinguish type literals
from constant constructors, let alone non-constant constructors
if we ever get them.

Actually the syntax should be:

        typematch ... | $(int) => ...

because in an ordinary match

        match .. | $(x) => ..

actually means

        match .. | ?a where a == x => ...

however type matches aren't used much, so perhaps it doesn't matter :)

bottom line: use @T for opt[T] or ?T and  then #None in matches...



--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to