Front page | perl.perl5.porters |
Postings from June 2001
RE: the "it" hack
Thread Previous
|
Thread Next
From:
Richard Soderberg
Date:
June 9, 2001 09:09
Subject:
RE: the "it" hack
Message ID:
NAEKLNAAHLMBPMPNBMLEAEDGDGAA.rs@crystalflame.net
I'm impressed. It's the _ operator ported over to ... weirdness.
Well, congratulations. I wouldn't mind seeing it in the core, I guess.
R.
> -----Original Message-----
> From: RFC850 host name inserted by qmail-smtpd
> [mailto:david@nicol6.umkc.edu]On Behalf Of David L. Nicol
> Sent: Friday, June 08, 2001 9:36 PM
> To: fwp@technofile.org; clpm@lists.eyrie.org; perl5-porters@perl.org;
> Kansas City Perl Mongers
> Subject: the "it" hack
>
>
>
> 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 Previous
|
Thread Next