Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28672 invoked from network); 28 Apr 2012 18:11:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2012 18:11:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@googlemail.com X-Host-Fingerprint: 209.85.214.42 mail-bk0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:35603] helo=mail-bk0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/D5-06766-CE23C9F4 for ; Sat, 28 Apr 2012 14:11:57 -0400 Received: by bkcik5 with SMTP id ik5so1167763bkc.29 for ; Sat, 28 Apr 2012 11:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=6zjNehtsZgfZuAU4xxcFrUMqRmpWfXEv5NkpY0Jj1pg=; b=S0oXm4SU+rkPt290UxYrjIJsap3C89L0iczj+Ui8W9vAeJVHFCcsZbVi/Rr/I3Gb6n 9TfWssNzH+1/0CcqVgHohSsxPvv8r3vDLDgOO+0kkJ9qGZ2HagH/Y7gjTdYztmN4UHzU CnkIUSsS+77o0r8yzeCt7jeO4T3BQnXtVzV0EAL7Mh3SO1mXrKe0361FsMCF84a2aqN2 M9sTKH7A0frXIo3aOL0iczC9GLQlIR8jIwfSBN2JDIbM+pJ9TUeufyJp272P/zpQFwT8 MfzmSUDtJlP94XsI8C0kHJjbYjCPUkgRFvYUZlAVA/6mF2Jr6WVHJpo1d9o9rE0D07Br hEWQ== Received: by 10.204.133.197 with SMTP id g5mr5453852bkt.28.1335636713176; Sat, 28 Apr 2012 11:11:53 -0700 (PDT) Received: from [192.168.24.2] (91-66-42-108-dynip.superkabel.de. [91.66.42.108]) by mx.google.com with ESMTPS id ie3sm3122338bkc.1.2012.04.28.11.11.50 (version=SSLv3 cipher=OTHER); Sat, 28 Apr 2012 11:11:51 -0700 (PDT) Message-ID: <4F9C32E4.7020108@googlemail.com> Date: Sat, 28 Apr 2012 20:11:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 To: internals@lists.php.net References: <4F9AFE3D.8010805@quis.cx> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Function boolval() From: krebs.seb@googlemail.com (Sebastian Krebs) Am 28.04.2012 06:27, schrieb Kalle Sommer Nielsen: > Hi > > 2012/4/27 Jille Timmermans: >> Hi, >> >> I suggest we add a function boolval(). It simply converts the given argument >> to a boolean, like strval(), intval() and floatval(). I already have an >> implementation ready[1]. >> >> Why? >> * It is missing in the current list of *val()-functions and people expect it >> to exist. I'd say it is an inconsistency. >> * It can be used as a callback, which is why a bool-cast does not suffice. > > Does it really matter nowadays when we got closures anyway: > > $bools = array_map(range('a', 'z'), function($a){ return((boolean) $a); }); > $bools = array_map(function($a){ return((boolean) $a); }, range('a', 'z')); $bools = array_map('boolval', range('a', 'z')); Second one seems more readable to me...