develooper Front page | perl.perl5.porters | Postings from December 2021

Re: No implicit coercion?

Thread Previous | Thread Next
From:
Ovid via perl5-porters
Date:
December 27, 2021 19:00
Subject:
Re: No implicit coercion?
Message ID:
1519741385.983626.1640631635791@mail.yahoo.com
On Monday, 27 December 2021, 19:43:02 CET, Felipe Gasper <felipe@felipegasper.com> wrote:

> IMO a “stricter” mode that refuses to do “nonsensical” things like numeric operations on 
> non- numeric SVs, scalar ops on references, etc. would be one of the most helpful features
> Perl could add. (Magic notwithstanding, of course.)
>
> We all know Perl “happily confuses” numbers and numeric strings, but other cases seem like
> places where the language could (fairly?) readily assist with bug-hunting.
>
> Is there a list anywhere of such behaviours?

Another example is JSON:

    {value:"0"}

If someone sends something as a string and I'm expecting a number, I can only guess if "0" is supposed to be the string "0", the number zero, or "false".

Most of the time the Perl code does the right thing, until it doesn't. And that can cause weird error far away from where the parsing occurs.

(Yes, I'm aware of the new booleans for Perl: https://www.nntp.perl.org/group/perl.perl5.porters/2021/11/msg261993.html)

Best,
Ovid
-- 
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/. 

Buy my book! - http://bit.ly/beginning_perl


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