Hi again,

In an attempt to be constructive, I have implemented an alternative approach to weak scalar type selection here:

https://github.com/krakjoe/php-src/compare/multi-types...TazeTSchnitzel:multi-types-roulette

Where there is no exact scalar type match, this patch uses an algorithm originally suggested by Nikita, wherein we use rand() to pick which type to cast to.

This is much simpler than having a type precedence matrix, and thus is easier to remember and reason about. The choice of selection function means that no particular use-case is privileged. Given PHP's scalar types are roughly equivalent (after all, PHP juggles them freely), this apparently unorthodox selection process should nonetheless produce sensible results in most cases.

Please tell me your thoughts!

--
Andrea Faulds
https://ajf.me/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to