Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61694 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30089 invoked from network); 24 Jul 2012 16:18:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 16:18:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=alex.aulbach@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alex.aulbach@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: alex.aulbach@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:49982] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/CD-17533-1CACE005 for ; Tue, 24 Jul 2012 12:18:10 -0400 Received: by ghbg2 with SMTP id g2so7813981ghb.29 for ; Tue, 24 Jul 2012 09:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=g/A95fCREPAUd31UPEzkS1OX+vqPYgzXQ5TmusBdCsA=; b=UcsRJb1S+8TGbhMGsPQlmrE5Wn1SE+WUcegTRkxUrm+oBF+89TBUfGgB3gQvpvnp/V EGyIOpn/CSMUqCaI7BOvrnFw2G167c18trKi9KE0U/P+DiHZkQn8goZNVn2Jc/lmHg82 dPtMQjcgfrHJgmdA+vLTyGkwQyiQEchIkvMc1Agajp21YYR1pns8hwzEczt4l44KlAbm 0bSd7uYvlieuI5MClRC0sGcuX0JOlZ00YIXmumqeDCM9KJQTlpjKvlI2q8UaAlxjywD6 aYjKck5o+riznbq6Z2Nu5eLSW9jTnE9u4zdiM2RGiENI15NOIx9FAwmwgh1+v1fQRRMP reEQ== MIME-Version: 1.0 Received: by 10.66.79.195 with SMTP id l3mr5802430pax.33.1343146687009; Tue, 24 Jul 2012 09:18:07 -0700 (PDT) Received: by 10.68.31.7 with HTTP; Tue, 24 Jul 2012 09:18:06 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Jul 2012 18:18:06 +0200 Message-ID: To: Galen Wright-Watson Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Implicit isset in ternary operator From: alex.aulbach@gmail.com (Alex Aulbach) 2012/7/24 Galen Wright-Watson : >> Don't see much difference between >> >> $a = $b ?: $c; >> >> and (for example I used "i" for "if") >> >> $a = _i($b, $c); > > > When $b is defined, there isn't much appreciable difference. However, this > behavior already exists, so there isn't much to debate. In the cases under > discussion, a userland function can't suppress undefined variable & index > notices, so it isn't a viable substitution. Hm, you're right. I normaly don't do such ugly things. :) Hum. This behaviour is needed in very special contexts. In my eyes only when printing out/filling up the templates etc. Under normal circumstances I think, you should program without too much operators, because a deflation of operators leads to - hm - deflation of the language. Thats the same, as if everybody can create new words: after a short time, nobody can understand anybody. Hmmmm. But we can make this to a principle in this very, very closed context. So: What about if we can create new operators inside PHP with PHP? I think not more than 36 operators are needed at any time in a project. So we can do this: set_operator_handler('i', function ($b, $c) { if (empty($b)) return $b; return $b; }, OPERATOR_HANDLE_UNSET_WITHOUT_WARNINGS) then we can do this: $a = $a ?i: $b; This should help for this case and could be a great things for those very special cases, when you need the same operation over and over. Comments ---------------- Context: I think those operators should be global. Security: Hm. Could operators be overwritten? How to test, if an operator already exists? I think it should work like including a file. E. g. set_operator_handler_once() should be possible, so that a second call isn't executed. Other things: I don't like the first operator (the operator-name). Any goof idea? -- Alex Aulbach