This Week on p5p 2001/07/09

Notes

This Week on P5P

No 5.8.0 Yet

New Modules

Numbers, numbers, numbers

PerlIO considered evil

Asynchronous Callbacks

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 busy week, seeing just over 400 messages. I say that every week, don’t I?

No 5.8.0 Yet

Jarkko sadly announced that 5.8.0 wasn’t going to happen before the Perl Conference, but 5.7.2 is imminent:

I think it’s time for me to give up the fantasy that 5.8.0 will happen before the Perl Conference. The stars just refuse to align properly, too many loose ends, too many delays, too many annoying mysterious little problems, too little testing of CPAN modules. Luckily, nothing is majorly broken, and I think that I’ve more or less achieved what I set out to do with Perl, so I still hope to be able wrap something up before TPC and call it 5.7.2 (it must happen next week or it will not happen), and soon after the conference put out the Release Candidate 1 for 5.8.0, and then keep cracking the whip till we are happy with what we’ve got.

New Modules

These aren’t really very new, but they may have slipped through the net and you haven’t noticed them yet, and since they’re interesting, you might want to have a look…

I18N::LangTags detects and manipulates RFC3066 language tags; Locale::Maketext is extremely useful for localizing text; Unicode::UCD is a neat interface to the Unicode Character Database; Encode is coming on strong, and can now read IBM ICU character tables; Mark-Jason Dominus’ Memoize module is now part of the core.

Numbers, numbers, numbers

Remember last week’s weird Amdahl UTS bug, where Nicholas Clark was convinced UTS C was doing a decrement statement twice? He found the problem - the decrement statement shouldn’t have been there at all…

This prompted him to find a bug in grok_number; this surprised me a little, because I didn’t know that grok_number even existed. All of the useful, platform-independent code which deals with numeric operations - casting between different sizes, converting binary, hex, and octal numbers, recognising numbers in strings, and so on, has been moved to numeric.c. Take a look at it, there’s a load of handy stuff in there.

Hal Morris, our UTS wizard, also pointed out some unpleasant casting assumptions, which needed a patch:

UV_MAX must NOT be defined as (unsigned long){whatever} for UTS, because then comparisons with double will not work correctly (there is no problem with (unsigned) typecasts, only with (unsigned long))

grok_number again came in handy on QNX, when Norton Allen found that strtoul wasn’t setting errno correctly on overflow. It’s sad when we have to start reimplementing people’s broken C libraries, but this is the price of portability.

PerlIO considered evil

Ilya found a bug in PerlIO, then found another bug while attempting to demonstrate it. The original bug was:

The *actual* problem is that char-by-char input requires DUPLICATE pressing of ENTER key for this key to be seen by Perl. Debugging this problem (via Term::ReadKey test suite) shows the following logic:

pp_getc() calls is_eof() which does getc/ungetc calls getc()

[BTW, I see no logic in this sequence of events.]

The problem is that ungetc() can’t unget “\n” if this \n is the first char in the buffer, and quietly drops “\n” to the floor.

Ilya had a lot of invective set aside for PerlIO, which we need not go into. Needless to say, he did not provide an alternative implementation of a multi-layered standard IO system as a patch. Or indeed any patch at all.

Vadim Konovalov did provide a simple patch to clean something up, but then Andy and Nick both showed that it didn’t help at all, the generated code being the same and some compilers not being able to cope with lvalue casts, which Nick had carefully removed and Vadim’s patch reintroduced. Guess Nick might actually know what he’s doing after all.

Asynchronous Callbacks

David Lloyd asked how do safely do asynchronous callbacks from C to Perl. Bejamin Stuhl suggested hacking the core to introduce some checks during the inter-opcode PERL_ASYNC_CHECK, and suggested that Perl 5.8.x had a public way of registering inter-opcode callbacks. David Lloyd replied that PHP/Zend already had this, and you could even implement a signal checking add-on module without any core hacking. Paul Johnson went one further, and suggested using a pluggable runops routine. Surprisingly, this has actually been implemented but nobody really knows about it; Devel::Cover apparently makes use of it. Of course, the problem is that only one thing can use a custom op loop at a time, so David suggested writing an XS module that allowed other modules to add callbacks. I hope that happens.

Artur Bergman popped up and, predictably, suggested using ithreads.

Various

Rudi Farkas found a weird one on Win32 - on that platform, executableness (the -x test) is determined by the filename being examined. For instance, foo.bat is classed as executable, but foo.bar is not, even if they contain exactly the same data. This rather curious design decision leads to the fact that if you call stat with a filename, the execute bit is set depending on the extension. If, on the other hand, you call fstat with a filehandle, Windows can’t retrieve the filename and test the extension, so it silently sets the execute bit to zero, no matter what it gets fed. This is Bad, and means that -x _ on Windows is unpredictable. Radi provided a suggested workaround, but nobody cared enough about fixing something so obviously braindead to produce a patch.

Mike Schwern fixed up MakeMaker to stop producing extraneous -I...s when building extensions, and also found that the XS version of Cwd won’t do much good as a separate CPAN module, since it relies on the core function sv_getcwd, which only appears in 5.7.1. Oops. Oh, and speaking of Cwd, Ilya patched it up a bit for OS/2, while noting that its results were untainted on that platform.

Ilya also fixed a glaring debugger bug (oh, the irony) prompting Jarkko to lament the lack of a test suite. Robin fixed up a couple of weird, weird bugs in B::Deparse.

Jonathan Stowe upgraded pl2pm to be warnings and strict clean. I’m not sure why.

Philip Newton patched a score of typos. Norton Allen updated the QNX documentation and provided a couple of other fixes.

Piers Cawley found something that looked like a bug in SUPER:: but was assured that it wasn’t; Randal won the day with a reference to Smalltalk.

Abhijit Menon-Sen (look out for this guy…) made mkdir warn if it was given a non-octal literal, since that generally doesn’t do what people want, and after prompting from Gisle, did the same for umask and chmod. Unfortunately, he forgot about constant folding…

Until next week I remain, your humble and obedient servant,


Simon Cozens

Tags

Feedback

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