On Tue, 21 Oct 2008, David Green wrote:

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.

XPath does this by default, and XPath is what I'd want to model any tree-based stuff on, because it has a pretty comprehensive tree model. But having said that, I'm not sure that I want to do it by default. It'd certainly be an option, though.

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.

I admit to not understanding enough Perl6 to be able to understand what you're getting at here, but no doubt I will.

        :)


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: [EMAIL PROTECTED]    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Reply via email to