[r6rs-discuss] Scheme pattern matching & R*RS
per at bothner.com
Fri Dec 17 03:52:25 EST 2010
On 12/17/2010 12:17 AM, Peter Kourzanov wrote:
> On Thu, 2010-12-16 at 23:42 -0800, Per Bothner wrote:
>> For example this would be mis-parsed in an unexpected manner:
>> (lambda (x y) (list y x))
>> My definition *is* (I believe) compatible (i.e. a super-set) of traditional
> But it still allows for only one pattern rule. Why not have:
> (lambda (x y) (list y x)
> | (x y z) (list z y x))
I agree some separator like that would work, and be quite readable, IMO.
One issue is that if you use | (or some other separator to separate
"cases") then you'd really want to be consistent and use the same
separator for match, let, etc etc. I'm not sure that works all that well:
<pat> <body> <body> ...
| <pat> <body> <body> ...
This seems a bit less inelegant.
I actually considered something similar, but using double bars:
(lambda (x y) (list y x)
|| (x y z) (list z y x))
This would actually be consistent with using | for symbol quoting - in
that case the "empty symbol" || would separate different cases.
> or, with arrows (and guards):
> (lambda (x y) ! (> x 1) => (list y x)
> | (x y) ! otherwise => (list x y))
Nothing wrong with going in that direction - but you're getting
further and further away from what people think of as "Scheme",
and I suspect most people here are going to be skeptical.
Language design means more than just throwing out ideas - you need to
work out a coherent language from it all. And I'm not sure the
direction you're going has "the Scheme nature".
You might find this interesting
The article does not describe a coherent language (there will be
more as I have time), and certainly not anything I'd call a "Scheme",
but it's a working-out of some my ideas. (I intend to support
patterns and unification, but haven't had time yet.)
per at bothner.com http://per.bothner.com/
More information about the r6rs-discuss