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

Re: pack and ASCII

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
January 15, 2012 14:08
Subject:
Re: pack and ASCII
Message ID:
1EF7107C-E713-4D6C-8B7E-FA8F0D106903@cpan.org
> 
> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About