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

Re: ???strict??? strings?

Thread Previous | Thread Next
From:
Felipe Gasper
Date:
January 6, 2020 15:51
Subject:
Re: ???strict??? strings?
Message ID:
8FA6DCB9-F49C-4303-98A3-845BA944BFDD@felipegasper.com


> On Jan 6, 2020, at 8:18 AM, Zefram via perl5-porters <perl5-porters@perl.org> wrote:
> 
> Felipe Gasper wrote:
>> so couldn't any existing code be rectified?
> 
> Ah, not sounding so opt-in now.  We prefer to keep existing Perl code
> running.  And no, existing code can't necessarily be `rectified' to work
> with a character/octet type distinction.

It’s very much opt-in. strictstrings code would just need to be aware of the called module’s behavior and compensate.

It seems like it would be simple enough: if I get back a text string when I wanted bytes, or vice-versa, then encode/downgrade/decode/upgrade as needed. The only way things would break would be, as with 'use strict', to have an error thrown that says exactly what’s wrong.

>  It's not so much the code that's
> the issue as the APIs: the type distinction would have to be introduced
> into most existing APIs (most involve strings in some capacity),
> requiring every module author to decide new semantics for their API.
> What really wouldn't work is APIs that currently generate strings that
> are useful both as character strings and as octet strings, and which
> are currently, correctly, used both ways by callers.  Introducing the
> type distinction would make such usage impossible.

Do you have an example that you could point me to?

-FG

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