Perl 6 - the future is here, just unevenly distributed

IRC log for #6macros, 2015-03-31

| Channels | #6macros index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
01:48 ilbot3 joined #6macros
01:48 Topic for #6macros is now 6macros: discussing the finer points of Perl 6 macros, Qtrees, and how to stay sane | irclog: irclog.perlgeek.de/6macros/today
08:14 Ven joined #6macros
10:44 Ven joined #6macros
12:35 Ven joined #6macros
15:16 Ven joined #6macros
19:54 vendethiel http://ideone.com/3J0H2y
19:54 vendethiel that's an example of CL-style macros, masak :-)
19:54 vendethiel I mean, late-binding :P
19:57 * masak looks
19:58 vendethiel I'm also thinking about macros for a language
19:59 vendethiel I wanted the language to be simple and moduler, as in:
19:59 vendethiel cat foo | parse | emit-bytecode | vm
19:59 vendethiel cat foo | parse | desugar* | emit-bytecode | vm
19:59 vendethiel but -- how do I add macros to that? I need the vm to run code, and I need the ast2bc to compile macros...
20:06 masak good question.
20:06 masak "Lisp in Small Pieces" has this notion about "internal macros" vs "external macros".
20:06 masak sounds like you're touching upon that notion.
20:07 vendethiel mmh.
20:07 vendethiel perl6 just had to borrow the notion of "BEGIN3
20:07 vendethiel BEGIN* for macros
20:10 masak see #perl6
20:11 vendethiel mmh
20:11 vendethiel you've still solved the "how" problem
20:11 vendethiel now need to get all the ramifications correctly
20:14 masak aye
20:14 vendethiel I'm a bit at loss here.
20:15 masak my example ought to have worked and been a faithful translation of yours.
20:16 vendethiel no
20:16 vendethiel there's no quasi in my code
20:16 vendethiel I'm not *generating* that push. it's run as macro time
20:17 masak if it's run at macro time, how come at runtime the list is empty at the first print?
20:17 vendethiel as I said -- welcome to common lisp macros ;-)
20:17 masak there's something I'm missing here
20:17 vendethiel and "late binding"
20:17 vendethiel it's run as it's parsed
20:17 masak I mean, it seems *better*, but I don't see how it could possibly work
20:17 vendethiel well
20:17 vendethiel it can't have reader macros
20:17 vendethiel if it didn't work like that
20:18 masak I must say it works much more like how people expect Perl 6 macros to work.
20:18 masak I'd very much like to see a consistent model based on this :)
20:18 vendethiel yeaaah
20:19 masak problem is, Perl 6 provides two "phases" inside a macro
20:19 vendethiel another BIG pain point for the "BIG PLANS" i have for perl6 is the other part of that
20:19 masak the compile-time phase, outside the quasi
20:19 masak and the runtime phase, inside the quasi
20:19 vendethiel it's the "constant are BEGIN time"
20:19 vendethiel that makes me incredibly sad :(
20:19 masak huh
20:19 vendethiel I can't do any compile-time metaprogramming
20:19 vendethiel because
20:19 vendethiel role A[::T] { constant NEXT = X[T]; } will fail
20:20 vendethiel because "T" is Mu at the time the constant is parsed
20:20 masak bring it up with TimToady
20:20 vendethiel well, it can't work differently, can it?
20:20 vendethiel constants have to be BEGIN-time
20:20 vendethiel but I want them role-parameterization-time
20:20 masak so maybe we need a `let` or similar for runtime constants.
20:20 vendethiel but I don't want quite "runtime" constants :P
20:21 masak *nod*
20:21 vendethiel i still want something that runs at compile-time
20:21 masak you know what you could do?
20:21 vendethiel no?
20:21 vendethiel paste that in #perl6?
20:21 vendethiel :P
20:21 masak you could declare it as a second parameter in the role, with a default
20:21 masak then it would evaluate at the right time
20:21 masak maybe not ideal
20:21 masak but it works today
20:21 vendethiel care to give me an example?
20:22 masak role A[::T, $NEXT = X[T]] {}
20:22 vendethiel aaah.
20:22 masak :)
20:22 vendethiel that's actually an interesting idea.
20:22 vendethiel not quite "pretty", tho, but...
20:22 masak it works.
20:24 vendethiel .oO( I'll just write a macro to do that )
20:25 masak :P
20:26 masak yep, that should probably be possible once I'm done...
20:26 vendethiel so, there's something in progress? :-)
20:26 vendethiel did you get the CL macro system, or do you want me to add a bit on that?
20:27 masak "it's lazy and magical, and ponies"
20:27 masak is what I got
20:27 vendethiel haha
20:28 masak sorry for being a bit brusque. still doing $work stuff :)
20:28 vendethiel (defmacro mac (arg) (print arg) `(print arg))
20:28 vendethiel then
20:28 vendethiel (mac 5)
20:28 vendethiel it'll first evaluate the macro
20:28 vendethiel printing arg first
20:28 vendethiel then substitute the AST
20:28 vendethiel then evaluate that
20:29 masak so, in some sense, the `(mac 5)` remains in the code until runtime?
20:29 vendethiel yeah
20:29 vendethiel there's only runtime
20:29 vendethiel there's nothing else
20:29 vendethiel just like I said before
20:29 masak *nod*
20:30 vendethiel if everything wasn't runtime, lexer macros wouldn't be possible
20:30 masak I... see.
20:30 masak well, Perl 6 *does* have two phases.
20:30 masak they can even be separated to different physical machines, etc.
20:30 vendethiel ;-)
20:30 masak and macros most certainly run in the first phase. that won't change.
20:30 vendethiel definitely :)
20:32 masak do you think that, given the two-phase thing, the type of macros you describe would still be possible?
20:33 vendethiel the type of macros?
20:33 vendethiel with the print before and after the macro use?
20:33 vendethiel no
20:33 vendethiel lexer macros? probably :P
20:33 vendethiel only because we define our lexer modifications declaratively
20:33 vendethiel whereas cl runs code
20:34 * masak needs to learn more about lexer macros, then
20:34 vendethiel changing the reader as-you-go
20:37 masak would you say Perl 6 has a reader?
20:37 vendethiel I'd say every language has a "reader", in the form of a lexer
20:37 vendethiel in c, I can "augment" the reader by declaring types
20:37 masak of all the languages I know, Perl 6 has a lexer the least... :)
20:37 vendethiel in c++, I can "change" the reader by declaring templates
20:38 vendethiel s/change/augment/ # copy pasta fail :-)
20:38 masak I see your point, though
20:38 vendethiel and in perl6, I just have more control
20:38 vendethiel (though I have even more in lisp..obviously :P)
20:39 masak obviously
20:46 masak vendethiel: did you see http://irclog.perlgeek.de/6macros/2015-03-29#i_10359341 ?
20:46 vendethiel definitely didn't
20:46 * vendethiel didn't backlog properly
20:48 vendethiel I'm not sure you can make your AST types so good
20:48 vendethiel that it's impossible to build an invalid ast :-)
20:50 masak I want to allow building an invalid AST
20:50 masak that's why the hardening mechanism is necessary
20:51 masak and some things that are disallowed in parsing probably should be allowed in hardening
20:51 vendethiel referring-using-strings needs to be banned, but it was never a question in my eyes
20:51 vendethiel "symbols" were always gonna be necessary
20:51 masak oh, ok
20:51 masak good to know
20:51 masak thanks for that bit of feedback alone
20:51 masak that basically answers it for me
20:52 vendethiel I agree that I don't see a solution with strings :) it can't be made sane!
20:52 vendethiel elixir, which has strings and "symbols", uses another "data type"
20:52 masak everybody else seems to try to do it with strings, in my experience
20:52 vendethiel because no other solution around?
20:55 masak sure, it's a local minimum, if that's what you mean
20:55 masak it's just not I particularly strive for in Perl 6
20:55 masak we can do better
20:58 vendethiel I agree,I agree:)
21:00 vendethiel also
21:01 vendethiel strings aren't really viable with our compile-time lexical variables errors :)
21:06 masak right.
22:19 vendethiel joined #6macros

| Channels | #6macros index | Today | | Search | Google Search | Plain-Text | summary