This Week on perl5-porters (7-13 April 2003)

rafael on 2003-04-14T11:25:42

This week : Mac OS X problems, big and small patch proposals, cross-compilation and unknown errors.

use base and import

Casey West proposed a patch to call the import() method of a module referenced through the use base pragma. Graham Barr disagrees, saying that use base should only be used to set up inheritance, and Michael Schwern threatens to call the backward compatibility police.

    http://xrl.us/f4p 

Cross-compilation

Redvers Davies complains that there's too little information about the cross-compilation of perl. Nevertheless, he successfully produced perl packages for the OpenZaurus OS (http://www.openzaurus.org/), including dynamically loaded extensions, and the ability to cross-compile XS modules ! (Perl 5.8.0 has the beginning of a minimal support for cross-compilation. Let's hope it can be improved by this impressive work.)

    http://xrl.us/f4q 

Unknown error

Tels manages to have perl to emit an actual Unknown error. This obscure message is actually produced by perl when it fails to load a module, and fails again to get an error message for this first failure. Enache Adrian provided a fix.

    http://xrl.us/f4r
    http://xrl.us/f4s 

Mac OS X peculiarities

Michael Schwern notices that nobody, the traditional Unix low-privileged user, has user id -2 on Mac OS X (according to /etc/passwd), but the uid_t C type is actually an unsigned integer. Consequently, getpwnam() says that nobody's UID is 4294967294. Looks logical. We've seen weirder things.

This doesn't seem to be related to the fact that you can't run perldoc as root on Mac OS X. That's what Dan Kogai explains after a few tests of changing the UID and EUID on various BSD flavors.

    http://xrl.us/f4t 

Michael also criticizes the choice of the default vendorlib location on OS X. In fact, he doesn't think that vendorlib should be set at all in a hints file. Wilfredo Sánchez asks for more info, and is working on a patch, both for the Darwin and Rhapsody hints files. (By the way, Wilfredo doesn't have a Mac OS X server, so he'll patch blindly unless someone wants to test bleadperl and/or maintperl on Rhapsody.)

    http://xrl.us/f4u 

h2xs and enums

Tassilo von Parseval notices (bug #21887) that h2xs doesn't generate constants from the enumerated types found in C header files. Nicholas Clark explains how to use ExtUtils::Constant to achieve the desired effect.

    http://xrl.us/f4v 

Big Bug Fixes

Pradeep Hodigere proposed a patch to speed up some of the perl built-ins when handling UTF8 data (and he provided also benchmark results). Basically his solution is to add a field sv_length to the internal SV structure, to hold the length, in chars, of the scalar string value. Nobody commented yet.

    http://xrl.us/f4w 

Dave Mitchell sent a patch to allow FETCH to access arrays and hashes which are themselves tied without fear of crashing (a.k.a. nested FETCHes). I personally don't understand fully the solution. Nobody commented yet. No, wait, Arthur Bergman said it was nice ! and asked for benchmarks.

    http://xrl.us/f4x 

Beware the precedence police

Dan Kogai complains that this code :

    print chr(0xE3).chr(0x81).chr(0x82) =~ /^\x{3042}$/ ? 'true' : 'false';

prints true. Then, he ceases to complain when he realizes that the precedence of . is actually lower than the precedence of =~. Tom Horsley comments that APL was the only language that ever got precedence and associativity correct.

    http://xrl.us/f4y 

In brief

Jarkko Hietaniemi reports that Devel::Coverage doesn't work with perl 5.8.0, while it works with perl 5.6.1 (bug #21890). Randy J. Ray says he'll look at it. Stas Bekman suggests that the problem might be similar to one he found on Apache::DB.

Long doubles are now correctly recognized by the Configure script on AIX, thanks to John Allen and Merijn Brand. They also improved the compiler detection mechanism, if I understood correctly.

Pierre Denis reports a parsing bug (#21875) involving a hash key which is a bareword beginning by q, and a pair of braces that can be seen as a block or as a literal hashref. Dave Mitchell sends a fix.

Alberto Simões says that it'd be nice to have a function in Data::Dumper to dump the structures directly to a chosen filehandle. Patches welcome !

Nathan Torkington asks a bunch of I/O layer questions, and gets some answers.

    http://xrl.us/f4z 

About this summary

This summary was brought to you by Rafael Garcia-Suarez. Weekly summaries are available on http://use.perl.org/ and/or via a mailing list, which subscription address is perl5-summary-subscribe@perl.org . Comments, corrections, additions, and suggestions are welcome.


Pradeep Hodigere's patch

jhi on 2003-04-14T11:48:19

I saw that fly by in the p5p archives but did not have the time to comment. See change #18353: basically what he is proposing has already been done, kind of. I did it with MAGIC (instead of adding a new struct member, which is probably unthinkable at this stage of the Perl 5 codebase), and in addition to length I also cache the byte/character position, which is useful for regular expressions or anything that scans through the string. The length part is simple, the position caching code is horrible.