Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101384 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40237 invoked from network); 19 Dec 2017 17:05:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2017 17:05:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.46 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.46 mail-lf0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:45158] helo=mail-lf0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/83-10479-2E6493A5 for ; Tue, 19 Dec 2017 12:05:39 -0500 Received: by mail-lf0-f46.google.com with SMTP id f13so20947896lff.12 for ; Tue, 19 Dec 2017 09:05:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=te4CmD6QbSuyEPBSMbD84yaXzZaubB4zpSJ8qcCgVEI=; b=WzMr/ekzcEXsuSZIcBd32TXu9rCin5GxzzzXua0tR1UjHe92XUgc4VXjh9VWPiig/2 kjEO0A7R1T4jKyiPUb93rFQaC7AUK1iKk3neFD9ZkAFxtQ4GuoGIlTqh3OID0UuPW48a xv0iq8ql4zNcJx+rvx1Zg5cikjyHn1DEDZFZgCqyrZ9P9ukcGtHUF5jucjxbJIFaNebi 2IA0O6ed0fW93HVUn9WN2TLR6M5E6dw4W5OnVAgw5Cd9ffNcCyjwz6PSRATWd+aaoDt5 MI+xVo+NEIo+BHp24kjUiDBQsLDFvFClt/yWTyIe4pXYwGyY3L0YixASRq724zKjVBKJ wOqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=te4CmD6QbSuyEPBSMbD84yaXzZaubB4zpSJ8qcCgVEI=; b=RhwiaEBTOPUgT3MAuG6nZ0oC1VAXlKWPh8O/vRASmuF25t7Onusei7nwUJnCUSvxje rrme4sgrEewAufSgANwUivsU6wikY2HLgodNeDQNQw5+ed3FHn1pdbrSNgl5SiRJaYt9 7h5ZC+rQXoOuFvYKvOQnVh2q5gthS/4KwpWD+vUO/228jJKAHsK6nKqUCfgfm7wRTI9B /SAGyqHzKlNO/6Z0FkwjVMp5kUeofUHlQ7VB3y1B55q63SQHv+Oeq709xSpzE70RmIMR XgKNC/wfec8luC30WYq2yfmlOBqDxNxDN/RGgqerFEoM/zNYEsrNYUY1CzOrE0OxdMdC QZgA== X-Gm-Message-State: AKGB3mITNI2wgWQ2ENh45+2NTpRwLz1mVHcjM9NxsnzndIPQfaWAzRH5 dfSOtywK+r1fwr2zgSgqHLELXT4T X-Google-Smtp-Source: ACJfBosjlkAyMNVzxOLU1VigJHpe36ZweBJhBUmUOCKzEJszEXq0HHyShYLstDkWw+3ezWnlXZ+z2g== X-Received: by 10.46.21.7 with SMTP id s7mr2660287ljd.71.1513703134742; Tue, 19 Dec 2017 09:05:34 -0800 (PST) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com. [209.85.215.50]) by smtp.googlemail.com with ESMTPSA id 72sm3193361ljz.31.2017.12.19.09.05.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 09:05:33 -0800 (PST) Received: by mail-lf0-f50.google.com with SMTP id x204so20945018lfa.11 for ; Tue, 19 Dec 2017 09:05:33 -0800 (PST) X-Received: by 10.25.141.74 with SMTP id p71mr2703031lfd.10.1513703133121; Tue, 19 Dec 2017 09:05:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Tue, 19 Dec 2017 09:05:12 -0800 (PST) In-Reply-To: References: <3a8054fd-b99f-771f-1f6c-29cf198acdeb@phpgangsta.de> Date: Tue, 19 Dec 2017 18:05:12 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Levi Morrison Cc: Michael Kliewe , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Mixed Typehint From: andreas@dqxtech.net (Andreas Hennings) We already have other "meta" types. E.g. "callable" can be a string, an array, an object with __invoke(). A "numeric" can be float or int. A "iterable" can be an array or an traversable object. Technically you are right, my "anything that could be an array index" would be equivalent to "string|int". Personally I don't think we need every possible union, let alone intersections. I am not strictly opposed to them, but don't find them as necessary. Most well-written functions will have one return type. But there are some cases of naturally occuring union or meta types, which might deserve their own meta type name. On 19 December 2017 at 16:28, Levi Morrison wrote: > On Tue, Dec 19, 2017 at 4:47 AM, Andreas Hennings wrote: >> On 19 December 2017 at 08:06, Fleshgrinder wrote: >>> What is really needed are `scalar`, `number`, union types, intersection >>> types, and all that together with generics. >> >> Do we have ongoing discussions or RFCs for those already? >> I know we have one for generics, which seems somehow stuck, >> https://wiki.php.net/rfc/generics > > No. Work is quietly being done on parameterized types (aka generics) here: > > https://github.com/morrisonlevi/php-src/tree/parameterized_traits > > There really isn't a lot to discuss at this stage anyway; the > technical implementation is paramount. > >> What would "scalar" mean exactly? string+int+float? > > Scalar and number are just ways of naming certain union types which > feature was already declined. Maybe a single RFC which targets both > union and intersection types would pass. Our `is_scalar` function > returns true for integer, float, string or boolean; a scalar type > should mirror that definition: int | float | string | bool. > >> I would sometimes like a string+int, for "everything that can be an array key". > > This is just another named union for `string | int`.