Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50162 invoked from network); 10 Jul 2018 19:08:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2018 19:08:16 -0000 Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.41 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.214.41 mail-it0-f41.google.com Received: from [209.85.214.41] ([209.85.214.41:56058] helo=mail-it0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/AB-15421-C14054B5 for ; Tue, 10 Jul 2018 15:08:15 -0400 Received: by mail-it0-f41.google.com with SMTP id 16-v6so188158itl.5 for ; Tue, 10 Jul 2018 12:08:12 -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=47zRNznvLXW+Tn1cMWkTtxTTD7QwkhQVjUqHbhUjtcs=; b=JSw318w3WCCJ4mAiHJsSu3HwKNZpxqFiNv47AVNRKjQpEDB4oJpylbQjbS+3wMjsFM eWG/OngPzmdegS2W3YJK6swCz4v7qDHbx8jPf4TARkdpZL3cjPkqbScAL+zmchj/TvHV FRbSkLNnHkKZ8V/+gBz6J8Yu4VVaIaDKRVstwbSmggS8VgKL2PbnV7ZjtEyHBYo+zw8p vM0X5LKy9B1z/EOW0cifhoyYFodwQn94SoBG7M5fcGWSOPXrwt5cFjudDNFz0b1etqiM maebuNiXh06n6s5bv1D+2npCW7JfLqGASG0RCqG264chOdCHz0LvQoXhYZBAzDp624II agrg== 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=47zRNznvLXW+Tn1cMWkTtxTTD7QwkhQVjUqHbhUjtcs=; b=ZxUF6EzjBUaXYlCWk5Ln1ZDaK7ZzRncNk3P0aFAuk1lZG1dhXwjWcXCKKnhMEHuWVQ shQ0ypvDCXfcaal/W+nKBD0YWfdvzm9JcUVKqmqTlco57jruEoMZn2m4GQXZ5SStSV0q Mepca2flvohrInEroyuDa5VLJqP4/hatABhcWPlSlwIug1+xySSTq81i3CZ4ovTTTkEO s7uYRdg4cIOizEMbdGNWg1ehOKbe3LtILRgjhJyuEPfD53xypiq3ff5yO3PzYmJOjRVz TP/CxIs0ViNVR1fB+3P19PjzFKY9Ah59vXJ3HT57idhumuPYcZh5JwSi0gvuk8nWDHo6 4JDg== X-Gm-Message-State: APt69E0bJ+tMRGYAIsysLJjhqOnCG0PRpvT/t55jNqRuk633wzy5qD6d VbjfKU5FKnQr4eWdA/wRTzLbi4xER2rvRj6IGCU+9A== X-Google-Smtp-Source: AAOMgpeaOf2iefn6IdwE4D18DFFxH7t/5ikUu683zQJchCJa5KSZz9vB/SEkmSwr9AT/vX1ZZmBQfhxV0P2iau6sg80= X-Received: by 2002:a24:5cc8:: with SMTP id q191-v6mr20958645itb.63.1531249690189; Tue, 10 Jul 2018 12:08:10 -0700 (PDT) MIME-Version: 1.0 References: <00c2c7a0-432e-0e19-983d-eca6c7cadf2e@gmx.de> <2123664.O6GaDqPnH7@vulcan> In-Reply-To: Date: Tue, 10 Jul 2018 16:07:58 -0300 Message-ID: To: narf@devilix.net Cc: Kalle Sommer Nielsen , Larry Garfield , PHP Internals Content-Type: multipart/alternative; boundary="000000000000d8c5ed0570a9d903" Subject: Re: [PHP-DEV] Unifying logical operators From: david.proweb@gmail.com (David Rodrigues) --000000000000d8c5ed0570a9d903 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I think that "or" could be removed if PHP could supports inline conditionals like: die() if !$connected; throw Exception() if fail(); $x =3D $y if (z() && w()); Or "when": die() when !$connected; It seems more clear than $connected or die(). Em ter, 10 de jul de 2018 =C3=A0s 15:59, Andrey Andreev escreveu: > Hi, > > On Tue, Jul 10, 2018 at 9:37 PM, Kalle Sommer Nielsen > wrote: > > Den tir. 10. jul. 2018 kl. 20.22 skrev Larry Garfield < > larry@garfieldtech.com>: > >> "do() or die()" code is/was very common in example code, tutorials, an= d > other > >> intro material because it means you don't need to think about error > handling. > > > > I personally wanted to extend this syntax but I never got around to it > > to support: "do() or throw new Exception(...);", tho its just a code > > style over: "if(!do()){ throw new Exception(...); }" > > > > I sometimes declare a closure that throws an exception to do just > that. It's very convenient in short(ish) scripts. > > isset($foo) OR $foo =3D 'bar'; (and similar variations using empty() > and/or &&) is another pattern I use often to set fallback values for > empty or missing inputs. > > An eventual deprecation would make literally all of my code output > entire screens of warnings. > > Cheers, > Andrey. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 David Rodrigues --000000000000d8c5ed0570a9d903--