Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49710 invoked from network); 24 Jul 2012 17:15:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 17:15:39 -0000 Authentication-Results: pb1.pair.com header.from=alex.aulbach@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=alex.aulbach@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: alex.aulbach@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:37600] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/61-42538-A38DE005 for ; Tue, 24 Jul 2012 13:15:38 -0400 Received: by pbbrp12 with SMTP id rp12so13931008pbb.29 for ; Tue, 24 Jul 2012 10:15:35 -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=mhtH46OB/XD7PVKgxJBtxYhR5u5x0IgvSzI0XY0jtuo=; b=ijrRiDWYLbSr2eJkxVJpEKbSFJWiHaz37wbsuWo6nobtUSTSJqMdEMyoFGs6/sLvvG 76qBZORFWZ+hlOvlJCErXBeMYZtabYdYI0q3Jf5POJhUBm1Ye5bbmnvdPTi1cJls6Vn2 ebVlvA3QtsmzfF32ie69gxytFh5T3lK5MS59wNc2DtEQHA9SHB2ECS0galM7IfBNMktH Ie2oKUxiL/tPVtck9+zwpILkEPV34pn0L9AZk+yMAVttJfaXf3A/rK3ZDagf3E44cgdz 5v8igwTQOdsn9PN/Iag7hfvNwfSznCN3JkE4lGqfanVQ6SatL5bRM1ZuWWAJj0Wtxc8t bTCg== MIME-Version: 1.0 Received: by 10.68.217.100 with SMTP id ox4mr46176191pbc.87.1343150135806; Tue, 24 Jul 2012 10:15:35 -0700 (PDT) Received: by 10.68.31.7 with HTTP; Tue, 24 Jul 2012 10:15:35 -0700 (PDT) In-Reply-To: <4024424F-2D65-41EA-8E18-B2B8FCE94754@gmail.com> References: <4024424F-2D65-41EA-8E18-B2B8FCE94754@gmail.com> Date: Tue, 24 Jul 2012 19:15:35 +0200 Message-ID: To: Yahav Gindi Bar Cc: Galen Wright-Watson , 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 Yahav Gindi Bar : > I don't think global operators is good idea since it can make a script very complex and you'll have to learn many operators in case the one who wrote it decided to make it "operator driven" On the other hand: If those operators aren't global, then they are local. I wouldn't like that much more, because inside "your project" you will then never know, if and how an operator is currently working. Much more confusion. But I wouldn't like to see this operator-stuff using in a "normal" context, in "normal" PHP-scripts. (What's normal?) I see those operators in a very limited context, e.g. when you create output (use PHP as template-engine), then they could be extremly helpful. Always and alyways repeating things, which can't be made shorter. For example checking the rights of a user: set_operator_handler('r', function ($user, $current) { .... if (!$userrRights->userHasRights($username, $current)) { throw userRightsException(....) } } and in the code: try { $user ?r: $current; } catch .... Ugly? Yes!!! Very! But that's wanted, because - as said - in very special context. [But really? You can read the code as: "Has the user the rights for current?"] In the end this is a design-decision. I wouldn't recomend this for the normal work (as shown above) and I think the said should be part of the documentation - if it is really implemented. But I think in some very special contexts this could be really helpful. > However, if we're talking about operators, I do think that adding operator override option (for the regular operators, such as +, -, * etc.) will be great for OOP - but that's a different topic. Existing operators shouldn't be changeable. My suggestion is the "PHP-way" of operator driven development for a very special problem, which is making very repeating but complex things very short, nothing else. :) Or in other words: In detail it's great, but in general it's a very bad idea. :) That's just wanted and if you think you must use it, then you should have a good reason. -- Alex Aulbach