Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93814 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88917 invoked from network); 5 Jun 2016 12:24:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2016 12:24:06 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; 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:56406] helo=ns10.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/F5-55579-5E914575 for ; Sun, 05 Jun 2016 08:24:06 -0400 Received: from RoLaptop (adsl-84-227-2-98.adslplus.ch [84.227.2.98]) by ns10.kreativmedia.ch (Postfix) with ESMTPSA id 559D647E5D3D; Sun, 5 Jun 2016 14:24:02 +0200 (CEST) To: "'Ryan Pallas'" Cc: "'Bob Weinand'" , "'Andrea Faulds'" , References: <0A.C5.62101.1C860575@pb1.pair.com> <9A.32.22497.9AE91575@pb1.pair.com> <6B.DE.25194.C5C53575@pb1.pair.com> <003d01d1bf23$28c959e0$7a5c0da0$@tutteli.ch> In-Reply-To: Date: Sun, 5 Jun 2016 14:24:01 +0200 Message-ID: <004401d1bf25$247f4230$6d7dc690$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHC17mo8ceEkMxWLa6fk99AI9WBYgH+IVGxAcJX8McC39XZcQHBHouQAcqImgQBplRLbwHFre30n4vaqpA= Content-Language: de-ch Subject: AW: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: php@tutteli.ch ("Robert Stoll") > -----Urspr=C3=BCngliche Nachricht----- > Von: Ryan Pallas [mailto:derokorian@gmail.com] > Gesendet: Sonntag, 5. Juni 2016 14:22 > An: Robert Stoll > Cc: Bob Weinand; Andrea Faulds; internals@lists.php.net > Betreff: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types >=20 >=20 >=20 > On Sun, Jun 5, 2016 at 6:09 AM, Robert Stoll wrote: >=20 >=20 > Hi Andrea, Bob >=20 > > -----Urspr=C3=BCngliche 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 > > > > > > > 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! > > > > All my computational problems can be solved by a simple rand()! > > > > 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!). > > > > Thanks a very much!!! > > > > Bob >=20 >=20 > 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? >=20 > function foo(int | string $a) { > if ($a =3D=3D "") { > //a > } else { > //b > } > } >=20 > foo(false); >=20 > What branch is taken? Is it taken randomly? >=20 >=20 >=20 > In this case, A will always be taken, because of the loose comparison = (=3D=3D). Basically: >=20 > var_dump("" =3D=3D ""); // bool(true) > var_dump(0 =3D=3D ""); // bool(true) > var_dump(false =3D=3D ""); // bool(true) >=20 My fault, so what about=20 if ($a =3D=3D=3D "") { }