Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

masak (6289)

  (email not shown publicly)

Been programming Perl since 2001. Found Perl 6 somewhere around 2004, and fell in love. Now developing November (a Perl 6 wiki), Druid (a Perl 6 board game), pls (a Perl 6 project installer), GGE (a regex engine), and Yapsi (a Perl 6 implementation). Heavy user of and irregular committer to Rakudo.

Journal of masak (6289)

Tuesday July 21, 2009
04:46 PM

Why I like having Tene on the team

[ #39329 ]

eiro++ asked me today why in this piece of code in, request() is called on line 4, but request($c) is defined on line 6. (And it's not a multi or anything, so that's not it.)

I promised him I'd check it out, and I just did. In a few minutes, I found this in HTTP::Daemon :

# hack until we can get real CALLER support
my %callerns := Q:PIR {{ $P0 = getinterp
                         %r = $P0['namespace';1] }};

# ...

Whoa! There's a piece of CALLER:: emulation in our copy of HTTP::Daemon. This is noteworthy for two reasons. Firstly, CALLER:: isn't implemented in Rakudo Perl 6 yet, so I thought some of the hard-core Rakudo hackers out there might like this tip. As you see, we're basically descending to PIR land and snatching the sacred information right from the claws of the interpreter. Use the trick wisely, Rakudo hackers.

Secondly, I think this is a good way to show how Tene (the one who added these lines to, and the second remaining crew member of is, for lack of a less blunt way to say it, very handy to have around. He has a unique combination of Rakudo and Parrot knowhow, having delved into the internals of both quite a lot.

<masak> phenny: tell eiro if you look at the beginning and end of you will find that the request($c) is actually deliberate (and the nasty but cool hack used to make it work) Tene++
<phenny> masak: I'll pass that on when eiro is around.
<Tene> masak: what part of it is a nasty hack?
<Tene> (I don't remember)
<masak> Tene: the emulation of CALLER::
<masak> Tene: but it's not very nasty, mostly cool.
<Tene> ah
<masak> Tene: I'm thinking of writing a small blog post about it. someone might like the trick.
<pmichaud> (blog post)++
<masak> it would be called "Why I like having Tene on the team" or something. :)
<Tene> It's not that much of a trick. That's what CALLER:: will end up being eventually.
<Tene> I just don't know enough about rakudo's lexical scoping stuff to know how to do CALLER:: right.
<masak> Tene: if you think using Q:PIR to emulate CALLER:: is not much of a trick, then you're way in deep, man. :)

Oh, and the mysterious parameterless call on line 4? Turns out that code was never reached, and is a remainder from earlier versions of HTTP::Daemon. I just pushed a patch that excises this dead code from the code examples in

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.