Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102159 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97940 invoked from network); 5 Jun 2018 07:29:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2018 07:29:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:35328] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/4A-62758-9DB361B5 for ; Tue, 05 Jun 2018 03:29:30 -0400 Received: (qmail 122761 invoked by uid 89); 5 Jun 2018 07:29:26 -0000 Received: from unknown (HELO mail-io0-f171.google.com) (yohgaki@ohgaki.net@209.85.223.171) by 0 with ESMTPA; 5 Jun 2018 07:29:26 -0000 Received: by mail-io0-f171.google.com with SMTP id r24-v6so2091305ioh.9 for ; Tue, 05 Jun 2018 00:29:25 -0700 (PDT) X-Gm-Message-State: APt69E1QzqiI1ujs+hUiw1g5VBlu8Wy09C1sgukm8bm17Zs7TJdiRiPn 7iTvbVEE1pYm/rQJREtYAcjfxi7sBJx05XuP2w== X-Google-Smtp-Source: ADUXVKIXq9Gy+W+b7lLW9GlbsmRGTk8DljmdRicAWkFTMRzpnDpJRi6KK0E0oFXJm7JYv0sa0vfYvb7gHEMyFXppmU0= X-Received: by 2002:a24:7748:: with SMTP id g69-v6mr14409295itc.3.1528183759253; Tue, 05 Jun 2018 00:29:19 -0700 (PDT) MIME-Version: 1.0 References: <0d108361-f5fa-fe76-b6ad-66e23bfa88f5@loot.at> In-Reply-To: <0d108361-f5fa-fe76-b6ad-66e23bfa88f5@loot.at> Date: Tue, 5 Jun 2018 16:28:43 +0900 X-Gmail-Original-Message-ID: Message-ID: To: r.gottesheim@loot.at Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000001f3cb0056de002b3" Subject: Re: [PHP-DEV] Better types without runtime checking From: yohgaki@ohgaki.net (Yasuo Ohgaki) --0000000000001f3cb0056de002b3 Content-Type: text/plain; charset="UTF-8" On Tue, Jun 5, 2018 at 4:23 PM Rudolph Gottesheim wrote: > There's always a lot of talk about types in the PHP community. > Specifically, many developers want property types, generics, function > signature types, union and intersection types, and more. Those talks > (and RFCs) always end with the same result: "We can't do it because > performance issues." > > Has there ever been a discussion about adding some of those features > syntactically, but ignoring them during runtime? At least until someone > finds a performant way to check them at runtime. That way we could have > advanced type checking in our editors at least. > > The idea will sound familiar to TypeScript users. It works great for > that language. > > I'm excited to hear your opinions. > DbC style has no performance issue at all. In addition, you can perform much better validation than simple type checks. function f($username) { assert(is_string($username) && preg_match('\\A[a-z]\\z', $username); .... } -- Yasuo Ohgaki yohgaki@ohgaki.net --0000000000001f3cb0056de002b3--