Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69192 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89725 invoked from network); 18 Sep 2013 13:57:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 13:57:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@chrislondon.co; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@chrislondon.co; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain chrislondon.co does not designate 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: me@chrislondon.co X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:47074] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/1A-43258-B51B9325 for ; Wed, 18 Sep 2013 09:57:48 -0400 Received: by mail-wg0-f44.google.com with SMTP id b13so6385582wgh.11 for ; Wed, 18 Sep 2013 06:57:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=/Rk/PicW/O4Rzc0p05SIxhcp/hySvMFBZJb+t63sDts=; b=e/z/AUJRVUJBE+Kp4lxdRF9nwrQ7O7BubRa2FOpiK2M78LFVcVQQcSLnaoTtRwTreu l2hYK44cb4vhpU9qVnvEl7uGC/A5V0k58FETdl3vRzqZQXlmFkRj/2vE1lPUzqvocx8U FZSH7CXfCCcrILVRTWHFi1CKRMnZjwJz/8Ymm2k8NuJH5pmqI4nm2VGgbIjg9zMi4Tmm SMRnG6pTam8RB6Ubaq3ZUlEcgMLe1bpR7vrHudZoRMpntejtW+uV/CMPfQC0j5VxW3Wb Hs9xUgDsPoBd6vTAx7riilpf3y2vxjwEW15rzfINNYmHp9Q7MxIeWP8AJXR9Cvd6ci8i xxNQ== X-Gm-Message-State: ALoCoQmadvS2CrA86ciimORr8Uw5VwiN7A+yZ5vVgJen8fQgH5wZZgNfg9+LphO25IGjfgrjZw/a MIME-Version: 1.0 X-Received: by 10.180.21.170 with SMTP id w10mr7244966wie.62.1379512664124; Wed, 18 Sep 2013 06:57:44 -0700 (PDT) Received: by 10.217.122.16 with HTTP; Wed, 18 Sep 2013 06:57:44 -0700 (PDT) X-Originating-IP: [66.219.207.210] In-Reply-To: <012B9378-3C3A-4169-96D3-3B57D6C7A82C@seancoates.com> References: <49D57F66323040FC9AE48244DAAF3771@gmail.com> <012B9378-3C3A-4169-96D3-3B57D6C7A82C@seancoates.com> Date: Wed, 18 Sep 2013 07:57:44 -0600 Message-ID: To: Sean Coates Cc: Leigh , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bb70cb04f018204e6a8d237 Subject: Re: [PHP-DEV] Re: Allowing is_* functions to accept multiple parameters From: me@chrislondon.co (Chris London) --047d7bb70cb04f018204e6a8d237 Content-Type: text/plain; charset=ISO-8859-1 I like the naming convention of are_*. For me personally it isn't directly intuitive that the multiple parameters of is_* would be compared with an && and not an ||. On Wed, Sep 18, 2013 at 7:50 AM, Sean Coates wrote: > > i.e. is_null($a, $b, $c) would be the same as is_null($a) && is_null($b) > > && is_null($c) > > Note that this would not be semantically equivalent in this form, even if > `is_null()` did accept multiple parameters, because of the short-circuiting > with `&&`: > > > function are_null() { > foreach (func_get_args() as $a) { > if ($a !== null) { > return false; > } > } > return true; > } > > function destroy_data() { echo "DESTROYING DATA\n"; } > > // old form: short-circuited; data is not destroyed > if (is_null(null) && is_null(false) && is_null(destroy_data())) { > echo "All null.\n"; > } else { > echo "Not null.\n"; > } > > echo "----\n"; > > // proposed form: no short-circuit; parameters are evaluated at call time > and data is destroyed > if (are_null(null, false, destroy_data())) { > echo "Still null.\n"; > } else { > echo "Still not null.\n"; > } > > --047d7bb70cb04f018204e6a8d237--