This Week on perl5-porters (1-7 December 2003)

rafael on 2003-12-07T23:34:00

I like tie could be the summary of this week's summary. But it would be a bit terse, wouldn't it ? Read on for the details.

Tied hashes and scalar context

This was the highest volume topic this week. Rafael pointed out that tied hashes in scalar context always return 0 with perl <= 5.8.2, which is obviously not a good thing ; and with perl 5.9.0 using a hash in scalar context yields a fatal error, which has the benefit of not returning a wrong value, but which is not backwards-compatible and most inconvenient. So he called for action.

    http://groups.google.com/groups?threadm=20031203022335.39c35723.rgarciasuarez%40 free.fr 

Tassilo von Parseval proposed to add a SCALAR() method to tied hashes, to be called when a hash is used in scalar context. When the class the hash is tied to doesn't provide this method, perl could try to make some educated guesses. For example, if the hash is in the middle of an iteration, this means that it isn't empty. Thus perl could return a true value to indicate this. Moreover, if the hash is not iterating, perl could call FIRSTKEY() if it can't find SCALAR(). The base class Tie::StdHash could include a default implementation of SCALAR(). Tassilo provided a patch, which got applied.

Yitzchak Scott-Thoennes spots a minor gotcha though : removing the last element from a hash will leave the iterator set. So, should scalar(%h) reset %h's iterator ? or implement a smarter fall-back strategy ? Tassilo decided to document this fact for now.

    http://groups.google.com/groups?threadm=20031207025958.GA2700%40efn.org 

Extending the tied scalar interface

Tassilo also proposed to add a SUBSTR method to tied scalars. Dave Mitchell remembered the old problem about new optional tie methods, that they don't play well with inheritance and backwards compatibility. Michael Schwern and Elizabeth Mattijsen suggest to wait for Ponie and its underlying Parrot vtables to clean up the mess.

    http://groups.google.com/groups?threadm=20031204100156.GA15074%40ethan 

CLONEing

Stas Bekman is working on a piece of documentation about the CLONE() method; more specifically, on a full-fledged example aimed at CLONE() method authors. While doing so, he remarked a problem with XS functions called from CLONE() methods, on perl 5.8.2 and later : they receive the arguments to threads->new(). This problem is avoided if the XS module defines PERL_NO_GET_CONTEXT.

    http://groups.google.com/groups?threadm=3FCDAC86.8070907%40stason.org 

In Brief

Leon Brocard released the first snapshot of perl 5.005_04-to-be.

    http://groups.google.com/groups?threadm=20031205170609.GA29131%40kanga.astray.co m 

A remark of Nick-Ing Simmons about a compilation issue in Tk led to a discussion of advantages of C inline functions vs CPP macros. Macros won.

    http://groups.google.com/groups?threadm=20031201192441.17478.2%40llama.elixent.c om 

Arjen Bax reports that localtime() doesn't seem to take into account the timezone under Cygwin with perl 5.8.2. (Bug #24582.)

Matthias Ulrichs manages to produce a Bizarre ARRAY copy error with a small program, running under perl 5.8.2 + threads. (Bug #24589.)

Randal L. Schwartz reports a bug in CGI::Carp : it doesn't seem to ever output a header. Lincoln Stein says it's already fixed in his development copy.

    http://groups.google.com/groups?threadm=86u14hzkwo.fsf%40blue.stonehenge.com 

Alberto Manuel Brandão Simões has problems with using DB_File and UTF-8 keys from an UTF-8 source script. Roman Vasicek suggests to use a DBM filter.

    http://groups.google.com/groups?threadm=1070484684.714.1.camel%40holst.di.uminho .pt 

Rafael Garcia-Suarez and Arthur Bergman provided some more comments about how and when CHECK and INIT blocks are run, discussing the possibility of adding a new kind of block, START.

    http://groups.google.com/groups?threadm=p05111b03bbf3754332ec%40[192.168.56.3] 

Tels pre-released Math::BigInt 1.67.

    http://groups.google.com/groups?threadm=200312062016.50484%40bloodgate.com 

Thomas Klausner anounced the release of Module-CPANTS-Generator 0.010, a framework to test all distributions on CPAN for 'kwalitee'.

    http://groups.google.com/groups?threadm=20031205205548.GB1578%40zsi.at 

About this summary

This summary was written by Rafael Garcia-Suarez. Weekly summaries are published on http://use.perl.org/ and posted on a mailing list, which subscription address is perl5-summary-subscribe@perl.org . Corrections and comments are welcome.


Minor correction

ethan on 2003-12-08T08:43:28

Tassilo also proposed to add a SUBSTR method to tied scalars.

Not just a SUBSTR method. My plea was more ambitious. :-) Virtually any Perl builtin that acts on scalars should be tieable. I continued using SUBSTR as an example since it also exemplified how one could deal with lvalueness.

I put this on the stack for ponie since I sensed that the porters didn't embrace this idea too much. %-)

Re:Minor correction

rafael on 2003-12-08T08:49:15

If you feel unemployed, (and since you were so successful as picking up that last TODO item I posted on P5P), I can give you more work if you want :)

Re:Minor correction

ethan on 2003-12-08T09:08:09

Now you're threatening me. ;-)

I made the decision some months ago that I should really be able to understand perl's internals so each of my patches is really just a little piece of my learning process. Good for you that there are still vast parts of the interpreter left that I don't have a clue about. ;-)