Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93813 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87486 invoked from network); 5 Jun 2016 12:22:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2016 12:22:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.46 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.218.46 mail-oi0-f46.google.com Received: from [209.85.218.46] ([209.85.218.46:33619] helo=mail-oi0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/A5-55579-17914575 for ; Sun, 05 Jun 2016 08:22:09 -0400 Received: by mail-oi0-f46.google.com with SMTP id k23so189916120oih.0 for ; Sun, 05 Jun 2016 05:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Amtx5P5UOR+gjeXSGiiEQkhAGGbHSgdJhuQfV2t5c2A=; b=Irhx+FvSHBn358bzuvErphvQ35LOv2OVkJTDHPuEPiU4etd3AdsZFV5Ti54X+nRfao sw74Zoac04235ZlqT/9T74Zxg4QCdc6My0S33YS8ByGS4o3CJy9PU1tdt51fldCdN5tZ /QpGY+BuFYllpONordev2L/S6htY1La4Oe9KGu/8lGTBFzlHaAcvxeKGFco019ViVcr7 sidTfX+xXbR4TZ5AHUpRyzzXfNTMgjjzI+44o63vPN6PY4kZVZCkSX1Xu5o8r2nny30Z tdiRiJmLz9jqkKW5ZsFcj8UaXaI0o2XTyWl/pzWjeo/qeOXY4vnBp9IkprLq5Sn7TQp1 PtYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Amtx5P5UOR+gjeXSGiiEQkhAGGbHSgdJhuQfV2t5c2A=; b=kpUp35nX9cmgbuq++z7abcB0O8u5u4vglOrep7I1ey1W5LDQnt1PG2fi4jfp1LIR7L NR5N2DL/8IeNIIi7jtZeuNO7vCNgSEINWEZa5DDkTd5UOKOSsyvKx3Bm+BwjTrDtmVrh RFWed8W6GTU8GIbf/zXR8MPs4I4Q/c9LIx5tXmUQ4mDRhAGf749Lak1p02ihHry6qU9R Fx2U9gqbneIeWtdydpqJRWog5mCkcVev2+MrHWbhW7WEKDeBtbJnaIjFUQDcv6fJjhc0 lWExqiN+Av/y1U5GYFYMSREa9jCv8CoN2vqK2cDmZzOPPapkqIj7j4ltfUZXSPRxPEG/ u34w== X-Gm-Message-State: ALyK8tIGZtckyHW1ca4NAvdVjjpx5M1xgDs7EU/vJ0wOzsZwxJuDdxyV+A2eYhBqcHTByT10Y1yQZFTvweyquw== X-Received: by 10.157.42.35 with SMTP id t32mr5697120ota.6.1465129326601; Sun, 05 Jun 2016 05:22:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.7.228 with HTTP; Sun, 5 Jun 2016 05:22:05 -0700 (PDT) In-Reply-To: <003d01d1bf23$28c959e0$7a5c0da0$@tutteli.ch> 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> Date: Sun, 5 Jun 2016 06:22:05 -0600 Message-ID: To: Robert Stoll Cc: Bob Weinand , Andrea Faulds , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113d1c260feadd0534870112 Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: derokorian@gmail.com (Ryan Pallas) --001a113d1c260feadd0534870112 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sun, Jun 5, 2016 at 6:09 AM, Robert Stoll wrote: > Hi Andrea, Bob > > > -----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 > > > > > > > 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 i= s > 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 > > 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 > } else { > //b > } > } > > foo(false); > > What branch is taken? Is it taken randomly? > In this case, A will always be taken, because of the loose comparison (=3D= =3D). Basically: var_dump("" =3D=3D ""); // bool(true) var_dump(0 =3D=3D ""); // bool(true) var_dump(false =3D=3D ""); // bool(true) > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113d1c260feadd0534870112--