[Grace-core] Some notes on pattern matching on the wiki
James Noble
kjx at ecs.vuw.ac.nz
Fri Jul 1 18:25:07 PDT 2011
Hi Kim
> I'm afraid I don't really understand your pattern matching semantics pages.
fair enough. I don't think I understand them either - or rather, I do understand them
but I am very aware we need actual implementations and iterators before we come
up with a final (hopefully clean & simple & explicable) design.
> Is there any chance you can expand them, perhaps by adding examples?
There were examples, but (unfortunately) in section 500 which is right at the end!
I will try to sort this out over the next day or so: perhaps come back on monday?
I now realise there are actually _three_ steps here: first, the matching syntax,
second, rewriting the matching lambda into a method request that tries to do the matching,
and then, third: implementing that method dispatch via a method protocol.
Unfortunately the verison of the discussion on that page mixes
all this up. I will try to refactor - have another look on monday...
> I get lost starting in section 0 where I am not sure what bindings and pattern.boundvariables are to represent (can you give an example) and then in section 1 where I have no idea what the "pattern" is in "pattern.matchObject(pat)".
both were typos.
> For the syntax, I'm more partial to the Scala version than newspeak.
I figured you would be!
> By the way, I haven't seen convincing evidence yet that we need first-class patterns or combining operators on patterns. [Consider this part of my continuing efforts to keep the language simple!]
A crusade I share!
But one of the things I think I see in the newspeak design - that I didn't understand until talking to Gilad at the last workshop,
is that the closer pattern matching is to otherwise normal expressions, the fewer extra mechanisms you need in the language.
I don't fully understand all the details of that, nor how to make it work in Grace.
But I'd like to have a try. My goals are:
- simple straightforward syntax, with as little extra as possible
- simple translation to non-matching lambdas by introducing match protocol
- simple matching protocol.
We're not there yet (or at least I'm not). But it gets better each time around the loop.
more later...
James
More information about the Grace-core
mailing list