[Grace-core] Some notes on pattern matching on the wiki

James Noble kjx at ecs.vuw.ac.nz
Sun Jul 3 04:24:24 PDT 2011


Probably mostly useful for Michael (if he's going to work on this on Monday NZ time)

I've edited - https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/GracePatternMatchingSemantics
to tidy up the typos Kim found.  It's still rough, and only covers the "Smalltalk" style passing block around,
but it may be a bit better than before.

I'll try to do the other Scala/Option/Monad alternative tomorrow my time...

A start about Grace-style pattern matching syntax is here: https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/GracePatternMatchingSyntaxGrace

Basically the syntax as we use it currently has an ambiguity.
We have to keep the same syntax for patterns as declarations.

So writing "id : type" must declare a pattern-match-variabel that will match against type "type" .
That's fine.

But in declarations we can just write "id" to mean declare the "id" with either dynamic 
(on method bodies)  or inferred type (initialised declarations).  Fine so far.

BUT we want to write just "Type" to match against types like "None"! 

problem is: that's ambiguous, it's not clear if its matching against None, or declaring a new variable called None.

This doesn't happen in Scala, because Scala has a separate namespace for Types & for variable/method names;
you always know what you're dealing with.  We don't. 

James




More information about the Grace-core mailing list