6macros: discussing the finer points of Perl 6 macros, Qtrees, and how to stay sane | irclog: irclog.perlgeek.de/6macros/today
Set by moderator on 19 March 2015.
07:49 Ven joined 08:18 Ven joined 11:50 Ven joined
masak this would be a good place to hash out various possible syntaxes for all the things we want macros to do. 11:51
(I'm teaching today, so I don't have loads of time to do it.)
(just wanted to share the idea.)
I'm experiencing some degree of "idea overload" from having seen macros and similar things in other languages. I would appreciate much more seeing macros in Hypothetical Perl 6. 11:52
and concrete things like, "I have this string here. how do I create a function of that name?" 11:53
Ven masak: something like my "MATCH" macro?
masak yeah, things like that.
what my grant really should amount to is arriving at a consistent set of "tools" (syntax, APIs, mechanisms) for doing common macro use cases.
the only reason I explore other languages is to get a sense of how they cover the use cases. 11:55
Ven mmh
masak after that, I/we still need to find our own path in Perl 6.
Ven perl6 has a huge issue tho
masak just one? :) 11:56
Ven the operators stuff, say
I'm just talking about a specific one here ;)
masak go on.
Ven in elixir, I have this macro "ADT.define foo | bar | baz"
masak *nod*
Ven it gets called with foo | (bar | baz)
so, I need to "flatten" these 11:57
to get [foo, bar, baz]
I *cannot* do that in perl6 because of how the operators things work.
masak um.
there's chaining operators.
Ven no, it won't work. only "is parsed" would work here
masak did you consider those?
Ven yes, but I can't define infix:<|> is assoc(<list>
what'd be the operand types? 11:58
masak oh, I see what you mean
Ven Any? but then, it'd override the "real" | operator
masak right, it'd have to be "is parsed"
masak will ponder this
thanks for your input.
Ven macro define-adt($/) is parsed /<call> + % '|'/ { for $<call> { die "invalid operand" unless $_ ~~ Callable; ... } } 11:59
that's *one* example :) 12:00
I actually think we don't really need a MATCH macro, as given/when+signatures *should* work
HOWEVER, I'd really love to have, say, `fun NAME { when :($a, 5) { ... } }` 12:01
(or function, if I want it to feel ml-ish)
... 12:07
tbh, doing that with "is parsed" makes me feel like we're reinventing a beast we tamed 12:08
12:21 Ven joined
masak yes, exactly 12:53
16:14 Ven joined