Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93812 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85440 invoked from network); 5 Jun 2016 12:09:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2016 12:09:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.144.14 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.144.14 ns10.kreativmedia.ch Received: from [80.74.144.14] ([80.74.144.14:45602] helo=ns10.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/45-55579-19614575 for ; Sun, 05 Jun 2016 08:09:55 -0400 Received: from RoLaptop (adsl-84-227-2-98.adslplus.ch [84.227.2.98]) by ns10.kreativmedia.ch (Postfix) with ESMTPSA id 8A30847E5D3D; Sun, 5 Jun 2016 14:09:50 +0200 (CEST) To: "'Bob Weinand'" , "'Andrea Faulds'" Cc: References: <0A.C5.62101.1C860575@pb1.pair.com> <9A.32.22497.9AE91575@pb1.pair.com> <6B.DE.25194.C5C53575@pb1.pair.com> In-Reply-To: Date: Sun, 5 Jun 2016 14:09:49 +0200 Message-ID: <003d01d1bf23$28c959e0$7a5c0da0$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHC17mo8ceEkMxWLa6fk99AI9WBYgH+IVGxAcJX8McC39XZcQHBHouQAcqImgSfpzChMA== Content-Language: de-ch Subject: AW: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: php@tutteli.ch ("Robert Stoll") Hi Andrea, Bob > -----Urspr=FCngliche Nachricht----- > Von: Bob Weinand [mailto:bobwei9@hotmail.com] > Gesendet: Sonntag, 5. Juni 2016 01:00 > An: Andrea Faulds > Cc: internals@lists.php.net > Betreff: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types >=20 >=20 > > Am 05.06.2016 um 00:55 schrieb 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:m= ulti-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/ > This is the holy grail I was hunting for so long! >=20 > All my computational problems can be solved by a simple rand()! >=20 > In case nobody objects I'm going to merge that straight ahead into = php-src 7.0 (no need for master-only, after all it's no real > BC break!). >=20 > Thanks a very much!!! >=20 > Bob Not sure if this is a clever idea. I haven't read all emails so bear = with me if this is more than clear. What happens with the following? function foo(int | string $a) { if ($a =3D=3D "") { //a=20 } else { //b } } foo(false);=20 What branch is taken? Is it taken randomly?