Hi!

> https://wiki.php.net/rfc/anonymous_classes
> 
> There's a little RFC + patch that Joe Watkins put together, and as
> before with the ArrayOf RFC, I'll be helping out.
> 
> So, lets get this discussion rolling.

This is a nice and clear proposal, however I'm not sure I'm completely
convinced about the necessity of it. In Java this kind of pattern is
used very frequently, because Java is a statically typed language where
it is the only way to achieve dynamic interface, and has other
capabilities, see below. In PHP, there are other ways (and can be made
more ways, such as more support for duck typing).

Also, the question arises when comparing this to Java - would anonymous
class functions be closures connected to the environment? In Java, they
are and that is what they are most frequently used for - to make
contextualized callbacks. In PHP, you need special syntax to capture the
environment, so how that would work? Also, what about scope access, etc.?

> Sadly due to the way in which people have had ONE CLASS ONE FILE
> drilled into their head since PEAR and continuing through Zend and
> PSR-0, it can become a PITA to add some simple functionality if a
> small class is needed for one tiny thing.

One class/one file may be a good idea in general for a big project, but
as they say, any feature that can not be turned off when needed is a bug.
-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to