Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75253 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79810 invoked from network); 4 Jul 2014 21:26:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jul 2014 21:26:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.182 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.182 mail-ob0-f182.google.com Received: from [209.85.214.182] ([209.85.214.182:42364] helo=mail-ob0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/F0-00852-71C17B35 for ; Fri, 04 Jul 2014 17:26:47 -0400 Received: by mail-ob0-f182.google.com with SMTP id nu7so2266505obb.41 for ; Fri, 04 Jul 2014 14:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=ympPEPuR4QZCktAHjH0u7aoaxJiQazpi5l7nkw7dWro=; b=T9C/rm9zJm9MfIeG+/D/ImlZmHffkU9npagnL3SGF3Un2gII+AiYUgVv+U0VyZvUW+ WJHX0MwZeh8bmJpSpByidy2mO47MWumMRF7WjoLi3/cHWHWheXheuvY40eqGkERFaCcX blFkeaJzsuwq/AR4ehqD6N/WRACoxlC+49fgJDQWHNLIndgdvMLOMsWRKgi3NGmaDVwv cHEYZPVsCThGe1q1mT+QlRKEM5yjEsEky9TR0nsSf6ZZzinA8tKFGGfMMi9ifs8tZXp9 2FfReZIYg2oQ2Pb5FIpA+i5FOYCkxRipYfh9be9BOt33hKEhWPCGvIfwHpRnbimyNns4 /XeQ== MIME-Version: 1.0 X-Received: by 10.182.44.233 with SMTP id h9mr15121854obm.68.1404509204484; Fri, 04 Jul 2014 14:26:44 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.76.77.100 with HTTP; Fri, 4 Jul 2014 14:26:44 -0700 (PDT) In-Reply-To: References: <002b01cf9784$4c1fe670$e45fb350$@tutteli.ch> Date: Fri, 4 Jul 2014 15:26:44 -0600 X-Google-Sender-Auth: ScRuhK59HUz5ATH_koPalPgFb44 Message-ID: To: Xen Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] not_null function From: levim@php.net (Levi Morrison) On Fri, Jul 4, 2014 at 2:27 PM, Xen wrote: > Op Fri, 04 Jul 2014 14:34:17 +0200 schreef Robert Stoll : > > >> [Robert Stoll] >> >> I really like how ruby tackles this problem with the syntactic sugar >> "unless" which basically is a substitute for "if( !() )". >> Maybe we could consider to introduce it in PHP next? It is very natural to >> read "unless(is_null($x))" an much nicer than "if(!is_null($x)" IMO. And it >> would not only solve your issue with is_null but is_Xy functions/methods in >> general. > > > I think that is just flawless. Thank you SO much for suggesting this. For completeness, it is available in Perl and I believe Perl had it first; not completely sure though. > Because you still have the cross-contamination between isset and is_null. > People wrongly use "isset" to test for "is set and is not null". So you > would have to keep is_null as meaning "if it is not set or (if it is set) > it is null". > > "unless (is_null())" would then mean "unless (!isset || is_null)" but it > would definitely be better than abusing isset for this. I don't think changing isset would be beneficial, sadly. I wish it only checked that a variable exists and didn't do the not null check but it's used very, very widely.