Welcome to this week’s Perl 5 Porters summary. Sorry again about the delay; we are “moving house” as those cool Brits like to say, so things are bit disheveled around here. I am going to try a new summary style this week, with a short synopsis followed by a link to the beginning of the thread.
I don’t know which style is going to be more popular/useful, so let me know what your preference is.
Topics covered:
- my() with empty list causes weird error
- IO::Socket::IP in core?
- Capturing All Matches for a Repeating Regex Expression
- KEYWORD_PLUGIN_NOOP for keyword plugins
- List::Util::first() don’t work into when() context
- Allowing named arguments in prototypes
- Storable can’t store VSTRINGs
- overload 1.19 breaks Math::BigInt 1.998
- Pod::Html::anchorify() and htmlify() are not tested
- highly illegal variable names are now accidentally legal
my() with empty list causes weird error
Jesse Luehrs continues onward with many, many RT ticket updates/closures. One surprisingly controversial ticket was the error message perl generates from the construct:
$ perl -le 'my();'
Can't declare stub in "my" at -e line 1, near ");"
Reini Urban felt that this error message is not “weird” and that perl should not treat my(); as a valid construction anyway. Lukas Mai argued that my() should be a valid expression as it has a logical meaning, and felt it made sense because otherwise there’d have to be a special case disallowing it. Ricardo Signes (the current pumpking) wrote that there are a lot of ways to write pointless Perl and maybe the cost to disallow it is greater than the cost to allow it.
IO::Socket::IP in core?
Rik Signes suggested making IO::Socket::INET a shell around IO::Socket::IP experimentally so that the former can be replaced by its modern equivalent. David Golden thought maybe it wasn’t quite ready for primetime due to CPAN testing failures.
Capturing All Matches for a Repeating Regex Expression
David E. Wheeler started a popular thread about how to capture all values of a repeating token in a regex. The first attempt only captured the last value but by embedding some perl inside the regex, achieved what he was aiming for.
There were many good suggestions for improvement in this thread.
KEYWORD_PLUGIN_NOOP for keyword plugins
Lukas Mai started a thread suggesting a way for keyword plugins to indicate that a keyword was recognized but no optree was built. This would help some plugins that want to inject source code at the current parse point.
List::Util::first() don’t work into when() context
A ticket was opened in RT for the following scenario:
#!/usr/bin/env perl
use v5.10;
use List::Util "first";
my @probe = (
# some other stuff removed...
'CPU Temp: +54.0°C (high = +75.0°C, hyst = +70.0°C) sensor = thermal diode',
);
my $item = 'temp1';
given ($item) {
when ('temp1') {
my @temp = @probe;
my $cputemp = first { /^CPU Temp/ } @temp;
$cputemp //= '';
say "[$cputemp]";
}
}
-------------------------8<---------------------------
OUTPUT:
[]
Several suggestions followed; most of them a variation on "don't do that." But the thread took on a life of its own, with respect to how SmartMatch interacts with (or fails to interact with) XS based code in a sane way. There was a new round of calls to deprecate given/when.
This week's quote of the week froms from this exchange between Father Chrysostomos and Ricardo Signes:
* Father Chrysostomos via RT [2012-06-27T11:18:15]
> Or just make given localise $'_, as everybody expects it to.
>
> Or just deprecate given/when outright.
You are on my shoulder, whispering, but are you an angel or a devil?
Most people argued for angel, but there are a few people who like foreach/when constructions who spoke up in favor of keeping when for cases where $_ is localized as most people expect (i.e., not how given does it.)
Read the thread.
Another related thread about smartmatch deprecation.
Allowing named arguments in prototypes
Peter Martini made a new proposal for named arguments in sub prototypes. Nicholas Clark wrote a long reply detailing some other attempts and problems encountered from past efforts. One thing that people seemed to think was worth trying was a way to assign arguments to names directly in the subroutine declaration.
sub frobulate($foo, $bar, $baz) {
# look ma, no my ($foo, $bar, $baz) = @_;
...;
}
Read the thread.
Thread from July 1
Storable can't store VSTRINGs
Jesse Luehrs opened a ticket showing that the eminently useful Storable can't store VSTRING types. Father Chrysostomos suggested Jesse look at the way Data::Dumper implemented VSTRING support.
overload 1.19 breaks Math::BigInt 1.998
There were a lot of bugs relating to overloaded operators on P5P this week, probably prompted by this RT ticket from Martin Becker.
perl -MMath::BigInt -le '$a = 2; $a -= Math::BigInt->new(1); print $a'
This should print 1 but prints -1 under perl-5.17.0 and perl-5.17.1.
Jesse Luehrs thought he'd hacked together a suitable fix, but later found things are quite a bit more complicated than he initially thought. The root problem seems to be in the way overload handles fallback functions. Jesse then opened a number of bugs in the way overload.pm handles fallback incorrectly.
Related threads:
- overload loses caller's context
- use overload fallback=>0; has no effect
- List::Util::sum() does not play nice with overloaded "+"
Pod::Html::anchorify() and htmlify() are not tested
James Keenan reported that Pod::Html doesn't test two crucial functions, anchorify() and htmlify(), so he added some tests for these functions and asked that they be incorporated into the core test suite.
highly illegal variable names are now accidentally legal
Yes, this popular thread continues onward from last week. Brian Fraser discusses a patch he wrote trying to restrict variable names. Whence came this week's runner up quote of the week, from Tom Christiansen:
"Brian Fraser via RT"wrote on Sun, 01 Jul 2012 16:02:46 PDT: > Sure, but Perl hasn't been doing it right by our own definition of > right either. It's a big mess. This, I think, is the take-home message from all this. It is ridiculously difficult to describe the spec for a Perl variable by name. It shouldn't be. Read the thread (from July).
Thread from June (if you want the full background)