Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61636 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23611 invoked from network); 23 Jul 2012 03:24:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2012 03:24:16 -0000 Authentication-Results: pb1.pair.com header.from=g.b.yahav@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=g.b.yahav@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: g.b.yahav@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:39607] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/94-20357-FD3CC005 for ; Sun, 22 Jul 2012 23:24:15 -0400 Received: by vbbfs19 with SMTP id fs19so5035054vbb.29 for ; Sun, 22 Jul 2012 20:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=3IRFUi68By23Lmlm5+zlqkJvRq9FZudLzsjpTkFtCRs=; b=OCSDFxAK/oLKEdlTj5RFEGnsU0ZS8FLU7DjrZ0fxw6meWn/syjVJTTZB5m7xeA81NZ LdemqJiMQtyEOisJPrwc5HIDKYH74GsZ3srr9cUUWUUBk7cGjK9QL4n02tAp0xaZoaV2 sKEel0ncD0Dp4ayDN33R+1DPm9+PuhQDPZ+g1Cb4GSSscPAU2LvQljGciWpTvvmhPwmj lGLczMB0H3+iNH3AMbdWuDQrDsgXQDAIYWdLzZ7s3m+igmrHgz4e4Y8bDzWKHhfJdOjM IOpqHuMGnIwMBYaVEzEe/UmrqCywp/WZR5hEe8Y60c2MtaMhSJgh9yqMZDXhHsdlQ3o4 Uynw== Received: by 10.220.153.200 with SMTP id l8mr11115992vcw.40.1343013852735; Sun, 22 Jul 2012 20:24:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.92.18 with HTTP; Sun, 22 Jul 2012 20:23:52 -0700 (PDT) In-Reply-To: References: Date: Mon, 23 Jul 2012 06:23:52 +0300 Message-ID: To: Alex Aulbach Cc: Rafael Dohms , PHP internals Content-Type: multipart/alternative; boundary=f46d04339cae9ee70204c576c73f Subject: Re: [PHP-DEV] Implicit isset in ternary operator From: g.b.yahav@gmail.com (Yahav Gindi Bar) --f46d04339cae9ee70204c576c73f Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jul 23, 2012 at 6:12 AM, Alex Aulbach wrote: > Do we really need that as operator? Why not using new functions for > special cases. > Don't see much difference between > > $a = $b ?: $c; > > and (for example I used "i" for "if") > > $a = _i($b, $c); > > Just a manner of getting accustomed to it. > > A little bit more thinking: This could be implemented directly into > any program/project, so it is a manner of how to use PHP and not of > why it isn't added to the language. > > PS: Would it be possible to implement functions like ":?()" or "!?()" > ? Currently this is not allowed by syntax. > > > 2012/7/18 Rafael Dohms : > > $width = $config['width'] ?: 300; > > > > The only reason for this to not work is: it throws a notice if the array > > key is not there (which is the case we are covering anyway) > > > > This is basically because the ternary operator does not do a internal > > implicit isset, only an empty. > > > > Does this seem like a possible improvement we can work on? Anyone > > interested in championing the change? > > -- > Alex Aulbach > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > I do think that such operator will be great. I think that you can compare the situation to the short if syntax ($a > $b ? $c : $d) - you could use a function too that'll do the same thing, but the syntax is very useful, readable and great. --f46d04339cae9ee70204c576c73f--