by Carl Mäsak
Feedback on "Macros: Placeholdeeers!"
These comments pertain to this pooost.
- lue: '"Does this whole thing remind you of beta reduction in lambda calculus?" um, sure :) .'
- TimToady: "I think the CoffeeScript approach only works well for pieces of grammar that can have a specific piece of code stand in for a generic node, which is easier for nouns, but harder for more abstract grammatical constructs, like a new trait syntax, or a new parameter syntax. So I'd rather see something tied a little closer to grammatical categories rather than just ad hoc chunks of target text that the substituter might have to guess on which thing, or level of thing, is actually being referred to."
- geekosaur: "seems to me we need (a) some way to introspect the names mentioned in an AST (b) these names should default to be new names not related to any existing ones (i.e. it is an independent scope) unless is used to associate with names presumably via CALLER:: or etc."
- TimToady: "
quasi { ¤A ¤B ¤C }
# is A a listop? is it a declarator? is B an infix? is C an initializer? the parser must know in advance in order to parse correctly" - TimToady: "the most generic macro in P6 is going to look a lot like a parsing rule with an AST maker for its action closure, which may or may not build the returned AST out of quasis, that may or may not refer to the bits parsed by the parse rule, presumably by the same name they were parsed under"
- TimToady: "sometimes I think even
%*LANG
is the wrong way to handle braids" - japhb: wip macro idea
- masak: "japhb: using parameter typing to decide the grammatical category of incoming ASTs seems, hm, both right and wrong somehow."
- masak: 'learning from tinkering around with Qtrees: there are things out there that are neither terms, nor expressions, but kind of head off in another direction. yet they are very "structural" and expression-like. they sort of occur in "restricted" parts of the language. that's also currently where unquotes have trouble going.'
- moritz (chiming in via email): "I feel you overlooked a kinda important point in your examples and analysis: In Perl 6, all variables must be declared. So the example with the substitution goes BOOM on the first '$s'. Two of your three examples miss the variable declarations, which usually isn't your style. Something else might be going on."
- masak (replying): "It seems to me now that the simplicity of
.subst
is dependent on implicit variable declarations in a way I hadn't appreciated when writing the post."