Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102548 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9250 invoked from network); 1 Jul 2018 17:27:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2018 17:27:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.160.51 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.160.51 mail-pl0-f51.google.com Received: from [209.85.160.51] ([209.85.160.51:33927] helo=mail-pl0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/97-15351-3EE093B5 for ; Sun, 01 Jul 2018 13:27:00 -0400 Received: by mail-pl0-f51.google.com with SMTP id z9-v6so6806303plo.1 for ; Sun, 01 Jul 2018 10:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=b9cCg/BP9I0eqfBZPRQFQ6/2LhYnDafVIkgyJNakHXM=; b=P628XCbTb4MkqzFTsHJrYAX6kf3+mu8wxcgMj3Srr5h15may+jE8rh+Y465UxTevkb vsaSPtiCxgPUQnz90/PyrkDqvnSwmk+Zi6WYzwIIKgEpdXBFXNx4/+Oas+A5/nSGJu3k 8qkO0r1plddU79GSIBYMuHX8zFXgr8onFgFXPMtkP2mHKVQdu99RQYUMdSCTNsBL6AxQ uAWnlGLVq5hEDjXvXYOZnOflLpKVWAaOlc4UsvOE5twjLepoHNXVR5sSAupKYMubAUxZ V8B25P4qXlzxab5J4EjC501Eggme7wNDpOP7n5EfNA6kIc4H4VC5UdYLiuackJQoFYHi yqgw== 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:content-transfer-encoding; bh=b9cCg/BP9I0eqfBZPRQFQ6/2LhYnDafVIkgyJNakHXM=; b=YqRwp/yEh6ET6BnVTjeNrOyDDQtfux4+eWvIrfEt8HVcUjhzqVka/lWnsda2oF24AQ 3ad0oF9Nhch7nOBkvObsuDbQ2SOXA3lRtv5LdFqi0aam5da2UzCBdeAGvnjeWYRRs6qM OYiRe7GaBM0wAyTsQj55mK3rtzkWqyNC1z5DTRDRdwbxOCkQD1LPKqIWTKxjWxlAx6N6 556znJNFhahui0Kj6Dhz5Pt/ZcLK16Sp8eLaHarc6LgDNAD/UxEE6uUzAzUdKh3muj+E KENghpoNvJuX+umMX2dEBl6g2RNcrhbf+M7OFD6pMupTi5YiTT2gymyaReYFlajaTPis 8Q7w== X-Gm-Message-State: APt69E2UdnqaLDubo9pl6/a0l5wabiJ1ilpRyIdmgbMHa+q5Keq/L43g ariVmFe5Bxs1G4IvZibJ6PRjvPNNlh2fQt3g8+CaBg== X-Google-Smtp-Source: ADUXVKI0RR/JTnjbbwEWOQSvEXFuRorh5UfRfoY1z0FgwxxUjoijiGQo0UISPjw+CEBqJ6OX/UOi41M28i+BecDuigc= X-Received: by 2002:a17:902:b08d:: with SMTP id p13-v6mr22681227plr.344.1530466016176; Sun, 01 Jul 2018 10:26:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:7f86:0:0:0:0 with HTTP; Sun, 1 Jul 2018 10:26:55 -0700 (PDT) In-Reply-To: References: <854a8dfc-4bc1-c001-a1a7-5347e5483ac8@gmail.com> Date: Sun, 1 Jul 2018 19:26:55 +0200 Message-ID: To: Nikita Popov Cc: Sara Golemon , Stanislav Malyshev , Gabriel Caruso , PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Mixed type From: rasmus@mindplay.dk (Rasmus Schultz) Nikita, I think we'll need the mixed type-hint in any case if we're to move ahead with generics? On Sat, Jun 30, 2018 at 10:30 PM, Nikita Popov wrote= : > On Sat, Jun 30, 2018 at 10:17 PM, Sara Golemon wrote: > >> On Sat, Jun 30, 2018 at 3:08 PM, Stanislav Malyshev >> wrote: >> >> Together with Michael Moravec, we=E2=80=99d like to announce that we = are >> pretending >> >> to open the Mixed Type RFC (https://wiki.php.net/rfc/mixed-typehint) >> next >> >> Monday (02/07) and we=E2=80=99d like to ask you to take a look into t= he PR on >> >> GitHub (https://github.com/php/php-src/pull/2603) and let us know if >> >> there's something else to do before it. >> > >> > I think this is wrong. This "type" - which is not really a type, of >> > course - does not add anything to the code, by definition - if you tak= e >> > it out, everything would be the same. Things like that belong in the >> > documentation. Moreover, it makes the code harder to read, as the read= er >> > should make mental effort to discard this non-type every time it is >> > mentioned, as it does not carry any information. >> > >> I would say that, in a world without union or intersection types, it >> adds to the readability of the code by explicitly saying, "We accept >> more than one type here, and we know we accept more than one type >> here." This is distinct from, "We have no idea what type we accept >> here." That adds to readability, it doesn't detract. >> >> I preface that with a mention of union/intersection types because that >> seems to be the *actual* problem this RFC is attempting to cope with >> while lacking the tools to do it right. I'm not super excited about >> this RFC because, as you say, this information could be easily encoded >> into the docblock for the function/method. Zero impact to the syntax, >> same benefit for the programmer and their readability. (More benefit, >> really, as docblock standards *do* permit union/intersection types. >> > > I'm basically with Sara here. Generally the feature has some merit, but I= 'm > sure that given our current type-system, and in particular the lack of > union types, this feature will be misused to annotate parameters that do > *not* accept completely arbitrary values, but where "mixed" is the best > approximation we have. For that reason I would prefer to defer this > addition until proper union types are supported. In that case mixed would > be a shortcut for the otherwise somewhat unwieldy type of > ?(bool|int|float|string|array|object|resource) (modulo the non-existence = of > resource...) > > Nikita