|
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 12 July 2015. |
|||
|
01:25
vendethiel joined
04:25
vendethiel joined
05:57
vendethiel joined
07:10
vendethiel joined
07:39
vendethiel joined
08:09
vendethiel joined
08:36
vendethiel joined
09:33
vendethiel joined
10:56
Ven joined
14:14
vendethiel joined
14:39
vendethiel joined
|
|||
| masak | so, I've been thinking. | 17:52 | |
| (it's great that this channel exists, because these are only half-formed thoughts so far, and I don't want to have everyone reviewing them just yet) | |||
| hooks per grammatical category | 17:53 | ||
| something like "whenever we parse a function (and get a Qtree), also call this user-provided function/macro (which can inspect and manipulate the Qtree)" | 17:54 | ||
| among all the things we know we want to do, this wish seems the most straightforward. | |||
| my use case is from 007: someone wants to extend `my foo;` declarations to be able to handle type declarations: `my Int foo;` | 17:55 | ||
| oh, actually, that's an interesting but slightly too advanced use case to start with. | 17:56 | ||
| better to start with [Coke]'s idea of having checked exceptions from the other day. for that to work, some function (like above) would have to inspect each parsed sub to see if it throws a checked exception -- and if it does, make sure that the sub is marked up with an appropriate trait. (or die otherwise) | 17:57 | ||
| vendethiel | interesting idea. | 18:01 | |
| that'd be lexically installed? | |||
| masak | yes, that makes sense to me. like operators. | 18:02 | |
| ...but exportable. | |||
| (disclaimer: 007 doesn't do exports in any form yet. nor does it have modules.) | 18:03 | ||
| vendethiel | first thought: is there a way to opt-out from that, say, to generate subs from macros that will not respect this rule? | ||
| well, I guess you can generate { no x; our sub ... } | |||
| masak | hm. | 18:04 | |
| I'm not sure I see the need. feels like it'd be better if the installed hook regulated what it applied to. | |||
| the downstream client code, in a sense, isn't supposed to care how it's being analyzed/mogrified. | 18:05 | ||
| vendethiel | hence why I said "for generating a sub inside a macro" | 18:06 | |
| but let's drop that idea for now | |||
| masak | ah, ok | 18:13 | |
| don't understand, but will keep in mind that there may be a use case | |||
| certainly there are interesting timing issues involved. | |||
| for example (like with macros), I think that there should be no retroactive firing of hooks on already parsed things. too messy. | 18:14 | ||
| vendethiel | right | 18:15 | |
| still feels like action-at-a-distance somewhat :P | |||
| reminds me of jnthn++'s OO:: modules | |||
| which used macros to check for the correct state declared in the "class"'s "is state(<...>)" | 18:16 | ||
| masak | I'll have to re-check those and compare. | 18:18 | |
| oh, it's definitely action-at-a-distance. so are source filters, though -- and I'd rather use what I'm proposing. | 18:19 | ||
| vendethiel | no question here | ||
| your "my T $a" seems like a really complicated use-case though | 18:34 | ||
| the non-homoiconic syntax bites here | |||
| masak | I was thinking about that one a bit more since I suggested it | 18:52 | |
| in the best case, I'd simply like to be able to install a `rule statement:my-typed`, and it gets to compete in LTM with `rule statement:my`. | 18:54 | ||
| actually, the bothersome detail there -- and something I haven't quite figured out yet how to solve -- is that such a new rule would generate an AST, but what the rest of the compiler needs is a Qtree. | 18:56 | ||
| provisionally, the answer to that is "action methods should generate Qtrees". | |||
| oh, and coincidentally 007 does! neat :) | |||
| vendethiel | the "AST" should really be the QTee | 18:58 | |
| r* | |||
| masak | yeah. | 19:00 | |
| well, the Perl 6 compiler is still allowed to generate something like QAST for later stages. but it shouldn't be user-exposed in the same way. | 19:01 | ||
| vendethiel | right. | ||
| I think the problem with typed-my is far deeper than that, though. | |||
| you need to "install" stuff to handle "=" and all that | |||
| masak | yes, I saw that from looking at the current `my`'s action method | 19:02 | |
| basically, it's really hard to do this without incurring quite a bit of code duplication | |||
| I've sort of come to accept that | |||
| writing it down to the fact that we have no "lore" for how to extend grammars and action classes in this way yet | |||
| hopefully we'll get better at it | |||
| unlike with classes, there seems to be a much bigger temptation in grammars to open them up and mess around "in the middle". | 19:03 | ||
| vendethiel | i'm not happy of where grammars are :) | 19:06 | |
| masak | Perl 6 grammars allow subclassing to extend into new behaviors. but I can't recall ever seeing a successful real example of that. | ||
| vendethiel | they're both too far and too close | ||
| masak | yeah | ||
| vendethiel | example: your generation thingie | ||
| I think the same about MMD | |||
| masak | MMD I really like. | 19:07 | |
| vendethiel | Oh, I sure do as well | ||
| masak | I can see a point where, for the sake of user-induced extensibility, I'd have to let go of the Perl 6 grammar in 007's parser. | ||
| vendethiel | but I strongly think it should be first-class. | ||
| they* | |||
| well no, it. dumb me. it's still MMD i'm talking about | |||
| masak | how would MMD look if it were first-class. | 19:08 | |
| ? | |||
| you could do a dispatch, get an object from that, and then later use the object to actually call the method found? | 19:10 | ||
| vendethiel | something like "match" | 19:11 | |
| I need to code something like "newtype" soon-ish | 19:31 | ||
| I'm afraid of string programming etc taking over. | 19:38 | ||
| and it seems like Perl6 is bound to see that happen | |||
| masak | heaven forbid. | 19:39 | |
| vendethiel | well, that's how it's gonna happen | 19:45 | |
| maybe I should start from another angle? | 19:46 | ||
| a context-sensitive template engine | 19:47 | ||
| where you can not interpolate strings | |||
| a "SafeString"-like thing, where you're sure you can't get XSS'd | |||
| masak | good luck. | 19:48 | |
| vendethiel | it's not really about luckj | 19:50 | |
| -j | |||
| it's about stopping complaining about how things are, and moving them where they could be, I guess | |||
| masak | indeed. | ||
| well, good that, then. :P | 19:51 | ||
| vendethiel | tough choice. | 20:05 | |
| how could I emulate typeclasses in perl6? | |||
| I also don't want people to be scared if I write some kind of "scalaz-perl6", aka "siz" | 20:07 | ||
| masak | please be more specific with "typeclasses". are roles with `...` methods enough? | 20:14 | |
| vendethiel | how do you give an implementation "from outside"? | 20:19 | |
| masak | oh, I see. | 20:20 | |
| vendethiel | Haskell has global instances (which leads to many issues) | ||
| scala has "import" | 20:21 | ||
| masak | only clumsily, I suspect. Adapter pattern and the like. | ||
| vendethiel | we can't specialize a role after it's been defined in a module | ||
| masak | no; roles are immutable after definition. | 20:24 | |
| vendethiel | exactly. sooo. :( | 20:25 | |
| masak | feels almost like subset types in Perl 6 are closer to what you want. | 20:27 | |
| except they are not very static. | |||
| vendethiel | yrzh | 20:29 | |
| yeah* | |||
| i'm pretty aware of what subsets can do :P | |||
| I've thought about it | |||
| masak just hopes he can get 007 into a demo-able state in the next few weeks | 20:32 | ||
| vendethiel checks if his talk has been accepted | 20:36 | ||
| "Status\t \tAccepted" \\o/ | |||
| masak | \\o/ | 20:37 | |
| vendethiel | now to write it... | ||
| I think I sent you my draft already | 20:38 | ||
| masak | I think you did. | ||
|
23:02
Ven joined
|
|||