Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52945 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5548 invoked from network); 5 Jun 2011 16:41:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 16:41:41 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:37754] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/02-26000-3C1BBED4 for ; Sun, 05 Jun 2011 12:41:39 -0400 Received: by bwz18 with SMTP id 18so3229873bwz.29 for ; Sun, 05 Jun 2011 09:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=0bfpNixWSK8IaNJkpDoCfoimyEza9pMxJ7q/xD71mQM=; b=Zd1+usHNol8Zr87aX8MpHI9FHI5lVmwo9SBXI+opIXbL/HoYs2M96Z4D9h44romuYT YdCOdsrHMj0D+HnEjhbw/V4PRrtOQkLGqgSOYEKi8Ov5EPpvFE1cXvG+99wjoZeOWwuZ pmI4hBuvIprCWpm3J6lVBxrzWDOsspuRLteyw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=c9MOR19OSekJlZSxee9VMAFpA2tXE+NgQ0ini5FKetDdT+qKrGjMJLqTh70rakx/Oh 9dU0w0nqxnE5QjojtXm6Kcbg/sCVr/eVwW5xdnq9umoA0MfpoZTZYHg2Z6VtJgs6sCOw EP6w6M3YguhkbikkcwRHwuWeb6tY/8CFlW3Zw= MIME-Version: 1.0 Received: by 10.204.74.9 with SMTP id s9mr4095165bkj.184.1307292095312; Sun, 05 Jun 2011 09:41:35 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.66.195 with HTTP; Sun, 5 Jun 2011 09:41:35 -0700 (PDT) In-Reply-To: References: <20110605175759.61a11a4a@benny-pc> Date: Sun, 5 Jun 2011 18:41:35 +0200 X-Google-Sender-Auth: 1Q24slxtdbgdOa6LvHXMjJ0PiiI Message-ID: To: Felipe Pena Cc: Benjamin Eberlei , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: colder@php.net (Etienne Kneuss) I consider this an improvement in terms of consistency w.r.t. callbacks, so +1 from me, good job! Best, On Sun, Jun 5, 2011 at 18:21, Felipe Pena wrote: > 2011/6/5 Benjamin Eberlei > >> That can lead to quite a bit of simplifications in code where you now ha= ve >> to check for is_array/is_callable/instanceof Closure and such. I like it= . >> >> > Exactly, and since our current $x =3D 'hello::world'; $x(); doesn't suppo= rt > method calls, the array one can help on this just like the call_user_func= () > approach with arrays. > > > class Hello { > =C2=A0 static public function world($x) { > =C2=A0 =C2=A0 echo "Hello, $x\n"; > =C2=A0 } > } > > function hello_world($x) { > =C2=A0 echo "Hello, $x\n"; > } > > $callbacks =3D array( > =C2=A0 array('Hello', 'world'), > =C2=A0 function ($x) { echo "Hello, $x\n"; }, > =C2=A0 'hello_world' > ); > > foreach ($callbacks as $k =3D> $callback) { > =C2=A0 if (is_callable($callback)) { > =C2=A0 =C2=A0 $callback($k); > =C2=A0 } > } > > Output: > Hello, 0 > Hello, 1 > Hello, 2 > > -- > Regards, > Felipe Pena > --=20 Etienne Kneuss http://www.colder.ch