On Mon, 2005-03-07 at 12:56, Ben Tilly wrote:
> On Mon, 07 Mar 2005 08:36:56 -0500, Aaron Sherman <[EMAIL PROTECTED]> wrote:
> > On Mon, 2005-03-07 at 01:51 -0500, James Freeman wrote:
> >
> > [...] If you know more trivia
> > than I do (I've yet to see that), then I would hire you on the spot.
>
> Let's turn this into, "Let's try to stump Aaron!"
Heehee! I mis-spoke. I meant "I've yet to see that in an interview." I
have seen plenty of people on this list or the various p6x lists that
make me look like a newbie. I was in no way trying to claim to be the
ultimate Perl trivia expert.
> Here are a few tries from me:
>
> 1. What is the output of the following, and why?
>
> package Foo;
> our $_;
> print grep {$_} -5..5;
Well, assuming you don't want me to test that on the command-line, I'm
not sure that the answer is the same across all of the commonly used
versions today. In 5.6.1... I'm guessing an error about using our on $_.
In 5.10 (upcoming), I know "our $_" is supposed to be a "go back to the
global $_, not my lexical version", but we don't have lexical $_ in
5.8.x yet, so I'm not sure what it would do there. Quite possibly, it
would be ignored, in which case you would get -5 through 5 being printed
without 0, of course.
This seems like less of a "Perl trivia" question and more of a "state of
Perl development" question. Not invalid, just pointing that out.
Ok, having written the above, I went and checked it out. It prints
nothing under all versions I have access to. Wish I had time to figure
out why. I'm sure it has to do with the interaction of our and closures,
but I have no clue.
> 2. Explain what's special about "0 but true" and why
> that's never actually needed.
Erg... "0 but true" is true by virtue of not being one of the special
cases that are considered false (e.g. "0")... and why is it never
needed? I thought it was, so I'm guessing that a recent version added
some sort of replacement? You can, of course, use "0.00" or construct an
SV that has numeric value 0 and string value "false".
Am I missing something?
> 3. Why don't you get a warning from:
>
> perl -we '"ignore useless use of a constant"'
It's not in a void context, so it's being used. I'm not too familiar
with the warning you're expecting, as I don't usually run into it, but,
as the last statement in a block, this value is used... Perl would have
a hard time telling that the value of the block isn't used....
> 4. As Larry points out in perlsyn, he has never felt the need
> to use goto LABEL in Perl. (With good reason, as was first
> proven in the 70's, any algorithm that can be written with
> goto can be written, with the same efficiency, with named
> loop control.) Why, then, did he include the feature?
Goto is commonly used in generated code which would be much more
difficult to generate using named loop controls (e.g.
Parse::RecDescent).
However, as someone who has contributed code to the core which is still
in use, and which uses goto in this way (grep goto in File/Copy.pm), I
can say that there are times when you really want goto, because the
alternative is ugly as sin or slow or loses information or a combination
of the above.
Named loop controls + efficient exception handling solves for all of the
above, and Perl 6 will no longer need that goto in File::Copy for that
very reason (though File::Copy probably won't be written in Perl 6, but
in PIR or C).
> 5. Who made the syntax $somesub->() work, and why?
Oh now that's just social trivia. I have no idea who made what patches
to the core and why. I have to much to do. Speaking of which ... have a
nice day!
--
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm