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

Re: No implicit coercion?

Thread Previous | Thread Next
Ovid via perl5-porters
December 27, 2021 19:00
Re: No implicit coercion?
Message ID:
On Monday, 27 December 2021, 19:43:02 CET, Felipe Gasper <> 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:


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:

IT consulting, training, specializing in Perl, databases, and agile development 

Buy my book! -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About