On Wed, Jun 26, 2019 at 12:00:18PM +0100, Rowan Collins wrote: > Perl is a notable contrast: the types of operands are deduced based on the > operator, but there are different operators to force them to different > types. So `23 < 4` and `"23" < "4"` are both numeric comparisons, so return > false; but `23 lt 4` and `"23" lt "4"` do string comparisons, and return > true. That way the user's intent is clear, but you don't have to manually > cast values or remember how different combinations will be interpreted.
IMHO the Perl way is better: the different operators mean that I will get what I want, I don't need to worry about an accidental type juggle; it is also (presumably) faster as the run time does not need to: look at a string, decide if it could be a number and maybe change what it does. The big problem is backwards compatibility, so new operators would be needed: string compare: lt, gt, etc, not much of a problem numeric compare: #< #> would be nice were it not that # means comment. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 https://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: https://www.phcomp.co.uk/contact.php #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php