This Week on p5p 2001/07/02

Notes

This week on P5P

Notes
Module Versioning and Testing
Carpentry
Regex Capture-to-variable
Perl on S390
UTS Amdahl
Various

Please send corrections and additions to perl-thisweek-YYYYMM@simon-cozens.org where YYYYMM is the current year and month. Changes and additions to the perl5-porters biographies are particularly welcome.

This was a reasonably normal week, seeing the usual 500 or so messages.

Many thanks again to Leon for last week’s summary.

Module Versioning and Testing

There’s a move on to make the modules under ext/ free-standing: that is, to be able to say

cd ext/File/Glob

make dist

and get a bundle that can be uploaded to CPAN or otherwise distributed. The only problem with this is tests. Currently the tests are kept under t/ of the main root of the Perl source tree, and are run when a make test is done there. To make the modules freestanding, you’d have to move the tests to ext/Foo/Bar/t/ and have the main make test also traverse the extension subdirectories and run the tests there. But then, of course, there’s another problem. Can you spot it?

make test is run from an uninstalled Perl, which needs explicit hints about where to find the Perl library. Hence, the tests in t/ directly wibble @INC. This wouldn’t work if we’re making the modules freestanding, or if we move the tests to ext/Foo/Bar/t/. So the trick, which nobody’s done yet, is to move the tests to the right place, change the main make test to recurse extension subdirectories, but also to propagate an environment variable telling the module where to find the library. ( PERL5LIB is what you want for this.) That would be a nice little task for someone…

Speaking of testing, Schwern got Test::Simple and Test::More added to the core, bringing the first All Your Base reference into the Perl source tree. Oh, and how many different testing mechanisms?

Robin Houston incremented B::Deparse’s version number and added some change notes. Here’s what’s improved since 5.6.1:

    Changes between 0.60 and 0.61 (mostly by Robin Houston) 
    - many bug-fixes 
    - support for pragmas and 'use' 
    - support for the little-used $[ variable 
    - support for __DATA__ sections 
    - UTF8 support 
    - BEGIN, CHECK, INIT and END blocks 
    - scoping of subroutine declarations fixed 
    - compile-time output from the input program can be suppressed, so that the 
      output is just the deparsed code. (a change to O.pm in fact) 
    - our() declarations 
    - *all* the known bugs are now listed in the BUGS section 
    - comprehensive test mechanism (TEST -deparse)

The new test mechanism is great: it runs the standard Perl test suite through B::Deparse and then back through Perl again to ensure the deparsed code still passes the tests. And, as a testament to the work that’s been done on B::Deparse, they mostly do pass.

Schwern also bumped up ExtUtils::Manifest, which caused Jarkko to appeal for a script which checks two Perl source trees to find updated versions of modules without a version change. Larry Shatzer provided one, and Jarkko used it to update the versions in the current tree. Schwern also put Cwd on CPAN, and found a weird dynamic loading bug with the XS version of Cwd. Oh, and noted that after his benchmarking, there’s no significant performance loss between 5.6.1 without PerlIO and bleadperl with it.

Carpentry

Mike Guy partially fixed a problem whereby when a magic variable like $1 is passed as a subroutine parameter, carp and the debugger don’t see it properly. Tony Bowden took the opportunity to ask for either more or less documentation for longmess and shortmess depending on whether or not they were meant to be internal to Carp. Tony wrote a documentation patch himself.

Schwern asked for a better name for those functions, perhaps more in line with the carp/croak/cluck theme. Jarkko suggested yodel and yelp which Schwern implemented.

Andreas had a quick bitch about Schwern’s, uh, idiosyncratic naming style:

Your style of naming things is just plain sick:

AnyLoader does anything but interface to any loader. Ima::DBI has something to do with DBI, but nothing with Ima. D::oh is the only really funny one. But it’s from 1999 and getting old. Sex: I still don’t know if it is fun or what. Bone::Easy? Same here. Semi::Semicolon? Same here.

And now yodle!

Unfair, though, since yodel and yelp weren’t his…

However, Hugo objected to yodel/ yelp because the other verbs write to standard error, hence “speaking” whereas longmess and shortmess don’t actually “say” anything. Jarkko agreed, and there the matter rested. (Modulo Rich Lafferty’s suggestion of “flame” for objections in a written medium…)

Regex Capture-to-variable

Jeffrey Friedl (he of the Regexp book) came up with an interesting patch which adds the new special variable $^N for the most-recently assigned bracket match. This is different from $+ which is the highest numbered match; that’s to say, given

    /(foo(bar))/

then $+ is equivalent to $2, whereas $^N is equivalent to the bracket match for the last closing bracket; that is, $1. This essentially allows you to do capture-to-variable, like this:

    (?:(\d+)(?{ $phone_number = $^N }))

without having to worry about which number bracket the match was. (Especially useful if you have to change your regexp around.) Whether this makes regular expressions cleaner or dirtier, I’ll leave up to you… However, Jeffrey also noted that you can use regexp overloading (my, that’s an obscure feature - look at re.pm) to make such syntax as

    (?<$phone_number>\d+)

work. Now that’s cool.

Phillip Newton added a nmenomic: $^N is the most recently closed Nested parenthesis.

Perl on S390

Hal Morris got Perl going on Linux/390, with only one test failing. Good news for the new generation of mainframe hackers.

There’s mixed news for the old-timers, though; Peter Prymmer has got it down to 10 test failures, but one of the tests completely hangs Perl. Apparently study under OS/390 is best avoided. He also started some investigation of a Bigint bug, under the direction of Tels and John Peacock, but left for his holidays and the discussion moved to the perl-mvs mailing list.

UTS Amdahl

Oh, and talking of weird platforms, UTS. Hal (who’s actually from UTS Global, so much kudos there) has been testing out recent Perl builds on UTS, and turning up some … take a deep breath … icky numeric conversion issues.

Nicholas Clark was convinced they (well, some of them at least) were due to UTS C going through a foo-- statement twice, but Hal pointed out he didn’t expect UTS C to be quite that braindead. On the other hand, Nick’s analysis looked convincing…

Hal also fixed up hints/uts.sh so that UTS now configures and builds nicely at least.

Various

David Wheeler found a known but really, really weird bug with lexical arrays; if you do:

    my @a = foo(); my @b = foo();
    sub foo { $x = 0; my @ary; push @ary, "hi" if $x; push @ary, "ho"; return @ary }

@a gets “ho” as you’d expect, but @b gets “ho”,“ho”. Ronald Kimball told him Not To Do That, Then.

Peter Prymmer noted that Perl on VMS was bailing out during the test suite, leading to lots of bogus failures. This only happens if none of the DBM libraries (GDBM, DB_File, NDBM or SDBM) were built. As the first three require external libraries that VMS doesn’t have and the last one is currently broken, it’s no wonder Perl is bailing out. The fix is to work out why SDBM has stopped building on VMS. Peter also produced a lot of other VMS and HPUX reports.

Andy was pleasantly surprised to note that the promised “binary compatibility with 5.005” actually works even in bleadperl. Perhaps we need to break more things.

John Peacock asked a portability question for XS bit-twiddling; he’s trying to adapt a math library which depends on casting two numbers to a long and adding them together to avoid overflow. Jarkko’s fantastic architecture experience was brought to bear as he revealed that Cray Unicos has long == short == int == double. Oh, and type casting has issues too, so you have to use a union. Nicholas Clark suggested the old trick of comparing the operands of an addition with the result; if the result is smaller than either of the operands, you’ve overflowed, so you add a carry and off you go.

The news that GCC 3.0 was out brought a rush of people testing Perl out with it; I got it through on Linux with all tests successful, as did H. Merijn Brand on HPUX, but with rather a lot more warnings. This was because HPUX messed up the test for __attribute__ due to using a HP linker instead of a GNU one. Merijn and Jarkko got this fixed up.

Artur continued his iThreads quest; he renamed the “shared” attribute to “static”, (and then again to “unique” after objections) presumably to free it up for an attribute which actually does share variables between interpreters, and also added a function which cloned the Perl host. He said that threads-0.01, the new threading module, will be released to CPAN when 5.7.2 hits the road. (Which Jarkko keeps hinting will be very, very, very soon now.) He also complained bitterly when Marcel Grunauer tried to document attributes.pm as useful, despite the fact that Marcel has some really very cool modules on CPAN based on it…

Marcel also found, and Radu Greab fixed, an insiduous bug in split, whereby if the default whitespace pattern was used for one iteration of a loop, it would be used for all succeeding ones; the PMf_WHITE flag for the regular expression was being set but never unset. Urgh.

Ilya produced some rough changes documentation for OS/2, as well as some other little patches. Norton Allen provided some QNX updates.

Phillip Newton documented the neat

    $count = () = function()

idiom for counting the number of return values from an operation. That was something I hadn’t seen before; you learn something new every day… Until next week I remain, your humble and obedient servant,


**

Tags

Feedback

Something wrong with this article? Help us out by opening an issue or pull request on GitHub