If we can solve the scoping problem (perhaps via references as you
mentioned), then lexical (or another keyword, to be debated endlessly
for months, whose name-debate will delay the implementation of this
functionality, but I digress...) seems like a good solution to grabbing
scope, and fits the "PHP Way", IMO.

> So, given some way to explicitly reference the scope where the function
> was "defined", what happens when you call $fancyVer after that scope has
> gone away:

This was my next question (-:

> This could perhaps be solved by taking a reference to $ver when the
> function is bound, but I don't know enough about the ZE to understand
> the implications of that; it would probably require a bit more state
> tracking per zend_function so that we know that we need to do that step
> during binding.

JavaScript (and I suspect other Lisp-like languages) solves this by
making the function an actual closure—the defined function maintains
access to the parent scope, even after the parent's hash table (or
however it works in JS) would have normally been destroyed.

I think the key thing to remember here is that JS is fundamentally
different from PHP. Functions are objects in JS, and they always have
access to variables from all parent scopes. I don't think PHP can (or
should) ever implement this.

I also don't know what I'm talking about when it comes to ZE internals,
so if I'm way off base, feel free to put me in line (-:

(I maintain that JS' wonky (though useful) scoping rules should never be
assimilated in PHP.)

S

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

Reply via email to