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

rafael on 2005-10-24T12:39:00

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
  http://dev.perl.org/perl5/list-summaries/2005/20050909.html 
  This time around
  http://xrl.us/h5ye 
  Musing on warnings
  http://xrl.us/h5yf 

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.

  http://xrl.us/h5yg 

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
  http://xrl.us/h5yh 
  Dave explains exactly what's going on
  http://xrl.us/h5yi 
  Rafael explains from the other end
  http://xrl.us/h5yj 
  Xavier summarises the current state of play
  http://xrl.us/h5yk 

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.

  http://xrl.us/h5ym 

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.

  http://xrl.us/h5yn 
  Initially summarised here
  http://dev.perl.org/perl5/list-summaries/2005/20050915.html 

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
  http://xrl.us/h5yo 
  The trouble with threads
  http://xrl.us/h5yp 
  Hugo's suggestion
  http://xrl.us/h5yq 
  Robin's way forward
  http://xrl.us/h5yr 

What John E. Malmberg did this week

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

  http://xrl.us/h5ys 

and synced exit's behaviour with the documentation

  http://xrl.us/h5yt 

and posted his VMS TODO list

  http://xrl.us/h5yu 

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.

  http://xrl.us/h5yv
  http://xrl.us/h5yw
  http://xrl.us/h5yx
  http://xrl.us/h5yy
  http://xrl.us/h5yz 

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:

  http://xrl.us/h5y2 

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.

  http://xrl.us/h5y3 

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.

  http://xrl.us/h5y4 

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

  http://xrl.us/h5y5 

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

  http://xrl.us/h5y6 

Gisle Aas fixed up pp_sselect

  http://xrl.us/h5y7 

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

  http://xrl.us/h5y8 

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 http://rt.perl.org/rt3/Ticket/Display.html?id=nnnnn

Information concerning patches to maint or blead referenced in this summary (as #nnnnn) may be viewed at http://public.activestate.com/cgi-bin/perlbrowse?patch=nnnnn

Weekly summaries are published on http://use.perl.org/ and posted on a mailing list, (subscription: perl5-summary-subscribe@perl.org ). The archive is at http://dev.perl.org/perl5/list-summaries/ . 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.


Thanks.

lb008d on 2005-10-27T15:53:55

These summaries are always very interesting!