On 4/20/16 10:01 AM, Rowan Collins wrote:
guilhermebla...@gmail.com wrote on 20/04/2016 03:54:
1- Even though mentioned, I'd still use "extends" or "implements"
instead
of "is" (which would be a new pseudo-reserved keyword) to enforce
data type
consistency and prevent developers to potentially referring to one thing
while consider another.
Perhaps "instanceof" would make more sense here? "class
FileProcessor<T extends FileHandle>" seems to exclude instantiating
FileProcessor<FileHandle>, because "FileHandle extends FileHandle"
doesn't make any sense.
You could read "class Box<T instanceof Boxable>" as an assertion that
the class passes the constraint, as in "public function __construct(T
$t) { assert($t instanceof Boxable); }"
Regards,
I'm not an expert in generics by any means, but how is that different
than just
public function __construct(Boxable $t) {}
I thought the point of generics was for cases like "these two variables
must be the same type, but they can be any same type."
--
--Larry Garfield
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php