Front page | perl.perl5.porters |
Postings from June 2001
the "it" hack
Thread Next
From:
David L. Nicol
Date:
June 8, 2001 23:28
Subject:
the "it" hack
Message ID:
3B21A7AD.D1AA4FE4@kasey.umkc.edu
Hi everyone
Here is my first piece of perl source code hacking. As predicted,
it was trivial, requiring modifications to only nine files in the
5.7.1 source:
opcode.pl
hv.c
pp.c
toke.c
intrpvar.h
mg.c
av.c
keywords.h
embed.pl
The attached patch defines a pointer-to-sv stash where the perl
operations "defined" and "exists" store a copy of whatever they
were determining the definedness or existence of; also a new
operator, C<it> which provides (read-only) access to the stash.
This has two goals.
1: now your perl code can look more like your pseudocode,
in case you ever write things like
exists ${$_}{$_[0]} and return it;
in your design notebooks.
2: improve performance by avoiding redundant data structure
descents. Your mileage may vary. If you don't use the shortcut,
and your programs use exists and defined heavily, there will
be a slight performance hit.
Instructions:
Obtain and untar the 5.7.1 source, and save the patch file that
is attached to this e-mail.
Apply it something like this:
cd perl-5.7.1 && patch -p1 < ../perl-5.7.1_it.patch
Proceed with the compilation as normal.
Example of use:
./perl -le '%r = (aa..bb);print it;print $r{ag}; print it; defined 5;
print it'
should print :
ah
5
Thanks are due:
Brian Warnock selected the discussion from perl6-language to
include in his summary of the perl 6 lists, on June 4.
Michael Schwern reluctantly admitted that he could imagine
using the "it" operator.
Simon Cozens helpfully suggested which files to edit, even though
he does not approve of the concept implemented by the patch.
--
David Nicol 816.235.1187
Signature closed for repaving, please have a nice weekend.
Thread Next
-
the "it" hack
by David L. Nicol