rfc:generics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:generics [2016/04/25 14:18] – additional notes on the is-keyword mindplay | rfc:generics [2017/09/22 13:28] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 289: | Line 289: | ||
The first example is able to infer the type argument '' | The first example is able to infer the type argument '' | ||
- | The second example results in a '' | + | The second example results in a '' |
Note the addition of '' | Note the addition of '' | ||
Line 327: | Line 327: | ||
The same applies when overriding constructors and static methods. | The same applies when overriding constructors and static methods. | ||
+ | |||
+ | ==== Generic Constructors ==== | ||
+ | |||
+ | Constructors may accept arbitrary type-arguments, | ||
+ | |||
+ | <code php> | ||
+ | class Hello< | ||
+ | { | ||
+ | public function __construct< | ||
+ | { | ||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In other words, the constructor may accept more type-arguments than those affecting the type. | ||
==== Generic Closures ==== | ==== Generic Closures ==== | ||
Line 365: | Line 381: | ||
TODO: decide whether or not [[https:// | TODO: decide whether or not [[https:// | ||
+ | |||
+ | === Multiple Constraints === | ||
+ | |||
+ | TODO: decide whether or not multiple constraints should be supported, e.g. with a Java-like syntax: | ||
+ | |||
+ | <code php> | ||
+ | class A<T> where T is T1, T is T2 { | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This may relate to the [[https:// | ||
==== Autoloading ==== | ==== Autoloading ==== |
rfc/generics.txt · Last modified: 2018/06/02 17:33 by mindplay