> From: Pawel Stradomski [mailto:[EMAIL PROTECTED]
>
> B), but what with following language construct:
>
> function doSomething (Service s) {...}
>
> PHP tries to autoload type Service, but it can't know if it's
> looking for interface or class. Both are possible.
Correct. I didn't consider this case because I didn't know this syntax for
interfaces.
To include this case, we can consider that, instead of a 'type' value, the
__autoload
handler receives a bit mask of the four possible types that can be requested :
classes,
interfaces, functions, and constants. It will have the responsibility to
resolve every
types corresponding to the bits set in the mask.
In your example, the interpreter would set the class and interface bits, as it
cannot
know which one it needs.
Your example seems to imply that classes and interfaces should not have the
same name.
Even if it is generally the case, it is not impossible. In this case, what does
your
example take, the class or the interface ?
Just an idea: wouldn't it be better to modify the syntax to :
Function doSomething (Always_A_Class s) { ... }
Function doSomething (s implements An_Interface) { ... }
And maybe
Function doSomething (s implements (Interface1,Interface2,...)) { ... }
Francois
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php