Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117381 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31515 invoked from network); 19 Mar 2022 15:49:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Mar 2022 15:49:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 51EC9180505 for ; Sat, 19 Mar 2022 10:15:38 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS398810 136.175.108.0/24 X-Spam-Virus: No X-Envelope-From: Received: from mail-108-mta145.mxroute.com (mail-108-mta145.mxroute.com [136.175.108.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 19 Mar 2022 10:15:37 -0700 (PDT) Received: from filter006.mxroute.com ([140.82.40.27] 140.82.40.27.vultrusercontent.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta145.mxroute.com (ZoneMTA) with ESMTPSA id 17fa32d54270004b83.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 19 Mar 2022 17:15:31 +0000 X-Zone-Loop: d5a4613b19aa99094ad340758e8fc454d916929e3c19 X-Originating-IP: [140.82.40.27] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sandfox.me; s=x; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References: In-Reply-To:Date:To:From:Subject:Message-ID:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+xp5SiODmhxkp6uD7BzImxn80ngOFso3C3SIs/CNSKs=; b=DeJUHHAsYowlyRic3GRWTopX/A F6GZ113ckfPKFICqSWvz29FVQVXqmkGDrYu8PJygqR4RtqQllr1clRtUfKqw/GowimVizw0RFzpfj jtbkZeyYvVPxNF5ni/Td9Ad3IG58ZCGVCT8xUwwExBfHXLqR1ZnD6vR5Ae+dXr5sIU7aNqvLliFFC Mi03s1vaYTWc92uhZAR3g3pIjq7r8TEINjIdzL5qMHUX9VEoWRHXmt5Se0azoatHM9WvfC7QS6mQ4 NJyTa+Eix2h1XfXdJks4Srdyp96P844cLgwfR9Wb1Cabx7bsViJu83v0odl9ePcw1soUbulcA8ZCS b+PgS94w==; Message-ID: <67f0c6a5a1bb63f299877a07b0b6fde032ee6878.camel@sandfox.me> To: PHP internals Date: Sat, 19 Mar 2022 19:15:28 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AuthUser: sandfox@sandfox.me Subject: Re: [PHP-DEV] [RFC] Disjunctive Normal Form Types From: sandfox@sandfox.me (Anton Smirnov) On Sat, 2022-03-19 at 16:38 +0000, G. P. B. wrote: > DNF types are a way to mix intersection and union types together in a > single type. > For example: >  - (A&B)|null >  - (Traversable&Countable)|array Hello George, I like your proposal. I would like to offer 2 suggestions however: 1. I think that syntax would be cleaner without the parentheses 2. [Future Scope] I would go against non-DNF types. DNF forms a nice two level structure that's easy to comprehend. Arbitrary expressions may be too much for runtime checks (correct me if I'm wrong) and will definitely have high cognitive complexity. And CNF would allow to form invalid types too easily like (Traversable|null)&Countable Best, Anton