|
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 28 July 2015. |
|||
|
10:31
pdcawley joined
|
|||
| masak | \\o | 10:41 | |
| pdcawley++ suggested the solution to strangelyconsistent.org/blog/macros...el-is-hard might be to put a lambda around the {{{ }}} in the unquote | 10:42 | ||
| I can't immediately dismiss that idea :) have to try it. | |||
| pdcawley | p6 has quasi, does it have quote too? | 10:45 | |
| Or is that simply lambda {...}? | |||
| because it's a bloody useful special form to have when you're fiddling with stuff. | 10:46 | ||
| masak | isn't quote just a quasi without unquotes? | 10:47 | |
| pdcawley | How do you write: quasi { quote {{{expr}}} } | 10:50 | |
| masak | dunno; maybe Ven does? | 10:51 | |
| pdcawley | masak: You can't write it as quasi { quasi { {{{expr}}} } } can you? | ||
| masak | I think that'd parse, but... | 10:52 | |
| pdcawley | macro quote expr { quasi { sub () { {{{ expr }}} } } | ||
| masak | ...the {{{expr}}} would expand in evaluating the *outer* quasi | ||
| pdcawley | masak: Which, in that case would be what you want. | ||
| given $thing = quasi { ... }. How do you get at the actual value, btw? (been away from Perl 6 for a while...) | 10:53 | ||
| masak: Does macro lookup (expr) { quasi { -> { {{{expr}}} }() } not do the trick? | 10:57 | ||
| masak: No... no it doesn't. Call me mr silly. | 10:58 | ||
| masak | the more I think about it, the less I think it helps | ||
| it boild down to just a lambda | |||
| supper & | 11:02 | ||
| pdcawley | So... in 007, how would you write short_circuiting_and(expr1, expr2)? | ||
| assuming all you've got available to you is 'if'? | |||
| ie, how do you control what gets evaluated when? | 11:03 | ||
| or, say, macromap { it * 2 } @list | 11:05 | ||
| last one's easy: macro macromap(block_expr, list_expr) { quasi { map ->(it) { {{{block_expr}}} } {{{list_expr}}} } } | 11:07 | ||
| masak | macro short_circuiting_and(expr1, expr2) { return quasi { my $e = {{{expr1}}}; if $e { $e = {{{expr2}}} }; $e } } | 12:49 | |
| boo-yah! | 14:36 | ||
| $ perl6 bin/007 -e='macro foo() { my how = "correctly"; return quasi { say("quasi lookup works " ~ how) } }; my how = "incorrectly"; foo()' | |||
| quasi lookup works correctly | |||
| \\o/ | |||
| biggest breakthrough since custom operators :D | 14:37 | ||
|
15:47
pdcawley joined
16:25
pdcawley joined,
_Ven joined
|
|||
| _Ven | ahoy. | 16:25 | |
| seen some messages in the irclog | |||
| the nested macro case is an interested one, but I think we can just copy what lisp does here | 16:26 | ||
| two level of quoting, so for us, nested quasis (since quote == quasi) | |||
| if we need to double-unquote, we'll probably going to use {{{ {{{ :) | |||
| ah but since it's 4pm, masak++ is probably sleeping :( | 16:37 | ||
| hi, pdcawley. | |||
| oh.. | 16:39 | ||
|
19:45
vendethiel joined
19:48
Ven_ joined
21:12
Ven_ joined
21:33
Ven_ joined
21:45
Ven_ joined
21:57
Ven_ joined
|
|||
| Ven_ | erm, didn't get to the ast thing yet. got a bit of smalltalk and apl done, though... I'll try to do a bit of that tomorrow | 22:10 | |
|
23:12
Ven_ joined
|
|||