develooper Front page | perl.perl5.porters | Postings from March 2014

Re: perlbug and encoding (Re: Perl 5.20.0 Blockers, 2014-03-24)

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
March 31, 2014 04:01
Subject:
Re: perlbug and encoding (Re: Perl 5.20.0 Blockers, 2014-03-24)
Message ID:
20140331040058.GA46923@plasmasturm.org
* Aristotle Pagaltzis <pagaltzis@gmx.de> [2014-03-31 05:35]:
> It’s lamentably easy to get confused because there are two layers
> (Perl and perl, if you will) that both use the exact same concepts:
> both deal with sequences of (small) integers and both use the same
> de-/encoding algorithms. “Of course”, on some level – because as you
> said: a decoded string does not *actually* exist. But semantically,
> they are distinct layers, and the use of the same representation on
> one layer has nothing to do with its use at the other layer.

Furthermore, we have no flag to denote “this is a decoded string”. We
only have a flag to say “select this code path when looking at the PV
buffer”, both of which paths can be used to implement either semantic
(they just need to have the right contents written into the PV buffer
to yield the right result under that semantic). So it ends up that the
encode/decode step preselects the correct code path to implement the
user-requested semantic *without actually recording any hint as to
which semantic that was*.

There is a flag that *seems* to indicate the right semantic but actually
only indicates the right code path.

And thus, confusion abounded among Perl programmers.

To keep the semantic straight, you need to keep track of it yourself, by
being explicit about which one you expect in all of your interfaces, and
then using encode/decode in strict accordance with your expectations as
declared. If all code in a program does so, then it WILL work correctly.
But the language offers zero aid toward this purpose to the programmer.

(End of digression.)

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

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