develooper Front page | perl.perl5.porters | Postings from February 2008

Re: Interesting self contained task

Thread Previous | Thread Next
Nicholas Clark
February 20, 2008 01:38
Re: Interesting self contained task
Message ID:
On Mon, Feb 11, 2008 at 08:05:47PM +0000, Nicholas Clark wrote:
> On Mon, Feb 11, 2008 at 08:37:03PM +0100, Philippe Bruhat (BooK) wrote:
> > Since I bought the priviledge in YAPC Europe in Vienna, you are supposed
> > to be my bitch (i.e. train me in the arcanes of the Perl internals).
> > 
> > So maybe this is the perfect time for me to yank your chain?
> Not *right* now, because I'm setting off to Erlangen tomorrow for the German
> Perl Workshop*, and could well be pretty much offline until the following
> Thursday.
> (Also someone on IRC who might not want to be named here yet might beat you
> to it)

Um, oops. I found a rather simpler way to do it:

==== //depot/perl/ (xtext) ====

@@ -760,7 +760,7 @@
 # String stuff.
-length		length			ck_lengthconst	isTu%	S?
+length		length			ck_lengthconst	ifsTu%	S?
 substr		substr			ck_substr	st@	S S S? S?
 vec		vec			ck_fun		ist@	S S S

This has this side effect:

$  ./perl -e 'bless \length "Pie"'
Modification of a read-only value attempted at -e line 1.

It used to work.

$ perl -e 'bless \length "Pie"'

I'm not sure if this is a great loss, but, it turns out, adding 'f' to substr,
index and rindex causes a test failure due to this part of bless.t:

$g1 = bless \substr("test", 1, 2), "G";
expected($g1, "G", "LVALUE");

Whilst we could change that test, it makes me wonder why we shouldn't have
bless constant folded, *if* the constant it will be blessing has a reference
count of 1. With that change, all existing code, albeit strange code, would
still work.

(This must still fail:

$ perl -le 'bless \undef'
Modification of a read-only value attempted at -e line 1.


Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About