This Week on perl5-porters - 17-23 October 2005

This Week on perl5-porters - 17-23 October 2005

Perl 5 was released this week, eleven years ago.

Defining sub _ {...} breaks File::Find

Jeff "japhy" Pinyan mentioned the Issue That Will Not Die, that if you define sub _ {...}, then _ as a shorthand for the file most recently statted stops working. The problem at hand for japhy being that File::Find fails, and wondered what workarounds were possible.

Mark Jason Dominus was against the idea of teaching File::Find to work around such damage, because it would probably not be the only module that breaks under this scenario. The best fix would be to adjust the parser to prefer string context for _ where it makes sense (and thus not call sub _). And Rafael Garcia-Suarez did just that with a quick patch to put more DWIMery into the tokeniser in change #25799.

It turns out that _ is the usual idiom in the gettext world for dealing with internationalisation (i18n). Yitzchak Scott-Thoennes thought that a new warning should be generated for attempting to define sub _. Abigail thought not. The thread then evolved into a discussion about how and when new warning can, or should, be added to the interpreter.

  Earlier thread, summarised here

  This time around

  Musing on warnings

Loading multiple versions of modules

Nicholas Clark wants to know how much tweaking to the internals would be required in order to let perl load different versions of the same module. Something as mundane as package Alpha using version 1.0 of module Charlie, and package Bravo using version 2.0 of module Charlie would come in quite handy. Without getting into the brain-melting complexity of an @array containing heterogeneously versioned Charlie objects...

The idea sounds quite exciting, sadly, after a few responses the thread flickered out.

Sub return values are inaccurately documented

The monster thread of the week, with 44 replies. It starts with a sentence from perlsub, noted by Xavier Noria: "The return value of a subroutine is the value of the last expression evaluated by that sub". Pop quiz: what does the following return?

  C<sub f { 1 for 1 }>

Answer: ''. Adriano Ferreira supplied a number of variations on the theme, with if or while in the place of for, and Abigail pointed out that do {...} has the same sorts of problems, so it's not only apparent in subroutines. The problem is that for is a control structure. And the value of a control structure is unspecified. In fact, it doesn't have one.

Yves Orton noticed that my @b=(0,1); print $b[0+do {1 for 1}] dumps core. He also wanted to specify the last expression produced by a control structure. Xavier pointed out that control structure are not expressions. And Rafael concurred, saying that you can't say my $x = while (...) { ... }. Yves countered with my $x = do {while (...) { ... }}. Rafael put his foot down and said that loops are evaluated in void context. To change them now to be evaluated in scalar or list context (which is what Yves wanted) would break lots of code.

But the core dump problem remained unresolved.

  The beginning

  Dave explains exactly what's going on

  Rafael explains from the other end

  Xavier summarises the current state of play

do { EXPR for EXPR }

Robin Houston picked up the core dump noticed by Yves in the above thread and analysed it. And patched the source to fix it.

List slice subscripting

Nicholas Clark said that he didn't want to see the new slicing syntax appearing in maint, and related a horror story of battling with syntax variants in 5.004, when only 5.004_05 compiles easily on modern platforms due to compiler evolution (specifically, Configure-back-then gets confused by what compiler-right-here-right-now says in response to its probes).

If you like this syntax, wait for 5.10. If you can't wait, try and help to make 5.10 get here faster.

  Initially summarised here

Recursive comparison routine can cause segfault in sort

Robin Houston found that using a sort comparison routine that calls itself can cause perl to dump core. Dave Mitchell confirmed that the situation is deeply unsatisfactory. Even if the code base was patched to die gracefully when a recursive sort comparison was found, there are problems with threads that remain in any event. Hugo van der Sanden suggested an approach using attributes. Robin and Dave started to debate a way forward.

  The bug report

  The trouble with threads

  Hugo's suggestion

  Robin's way forward

What John E. Malmberg did this week

John E. Malmberg got open(FOO, " foo|") working on VMS, applied by Craig Berry,

and synced exit's behaviour with the documentation

and posted his VMS TODO list

There's a lot there. And it probably may not be complete.

What Jarkko Hietaniemi did this week

Jarkko Hietaniemi posted many patches to bring Perl on Symbian up to speed.

In brief

I have the Perl5 bug summary in my spool, but for some reason I cannot find the message on xray. There were 1507 open tickets as of 2005-10-17.

Nicholas Clark thinks he shook out a reference counting bug with a ponie build:

Ilya Zakharevich cc'ed p5p about a bug in if and appended a patch. Some doubts were expressed about the error message (not everyone may catch the cultural context of "cryptocontext"). Others noted tangentially that testing for Windows platforms with if ( $^O =~ /Win/i ) will come to grief on cygwin and Darwin.

Andy Lester, continuing on his quest to conts, hoisted some repeated code out in av.c and thus shaved a few bytes of the resulting object code.

Following on from the discussion of manipulating the environment last week, H.Merijn Brand added a configure probe for clearenv.

Sébastien Aperghis-Tramoni wrote patch #25802 for so that it generates the index entries for perlapi.pod and perlintern.pod.

Gisle Aas fixed up pp_sselect

Nicholas upgraded ExtUtils::MakeMaker to 6.30 in maint. And wanted to know what (is)? broke(n)?.

About this summary

This summary was written by David Landgren, for once without Immediate Realtime Corrections (IRC), so any typos or wordos are truly my own. I'm offline as of tomorrow morning for a week. Yay!

Information concerning bugs referenced in this summary (as #nnnnn) may be viewed at

Information concerning patches to maint or blead referenced in this summary (as #nnnnn) may be viewed at

Weekly summaries are published on and posted on a mailing list, (subscription: The archive is at Corrections and comments are welcome.

If you found this summary useful or enjoyable, please consider contributing to the Perl Foundation to help support the development of Perl.