> On Dec 27, 2021, at 14:00, Ovid <curtis_ovid_poe@yahoo.com> wrote: > > 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) For “numeric strings” like this I’m not sure it’s as straightforward that a failure should happen. The recent discussions concerning IOK, IOKp, et al. *may* make it more feasible to fail in these cases, but IMO it would make more sense to solve the less-murky cases first. -FThread Previous | Thread Next