Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47936 invoked from network); 10 Jul 2018 18:59:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2018 18:59:06 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:33689] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/2B-15421-7F1054B5 for ; Tue, 10 Jul 2018 14:59:05 -0400 Received: by mail-wm0-f49.google.com with SMTP id z6-v6so14303088wma.0 for ; Tue, 10 Jul 2018 11:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CHN7WwvOtWMAnnfmd3fMIXN/fQjEG2U5v3KqtT/g8nU=; b=OSvgce7Y6HNnXrsAvOFw40/fEgGXpxol/2jDdUSGVp3+c7qQyqUTP2ldtsu/mNAztx bFFMIcOSMZTNBsT4LkmJJeCmPsMb0cR3kOO77sTg312JfCp+YlyC44gyLlhvQhad5XUD Syg2z+D7CJj8Oa+1tEqJ/HZG+jPeRc7JwfXdc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CHN7WwvOtWMAnnfmd3fMIXN/fQjEG2U5v3KqtT/g8nU=; b=O8tbubGBUADhpKQdGy0Iq14B2G91i4FyKV+jitgzQDVF2LmCkf1yKbePlyhX9lziZl a7I0cbYpfHKX0sg18xHjOAftc5KL0+ZHWWFyThRbFo1l06WjdokDuxo9T68ZOPKeUumB gxcKYrar4YAYngYf5+V3vgWVhUtOfraorY5IKQcVcutlTv/y5CPh2fzhVrNs/TJUBX7B V3v/JpTxHaT/08LbzXv+emh7c8NtACwOpBUU/Nhm4cQ3HtE+Fm3cqJXvSksxWDRwyE3i 0DZ1fDiglpUi0ObgHAyoJlec8eaXEscAMKPOuMiCPUrzOs1OHzw00KuATJ88UbB9OM3H ATIw== X-Gm-Message-State: APt69E3V+nreWQaJXA1ye05ktrlPDjYYL3isYcavN1Q7V34WyTtjhVSc EO/IDHfhltIj/ru/I7YxchDnSSyna8Ut1XtXQEyCbLb9 X-Google-Smtp-Source: AAOMgpchHto0yGCzQz1NOyLLG/GIHCu9KoeziFuxUn4j1c7J4OnmZL9AYdXQRiqcWKx/JIo5oPavRBBeSoDqY6Gy2nU= X-Received: by 2002:a1c:1983:: with SMTP id 125-v6mr16407188wmz.79.1531249140381; Tue, 10 Jul 2018 11:59:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:9f13:0:0:0:0:0 with HTTP; Tue, 10 Jul 2018 11:58:59 -0700 (PDT) In-Reply-To: References: <00c2c7a0-432e-0e19-983d-eca6c7cadf2e@gmx.de> <2123664.O6GaDqPnH7@vulcan> Date: Tue, 10 Jul 2018 21:58:59 +0300 Message-ID: To: Kalle Sommer Nielsen Cc: Larry Garfield , Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Unifying logical operators From: narf@devilix.net (Andrey Andreev) 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 : >> "do() or die()" code is/was very common in example code, tutorials, and 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 = '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.