Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110167 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13556 invoked from network); 15 May 2020 14:58:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 May 2020 14:58:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 44D3B1804CB for ; Fri, 15 May 2020 06:36:15 -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=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS701 96.241.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from nebula.zort.net (unknown [96.241.205.3]) (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 ; Fri, 15 May 2020 06:36:14 -0700 (PDT) Received: from [10.0.1.2] (pulsar.zort.net [96.241.205.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nebula.zort.net (Postfix) with ESMTPSA id C5F9D20008D93; Fri, 15 May 2020 09:36:13 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 nebula.zort.net C5F9D20008D93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zort.net; s=zort; t=1589549773; bh=EsPt7QeB2VdwLzCmt27G2iK9YWMX9Q//zH3QB768Djg=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=rzx2OOYUev/Cf7bjET1ZoKUGqvMh/k8TIqrgaWWnN3gnDsY7c7spP/VRHr1u5A0G+ ARTx9h4u/ctZgQw/NKjfQhhRmVuxXK6LV/utTGPw9JXvUjPNYyPm9LryHxXlOHp5+O tdxtxIcnRk/22cmtE5dZMAqeo4zJso124bOqxecU= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) In-Reply-To: Date: Fri, 15 May 2020 09:36:13 -0400 Cc: Ralph Schindler , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <301588B7-3FA5-49EF-A44B-9D5D24B68E9A@zort.net> References: <5780912D-2926-4381-8B40-FF4353140014@zort.net> To: Benas IML X-Mailer: Apple Mail (2.3608.80.23.2.2) Subject: Re: [PHP-DEV] Proposal For Return-If / Early Return / Guard Clause Syntax From: jbafford@zort.net (John Bafford) Benas, > On May 15, 2020, at 04:33, Benas IML = wrote: >=20 > Hey, >=20 > `guard` would be a keyword this means that all of the classes, = interfaces and traits named Guard would be illegal. Therefore Laravel's = `Guard` interface would be incompatible with PHP 8 which in turn means = thousands of web applications would be too. >=20 > Best regards, > Benas Seliuginas If the parser were sufficiently smart, I don't think 'guard' would = actually conflict with a class or function named 'guard'. If the syntax = were: guard (EXPRESSION) else STATEMENT_OR_BLOCK then, 'guard' could not conflict with a class name, because there's no = existing syntax that would fit the pattern of a type name followed by a = parenthesis =E2=80=94 you can't call a type name as if it were a = function. Even if you could, it would still not conflict with a function = call, because the 'else' keyword after the close parenthesis would not = be valid syntax immediately following a function call. So the main question there is, is the parser sufficiently smart to be = able to see 'guard' and look ahead for the 'else' to disambiguate a = function call from a guard statement? -John