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 17 July 2015.
00:36 vendethiel joined 04:36 vendethiel joined 05:56 vendethiel joined 06:36 vendethiel joined 07:41 vendethiel joined 09:53 vendethiel joined
vendethiel pings masak 22:19
masak pong. 22:22
vendethiel masak: how hard would it be to convert that S17-improvements gist into macroooos? 22:23
:D
masak would probably be an interesting exercise.
I mean, they are just syntactic sugar, after all.
vendethiel exactly 22:24
masak macros in their current form are not up for it.
but the keyword + expr + block thing is very very common.
I want macros to do that.
vendethiel no, but that hasn't stopped me in the past either
masak I have next to no idea how
vendethiel masak: with your "COMPILING.^declare-var" proposal 22:27
how does it fit if I want lexical variable?
as in
quasi { my $a; {{{ $stuff-with-a }}}; }
masak well, first off, whatever's in your $stuff-with-a AST will have a hard time seeing your `my $a;`, due to hygiene. 22:28
vendethiel that's my question
masak it's a good question. 22:29
see, the COMPILING:: and :COMPILING things are always discussed in the context of quasis, never in the context of unquotes.
I'll need to ponder that one a bit.
well, ok: 22:32
(a) it seems there's a real need.
vendethiel i'm writing up something :)
masak (b) maybe AST "hardening" will actually make this one work out automatically.
vendethiel I kinda like where I'm going with my gist. 22:39
except for the var.
masak there are two kinds of AST, based on how they're built. 22:41
"natural" ASTs come from actual source code in the program. they have an environment because everything in the source code does.
"synthetic" ASTs are built up from parts. the parts don't have an environment, and so neither does the AST. 22:42
vendethiel scala is interesting in this regards
masak but it needs one when it's spliced in, and so it gets one at the last minute -- the one of the surrounding code.
in that sense, synthetic ASTs are actually rather unhygienic. but I think that's good. 22:43
it kind of counterbalances a lot of the hygiene we have in the system :)
vendethiel my gist is *almost* ready 22:47
.oO( hang in tight, we're crunching the latest macro for you )
masak ;) 22:48
vendethiel okay, ready 22:51
gist.github.com/vendethiel/bff772fc084ca88bb253
masak reads 22:53
QV::ar -> Q::Var ?
it looks intriguing. 22:55
I find I don't have much coherent to say about it; maybe more tomorrow when I'm awaker.
but I do note a potential problem already.
vendethiel yeah, of course :p
masak actually, two. 22:56
your macro parameter &block will never bind correctly, since an AST/Qtree isn't Callable
second, that `{{{&block}}}` there splices in a *natural* AST. hence, hygiene applies, and it can't see the `my {{{$var}}};` 22:57
vendethiel fixed 22:59
well
it should be able to see it 23:00
masak `$block where Q::Call` better written `Q::Call $block` ;) 23:01
oh, I see, you're replacing parts of the natural Qtree with synthetic ones. 23:02
then I take back my objection.
ah, and you solved the `whenever $supply -> $var { ... }` parsing problem by ignoring it ;) 23:13
vendethiel ;-)
masak in the fullness of time, I want a solid way to do that. 23:14
something better than `is parsed`
vendethiel suure.
but not needed to whenever :P
masak sure, if you can live with that comma. 23:15
haha, maybe the solution could just be `macro whenever($expr, NO_COMMA, $xblock) { ... }` :P 23:16
though that feels like decidedly the wrong hook. ASTs are not parsing. 23:17
vendethiel lol :D 23:19
masak ok, my energy's run out. time for bed.
'night
vendethiel gnight :) 23:21
i'm just happy if I can provide a few pseudo-macros :P