[Retitled this to start a new thread.] On 28 January 2014 03:55, Zefram <zefram@fysh.org> wrote: > demerphq wrote: >>FWIW Figuring out a way to mark a string as not being upgradable, > > Sounds like a bad idea. Given that corruption of binary data by utf8 upgrading has been a repeated and expensive error at $work I disagree. Rather strongly. > What exactly do you mean by "a string" here? > Is this a status that would be preserved across copying such as scalar > assignment? I haven't decided, but probably not. > If so, adding any new hidden flag is a bad idea, but one > that prevents using what is otherwise always a legitimate representation > of a string is especially bad. Depends on your point of view. If you are one of the "there is no binary data mob" then I suppose you might consider it bad. On the other hand if you are not religious about this stuff then you know that Perl has to deal with binary data, and that it should NOT be upgraded, even if concatenated with unicode strings, and seen from that point of view it is a very good idea. So I consider Perl dieing (or perhaps warning, im flexible in that regard) when someone tries to concatenate a *designated* binary blob with unicode data exactly the right thing to do. Which is what I intend to make happen if I can. my $string= pack "N*", @nums; mark_as_binary($string); $string.=$unicode; # boom my $binary= encode_sereal($struct); # does mark_as_binary() internally my $unicode= "\x{100}"; $unicode .= $binary; # boom $binary .= $unicode; #boom sprintf "%s %s", $binary, $unicode; # boom My current thoughts are that this can be facilitated by attaching magic to the scalar and some minor patches to the appropriate parts of the internals. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Next