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 9 April 2015.
06:56 Ven joined 08:26 Ven joined 12:13 Ven joined 13:15 Ven joined
Ven I actually have an "use case" for macros to post here 13:28
It can actually be seen as pretty broad 13:29
but basically, it's the idea of being able to do what C++er do with their templates
most of what they do, we have bundled in the languages
masak I don't understand. 13:30
do you have a concrete example?
13:32 Ven_ joined
Ven_ okay, so, my internet crashed. but thanks lord for ilbot3 ;0 13:32
s/0/)/
I'll guess you can't read c++ template craziness? 13:33
(or you really don't want to -- and that I'd understand)
masak somewhere inbetween those. 13:34
the more you can phrase the use case as Perl 6 syntax, the better :)
Ven_ but it's very interesting to see what they've done with their templates. 13:35
say, enable_if, thanks to SFINAE (template substitution failure isn't an error)
it's not even SFINAE
it's just ... what they do in template parameter lists
they basically define several template "overloads", each with a different enable_if, and if one enable_if fails, it goes on to the next overload candidate 13:36
or just plainly fails
something like
role[::T where is_integral(T)] { constant HAS = true; } role[::T where is_boolean(T)] { constant HAS = true; }; # no other overload = will fail if not integral nor boolean 13:38
Okay, so, they're ready to go to insanely great lengths with that 13:40
basically, Boost is *the* crazy c++ template library
they had reimplemented *LAMBDAS* using templates 13:41
they even invented operator sections (boost.phoenix)
and they have a compile-time parsing algorithm that's faster than most handrolled parsers (boost.spirit) 13:42
and so 13:54
(I'll just carry on :P)
they built these incredible algorithms
some of those are just made to compile your programs slower (like those I mentioned)
even if, at times, they really can bring lots of runtime speed goodness
masak backlogs 13:55
Ven_ but what interests me is *correctness* 13:56
I have a very good example in mind, that was reminded to me by some #perl6 chat just now
github.com/rbock/sqlpp11 13:57
masak :)
Ven_ this is what it allows you to do:
masak looks
Ven_ for (const auto& row : db(select(foo.name, foo.hasFun).from(foo).where(foo.id > 17 and foo.name.like("%bar%"))))
this is all statically checked.
masak cool.
yes, I want us to have things like that.
Ven_ yeah. imagine that
masak that seems to me to be a very, hm, Smalltalk sensibility
Ven_ they built this only with templates. and template templates
and variadic templates
and a good amount of madness =)
masak "it's just an AST. the interpreter decides what to do with it"
Ven_ not even an ast in this case 13:59
hahaha
they have mpl.monad, which is basically a small, pure interpreter
using templates
because, well, templates can't have side effects (or even variables!)
masak those C++ people :) 14:01
impressive in a deeply scary way 14:02
Ven_ right?
they never stop to know if they should
they just do it
please do look at the sqlpp11 page, tho :)
and remember, there's nothing like method_missing in c++ :P
masak right, it's all compile-time 14:03
Ven_ BUT in boost.phoenix, you have "things" like "arg1" where you can "lazily-apply" operations
say
filter(range, arg1 % 5 == 0);
this works with boost::phoenix::arg1.
masak huh. 14:04
Ven_ right? 14:08
this is how crazy they are 14:09
I want that *power*
but saner. far saner.
basically
I want the ring, without the eye nor the mordor
masak who doesn't
Ven_ ;-) 14:10
sane people?
masak this "sane" thing you talk about... it sounds boring :P
Ven_ i know, right? 14:11
I started learning c++ with c++11
i have no idea how "normal" c++ code looks like.
I only know the crazy c++ templates part
(some would argue that "the rest" is C and I (mostly) know the sane part of C 14:12
that is, the part without the ASM bits, the overflow behavior and all that, and some other dark and crazy corners)
masak I think us having total AST read/write access will take us fairly far in this direction. 14:15
my main job is to make sure the API for it all is sane and nice to use.
and that we don't step on any huge hygiene mines on the way. 14:16
Ven_ right :) 14:18
I really think scala macros are the closest to ours 14:20
but I'll stop throwing names around
doesn't give you anything
masak I've emailed a bit with the scala macros guy 14:21
we were both a bit confused about differences in runtime model and terminology 14:22
but aside from that, we had a fruitful conversation
Ven_ oh?
I'd love that to be posted somewhere :D 14:23
masak heh. 14:24
not right now, but I'll see what I can do
Ven_ amazing! 14:26
must be very interesting conversations
masak don't get your hopes up too much 14:27
Ven_ I'm not ;-) 14:28
15:48 Ven joined 20:53 vendethiel joined
vendethiel friendly reminds masak about said email exchanges 21:03
but then, it's 11pm, I'm finally home after 14 days of school with crazy times, so I might get some rest first 21:04
masak :) 21:06
vendethiel that, or the last part when 4 people tried to destroy our project that really made me tired at once 21:08
"why don't you try nodejs" "ruby sucks" "freenode has as much people talking as twitch" "lol, rails can't scale, even twitter swapped it out" and so on so forth
masak vendethiel: gist.github.com/masak/b269ed2bb30e43ca80a7 21:12
tried to clean it up a little as I pasted it
vendethiel the quasi/hygiene question is interesting
masak keep in mind that this whole correspondence is from three years ago
vendethiel oh :P 21:13
i'm always late to parties...
masak with all that means for later insights and stuff
vendethiel cool beans, als 21:15
this guy is a crazy macro guy :P
masak yeah, I love how he took the time to understand Perl 6's model 21:17
vendethiel right? I expected disdain for perl, gotta admit
masak some people are suitably open-minded
vendethiel
.oO( I'd love to be one of these )
21:18
masak :P 21:19
vendethiel or those. probably those. 21:21
it's funny, the distinction between "this"/"that" and "these"/"those" only became apparent to me when I started learning spanish
(spanish actually has a 3rd variant, tho...)
masak wicked 21:22
vendethiel
.oO( This Guy Learns Something... You Won't Believe What Happens Next! )
21:23
masak :) 21:26
vendethiel masak: did you read that paper, btw?
I feel bad everytime I'm throwing stuff at you
masak "that paper"? could you be more specific? don't feel bad.
I need to read papers.
I'm not uninterested, just busy-ish. 21:27
vendethiel I know that feeling, but I know I'm slacking as well
masak today I've been slacking by blogging about heredocs :)
feeling pretty good about that
vendethiel I read it! 21:28
found it on r/perl, actually, totally randomly
masak I'm kinda veering towards spending 30 minutes on 007's custom-ops branch before going to bed
vendethiel the paper in the gist you linked me, in the exchange with eugene
also -- I feel bad because it doesn't make sense to give you 34252534 links you can't possibly read 21:29
masak I *think* I read that paper
but I should probably read it again, because I'm probably dumb in a completely different way than I was three years ago 21:30
vendethiel my problem as well!
I think I mentioned it already 21:32
I don't know what side effects should be allowed inside macros 21:33
probably mutation
masak mutation, of the program AST?
vendethiel that one's one of our banes :P haha 21:34
no, rather
cross-macros "global variables" mutation.
masak I see no problem there.
that's already possible, and will remain so.
vendethiel one use case I found myself having
while writing my ADT.ex macro
masak this is Perl, after all.
we can't predict the beneficial ways you choose to shoot yourself in the foot... so we allow most of them. 21:35
vendethiel is that I couldn't provide exhaustiveness checking
(since it uses SSA)
I really want exhaustiveness checking.
masak that deduction wasn't clear to me (SSA => can't exhaustiveness check)
vendethiel SSA => can't mutate variables => can't store the different alternatives for one ADT 21:36
=> can't provide a macro that will over exhaustiveness checking
masak oh, ok 21:37
vendethiel offer*
my brane is really tired, sorry
masak get thee to bed, vendethiel ;)
vendethiel maybe I should 21:38
I wanted to play some starcraft to feel the weekend, but at that point I probably won't be able to see my units, hah 21:39
masak :)
starcraft will be there for you tomorrow 21:40
vendethiel oh, sure, everything will, probably
I'll probably just go and read some more of my perl5 book 21:43
masak :) 21:48