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

Re: Pre-RFC: builtin:: functions for detecting numbers vs strings

Thread Previous | Thread Next
From:
demerphq
Date:
March 12, 2022 06:23
Subject:
Re: Pre-RFC: builtin:: functions for detecting numbers vs strings
Message ID:
CANgJU+WafGjtotQenuQcCv39H1cOKsNKgHjLxgW_c8GjxaR3mw@mail.gmail.com
On Sat, 12 Mar 2022, 05:19 William Lindley, <wlindley@wlindley.com> wrote:

> In all this discussion, what happens when reading a file


Any data that was read from a file would be a string unless you did
something to tell perl otherwise.

containing the
> line:
>
> 01730
>
> which is the postal code for my hometown.  This "looks like" a number


I don't believe it does actually. The leading 0 means that
looks_like_number() should reject it.

>
> but if treated like one, the leading zero is liable be dropped, leaving
> invalid postcode
>
> 1730
>

Yes, if you "numified" the original string that is how it would be treated.

>
> In more-pathological cases, 01730 could be interpreted as an octal
> number (984 decimal).
>

If you wrote it as code then that is true. But if it started out as data in
a file to get perl to treat it as octal you would need to pass it into a
function.

>
> It is disheartening that Perl's "be forgiving in what you accept; be
> strict at what you output" is violated by so many newer protocols.


I'm not really clear on what you mean by this. I feel like there is
something you may have misunderstood as nothing in your mail would behave
differently these days as opposed to the past, and none of the proposals
give me this impression. I'd be happy to hear more what gives you that
impression, but I assure you nobody that I'm aware of wants to violate the
principle you just quoted.

Cheers,
Yves

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