Robert Heckendorn wrote:
> I very much enjoyed the elegance of S4 patterning. I am intrigued
> by Clint's comment
> on best of both worlds. Do you have some syntax/semantics you are thinking
> of?
Hi Robert,
There are a lot of aspects to this. Off the top of my head, here
are the things I see [Clint probably has a different list.]:
(1) S4 patterns are concise representations.
I don't think Unicon can approach this (for one thing, I
*never* want to see blanks as operators, *ever* again!) without
munging the language itself. However, Unicon isn't all that bad
here, but you have to think differently than you do with
S4 patterns.
(2) S4 patterns are data objects.
You can *almost* get this effect in Unicon with
co-expressions (heh, you can 'almost' get anything
with co-expressions!). for example:
procedure main()
pat := create |(tab(upto('f')), ="foo"||move(1)||="baz")
"foo baz bar" ? write(@pat)
"bar foo:baz a foo?baz" ? {
write(@pat)
write(@pat)
}
end
writes out:
foo baz
foo:baz
foo?baz
(It's an exercise for the reader to figure out why I said
"almost"...). It might be worth exploring this more to figure
out how to do something similar that gets around the limitations
that currently exist. (Using closures to build the patterns may
help here for some of the issues, but not all, I think.)
The nice thing here is that you can put anything into
the 'pattern', not just matching constructs. That's a better
integration into the language as a whole.
(3) S4 pattern matching is fast.
I'm not convinced string scanning is *that much* slower, but
it should be reimplementable to take advantage of some of the
same implementation techniques as S4 PM.
--
Steve Wampler -- [email protected]
The gods that smiled on your birth are now laughing out loud.
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group