Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49485 invoked from network); 30 Jun 2018 20:30:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2018 20:30:46 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.194 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.194 mail-io0-f194.google.com Received: from [209.85.223.194] ([209.85.223.194:33314] helo=mail-io0-f194.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/93-15351-478E73B5 for ; Sat, 30 Jun 2018 16:30:44 -0400 Received: by mail-io0-f194.google.com with SMTP id d185-v6so11454325ioe.0 for ; Sat, 30 Jun 2018 13:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oGDdAJ1kgzxc+Dpfvp9UK0J4u0LLxmXM0jRTBpm2U8k=; b=nucx2hf5qyKkze6mpTd9hXUTvwGS/T3s9scYj6mRy5m2enBkkJGySj6kHdofzIyFC/ tgkrGuuXTxgUDCnwrCv+mmcWYRGUgaPtoEIc9ho7Y7Q720wYMbPJblihJ2+fLY0hQ/wj SS7NC1Q9S4WWmQAdn+qYrQ2+T6HcJ+RxKZpZDaIODkdOYvP3Uh8zKLMp8SrUTqiBCyqz Xh5LBeEeOLa9OLgjc45LHBqLil9JzDLDlQmup81HD3bmtnBcBfgnbvkZSRUWhmGvigV+ dfgxWDfvfU4WFn8Ih45n+E4bphPwI+DJ2VdhhArwouqXj/cNNLbgPq24uy4ytiYsvpkp EKpw== 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=oGDdAJ1kgzxc+Dpfvp9UK0J4u0LLxmXM0jRTBpm2U8k=; b=GimvSDZtfYa68eGXI3hZwqYanAbaeMM2/RQJ57G1DccIPncisrSdQnXdwB3cBxTpJq qkv1fS2bYDjyw6tbmZ0FqiZ7Anp5RR2ubQfmTOZEiE8FZM4o47l413dUKLwQfl59FOy3 6yHGkP2wz9/hTRyi2X2z3fya9Snl8RBVF5L3WtaM462woOGq7Qh7uSEJoLCM1rDpNcsb DMOYT0ZK3ROhaQaNs/jA07KkVTV9U5Fa/FpJRcG+Y8w2Lp+IbrzJ2OOmS4JUDTtMEETI XMPkJTuNVYZEPUbZQEn616c9jH/FRCRh1DDhODJ5AdUhMzeNrkRRRmPKdafUq/TdmIKy wGyQ== X-Gm-Message-State: APt69E2DKJyJe6DiH3ldWOImyKd+Few5vbEddKOI8xEy8ZOI0wl6GUIB 9yAzNsWyDC8dh4If3dLO7T0AFWS7X1wwbrVJpqg= X-Google-Smtp-Source: AAOMgpeJbAmxw0YSiYEbfzmwqXXd8s+kcOjjeMPwPoFEM+9IEONdHGzVTBHZqMWpkOiGHNgzB1P4n4JzEWV0cwuJZ/Q= X-Received: by 2002:a6b:2550:: with SMTP id l77-v6mr15509821iol.47.1530390641104; Sat, 30 Jun 2018 13:30:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:148a:0:0:0:0:0 with HTTP; Sat, 30 Jun 2018 13:30:40 -0700 (PDT) In-Reply-To: References: <854a8dfc-4bc1-c001-a1a7-5347e5483ac8@gmail.com> Date: Sat, 30 Jun 2018 22:30:40 +0200 Message-ID: To: Sara Golemon Cc: Stanislav Malyshev , Gabriel Caruso , PHP Internals Content-Type: multipart/alternative; boundary="00000000000087e30e056fe1d69b" Subject: Re: [PHP-DEV] [RFC] Mixed type From: nikita.ppv@gmail.com (Nikita Popov) --00000000000087e30e056fe1d69b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 a= re > 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 th= e 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 take > > it out, everything would be the same. Things like that belong in the > > documentation. Moreover, it makes the code harder to read, as the reade= r > > 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 --00000000000087e30e056fe1d69b--