Re: [VOTE] Warn about invalid strings in arithmetic

From: Date: Fri, 25 Mar 2016 12:15:23 +0000
Subject: Re: [VOTE] Warn about invalid strings in arithmetic
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-91943@lists.php.net to get a copy of this message
Hi Björn, Björn Larsson wrote:
Den 2016-03-24 kl. 21:29, skrev Andrea Faulds: Came to think on a conversation with Sara G last year about introducing the following operators, namely >==, <== & <==> working exactly like the existing ones but without type juggling. Maybe that would alleviate some of the issue here, giving new tools at hand when writing new or updating existing code?
This is an interesting idea. === and !== avoid type juggling by returning FALSE if the types of their operands don't match, so what would these hypothetical strict versions of < and > do in that situation? One approach would be to order by type, so any integer < any float < any string, for example. I think I'd like that, it'd be more predictable than PHP's current comparison operators, where "1" < "a" < "b" < 1 < "2" < 2. I'm not sure about those symbols, though. Given their appearance I'd think >== and <== would be strict versions of >= and <=, even though I think you're proposing them to be strict versions of > and <. But surely something could be figured out. Thanks! -- Andrea Faulds https://ajf.me/

« previous php.internals (#91943) next »