Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6368 invoked from network); 19 Jun 2008 08:52:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2008 08:52:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=troelskn@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=troelskn@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.154 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: troelskn@gmail.com X-Host-Fingerprint: 72.14.220.154 fg-out-1718.google.com Received: from [72.14.220.154] ([72.14.220.154:42695] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/05-12357-56E1A584 for ; Thu, 19 Jun 2008 04:52:54 -0400 Received: by fg-out-1718.google.com with SMTP id 16so385656fgg.23 for ; Thu, 19 Jun 2008 01:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=8V4qRkAj/uuzCJz6IkDaL0tM+VvxlTgHRcKwUAKiWGc=; b=Kv5C1v1OXA7ohfJUd3g1g7Id2ZxB5cyxUiii66E6FdgfspLRBDX0TDKTopHelC1yjq kdbwTVziFx7taxoG/o/fTYFNdbB1FstrRMio7oTPLZTiPH3+/rgsLF0SpsRT1bYKKTYv 8LE3XBBIPqbljoRZYkLRASQ5bfbhIUklfL38E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=TcwFtr/rkDNtrdyEiL0UU5u+QMtqkI9R2gG7H3eassxEqZD5ExK7bikqcmMcy5gRoj Fe52SnakYFfh4het6jd6Y7RY4fa+tolsHQsUKFog/XKHHF57IAoMaSYvJztGfVrzMkU0 dl9C+RmncPlXKPVREhnDOUDBeixGWjF1aT/WY= Received: by 10.78.172.20 with SMTP id u20mr887121hue.29.1213865570960; Thu, 19 Jun 2008 01:52:50 -0700 (PDT) Received: by 10.78.195.3 with HTTP; Thu, 19 Jun 2008 01:52:50 -0700 (PDT) Message-ID: <98b8086f0806190152t9803f8bx1370f2f0d2e96781@mail.gmail.com> Date: Thu, 19 Jun 2008 10:52:50 +0200 To: internals@lists.php.net In-Reply-To: <698DE66518E7CA45812BD18E807866CE01B70F8E@us-ex1.zend.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4856A547.3080801@gmx.net> <698DE66518E7CA45812BD18E807866CE01B11811@us-ex1.zend.net> <4858FCC7.5030305@gmx.net> <698DE66518E7CA45812BD18E807866CE01B70D73@us-ex1.zend.net> <48596C9E.2080605@gmx.net> <698DE66518E7CA45812BD18E807866CE01B70F8E@us-ex1.zend.net> Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: troelskn@gmail.com ("troels knak-nielsen") On Thu, Jun 19, 2008 at 8:44 AM, Andi Gutmans wrote: >> >> - In PHP 5, object storage is resources done right. I don't think >> >> we should be using the resource infrastructure for this >> >> implementation and would prefer to use the object one. It's better. >> >> I suggest to take a look at it. >> >> Hmm, seems like a good idea. If nobody objects in the next few days, >> I'll rewrite my patch to use objects instead of resources. What class >> name do you suggest? > > Great. I think Closure is probably a good name. > [Btw, if we want to get fancy we could even have a __toString() method on those which would print out information about the Closure. But this is not a must, just something which eventually could be nice for debugging purposes...] > Using objects, instead of resources is an excellent idea. Would it be possible to introduce a general __invoke (Or whatever name is more fitting) magic-method, so that whichever object implements that method, is callable with call_user_func (and directly through variable-function-syntax). Eg.: class Foo { function __invoke($thing) { echo "Foo: " . $thing; } } $foo = new Foo(); $foo("bar"); // > echoes "Foo: bar" I'm not sure how this would play together with lexical scope? -- troels