Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93791 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24558 invoked from network); 4 Jun 2016 22:55:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 22:55:26 -0000 X-Host-Fingerprint: 90.203.31.31 unknown Received: from [90.203.31.31] ([90.203.31.31:1601] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/DE-25194-C5C53575 for ; Sat, 04 Jun 2016 18:55:25 -0400 Message-ID: <6B.DE.25194.C5C53575@pb1.pair.com> To: internals@lists.php.net References: <0A.C5.62101.1C860575@pb1.pair.com> <9A.32.22497.9AE91575@pb1.pair.com> Date: Sat, 4 Jun 2016 23:55:20 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: <9A.32.22497.9AE91575@pb1.pair.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 90.203.31.31 Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: ajf@ajf.me (Andrea Faulds) 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/