develooper Front page | perl.perl5.porters | Postings from January 2012

Re: pack and ASCII

Thread Previous | Thread Next
Father Chrysostomos
January 15, 2012 14:08
Re: pack and ASCII
Message ID:
> So, what does it mean someone is asking for, when he or she writes:
>   my $string = qq[Queensr\N{LATIN SMALL LETTER Y WITH DIAERESIS}che];
>   my $packed = pack "A*", $string;
> All the other confusion of this thread aside, I *think* that we all agree that
> the person writing this is making a mistake.  Is that true?  Do we all agree
> that this should be (or would not be incorrect to be) a warning?
> My hunch is that we will want a warning and an improvement to the
> documentation.

I think adding a warning would be a bad idea.

As Eric Brine has pointed out, there are legitimate uses for that.  And in those cases where it would warn, it already warns, because the wide characters returned from pack will be fed through a byte-sized handle.

So, for existing cases (such as the code that brought this up to begin with), there will be two warnings about the same ultimate problem.  For code that relies on the current behaviour, there will be a needless warning.

Some have objected to using pack this way at all.  But the fact is that it has been possible for three stable releases (5.8 was buggy) already, so changing it would take away useful functionality and introduce a regression.

Eric, now do you see how I feel about sparse arrays?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About