Now for a bit of hypothetical polling! thinking on the generics/templates syntax, one can’t quite shake the feeling Delphi got the C#/C++ generics/templates syntax. The < and > can’t be read out loud, and just look like an out of place reuse of the comparison symbols.
Interestingly enough, Pascal had something of a generics syntax (if in a restricted case) with “array of”. I sometimes wonder how reusing that syntax would float, especially combined with some other enhancements f.i. instead :
TQueue<T> = class var myQueue : TQueue<T>; myQueue := TQueue<T>.Create; function Whatever<T>(param : T) : String;
could be more Pascalish (and readable) as
TQueue of T = class var myQueue : TQueue of T; myQueue := new TQueue of T; function Whatever of T(param : T) : String;
And for multiple types with constraints, instead of
TFoo<T: ISerializable; V: IComparable>
wouldn’t something like
TFoo of T (ISerializable), V (IComparable) // or (Kazantsev Alexey's) TFoo of (T : ISerializable, IWhatever; V : IComparable) // or (Schalk's) TFoo of T, V where T is ISerializable where V is IComparable
be more Pascalish?
The clock can’t really be turned back… but what say you?
Pascalish generics syntax
- I prefer C-style anyway (40%, 69 Votes)
- I prefer Pascalish style (60%, 103 Votes)
- I've got a better idea (0%, 0 Votes)
Total Voters: 172
