Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102547 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4856 invoked from network); 1 Jul 2018 16:21:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2018 16:21:23 -0000 Authentication-Results: pb1.pair.com header.from=carusogabriel34@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=carusogabriel34@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.170 as permitted sender) X-PHP-List-Original-Sender: carusogabriel34@gmail.com X-Host-Fingerprint: 209.85.128.170 mail-wr0-f170.google.com Received: from [209.85.128.170] ([209.85.128.170:35886] helo=mail-wr0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/07-15351-B7FF83B5 for ; Sun, 01 Jul 2018 12:21:18 -0400 Received: by mail-wr0-f170.google.com with SMTP id f16-v6so13172704wrm.3 for ; Sun, 01 Jul 2018 09:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PXe7ZfTKj6Cau8wZs+m2Gk7vCNh7akz4zdpoBfoI/IY=; b=e8CVfBwjSqHTdczKFuMvmonQrrqIH1x+7RwLRDH4qOEbrjmORIDQ0qbEqCOJxcqRKx 7E5xiJ6x22NQPCoBjLbgywWWsqPqJhVp3myx9EU1T88yFb530AZ1Uq8y6gSy6GFhEGpl FSUcqA1HdVYk2U267Ix0qZsfAsLAs7DrUq2xqjJQJCN82PEyn0OYA6bgoUElme1ozp6t vuByKeFmTbp3gBwZwDiTBnFNfFKMUt7AaksoNMDQNMwrYBMabiL+REaGsdEDS5pch/Un SKj528ccwJf4bsIPFQJV+fBuWEwuwEaBZCaMqo2v6rOiqJUq9howU8Jow8w3l0BHWbyj Rw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PXe7ZfTKj6Cau8wZs+m2Gk7vCNh7akz4zdpoBfoI/IY=; b=cEqwKET4u6RykzbSWZfvQUyug+6xqn4jDOFyq7bVmUF2TQZoTPFzHqt19lCm1aAt4O YXQqjesfW5YSUdlcdAGsnacY3g8aJDFM0MTVzYWwpY+NIBJf72DVo36BRrMGP9CWGYRW YRlmEnpJD1IttDxjzYPGOW6df+3+Zrvc6Xw3tgg5iUpTqrih2WSEsgZJilwkoFoJ7oyC EzIkMZJm2iEnq6EEXHTe5ToA8fX5vsei9zZ+3nxNp5kHjuwDzTQyGW7Vt+vOKaD5QarF Ve4meAJ9vZE22M76R84cz2tvOVQT7/0rycaixJZXdCw8L/99pkWE9KrjijTLXpu/wfUC SBSg== X-Gm-Message-State: APt69E3+EDfJf8kdCJWBfiT4NxN7L5CBXgy5GEXEBUTiPDQC9V7CQl67 wd/as0Xl0P5i+421aiRnzgPb8xsqnXNR7+olOus= X-Google-Smtp-Source: AAOMgpfJ8wzuHSYck+ieuAfoGT1jU0G2hv4xvRLtCM2MRQWfn/B7Rr1oQz6jSpAP/FrNopFMoUJ2eb+CE0MIY3IyyOY= X-Received: by 2002:adf:9ed0:: with SMTP id b16-v6mr13718904wrf.170.1530462072821; Sun, 01 Jul 2018 09:21:12 -0700 (PDT) MIME-Version: 1.0 References: <854a8dfc-4bc1-c001-a1a7-5347e5483ac8@gmail.com> In-Reply-To: Date: Sun, 1 Jul 2018 13:21:04 -0300 Message-ID: To: Nikita Popov Cc: Sara Golemon , Stanislav Malyshev , PHP Internals Content-Type: multipart/alternative; boundary="000000000000316252056ff278a4" Subject: Re: [PHP-DEV] [RFC] Mixed type From: carusogabriel34@gmail.com (Gabriel Caruso) --000000000000316252056ff278a4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > >> 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 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 o= f > 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 > Hello Nikita, Sara, Stan I agree with you that mixed in our current type system would be missused by those that want to document more than one type. So, the best to do would be to wait for a `union type` system in PHP, and than merge this feature to really document that a function accepts anything? Thanks, --=20 Gabriel Caruso --000000000000316252056ff278a4--