Thoughts from a user-land denizen:

- I conceptually really like.  lambdas and closures are a feature I've been 
jealous of Javascript for having since I learned how Javascript "really" 
worked. :-)

- I recall earlier discussion pondering if we should be using the 
keyword "function" to describe this new construct.  It is a function, but not 
as we know it.  (Thank you, Mr. Spock.)  Should we consider using the 
keyword "lambda" instead, or do we think re-using "function" is acceptable?  
(I'm cool either way; I just wanted to make sure it was a conscious 
decision.)

- I don't think the lexical keyword is a wtf at all, especially given that it 
works essentially like global.  It simplifies both the internal code and the 
user-space code, because it becomes more self-documenting.  The semi-colon is 
a slight wtf, but since it is the same as Javascript I think most people will 
get used to it.  I have no objection to it.

- I am a little confused about the OOP interaction.  How does a function 
become a public method of the class?

class Example {
  private $a = 2;

  function myMethod($b) {
    $lambda = function() {
      lexical $b;
      return $this->a * $b; // This part I get
    };
    return $lambda;
  }
}

$e = new Example();
$lambda = $e->myMethod();
$e->$lambda(5);

That doesn't seem right at all, but that's how I interpret "Essentially, 
closures inside methods are added as public methods to the class that 
contains the original method."  Can you give an example of what that actually 
means?

- Related to that, would it then be possible to add methods to a class at 
runtime using lambda functions as the added methods?  If so, how?  If not, is 
that something that could reasonably be added here without hosing performance 
(or at least doing so less than stacking __call() and call_user_func_array() 
does)?

I guess I just need some code examples to see how this behaves in relation to 
objects, because I'm not really following it as is.

- My minuscule knowledge of the engine internals looks at the description 
there and doesn't see anything to be scared about, but I am far from an 
authority in that subject.  It does seem to side-step the "can't compile at 
compile time" problem that was raised back in December, which is good.

Overall, big +1 pending clarification of how lambdas and classes interact, 
which I still don't grok.

On Monday 16 June 2008, Christian Seiler wrote:
> Hi,
>
> Lukas Kahwe Smith asked me to put my proposal into the PHP wiki, which I
> have done:
>
> http://wiki.php.net/rfc/closures
>
> I also have incorporated the last comment by troels knak-nielsen about
> JS behaving the same way as my patch and thus not being that much of a
> WTF at all (I somehow had a different behaviour for JS in mind, I
> probably got confused with yet another language).
>
> Anyway, feel free to comment.
>
> Regards,
> Christian


-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to