On 2008-Oct-2, at 6:15 pm, Timothy S. Nelson wrote:
The guys on IRC convinced me that the way to go might be something
like a grammar, but that does trees and tree transformations
instead of a text input stream. See the IRC log for details :).
[...]
<TimToady> note to treematching folks: it is envisaged that
signatures in a
rule will match nodes in a tree
There does seem to be a clever idea waiting to happen here, although I
expect signatures will be somewhat simpler since they are intended for
a more specific purpose.
One thing I would like signatures to be able to do, though, is assign
parameters by type. Much like a rule can look for identifiable
objects like a <block> or <ident>, it would be very useful to look for
parameters by their type or class rather than by name (or position).
For example, if I ask you to hand me a hammer and a nail, I don't need
you to hand them to me in a specific order, or with labels attached
like a Dick Tracy comic, in order to know which is which. That's
obvious, because, well, one is a hammer and one is a nail. If I'm
writing OO-code, then Perl also knows what's a Tool::Hammer and what's
a Fastener::Nail -- if I know that my $tool is a hammer, and Perl
knows, then I shouldn't have to spell it out.
The :$foo shortcut for :foo($foo) addresses the same problem, but in
terms of naming; it is reasonable that a Foo object would be named
"$foo" in both the caller and the sub, but not necessary. Being able
to use class info that's already there would make it easy to grab
params when I know the type of object I'm looking for, but not what
it's called.
-David