[OT] Apple introduces Swift as Objective-C sucessor

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 2 14:50:04 PDT 2014


On 06/02/2014 11:15 PM, Steven Schveighoffer wrote:
>
> They have template constraints similar to D. It looks something like this:
>
> func foo<T where T == Int>(t: T)
>
> I think everything after the where can be some condition, but I don't
> know how expressive that is. The examples aren't very telling.
> ...

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GenericParametersAndArguments.html#//apple_ref/doc/uid/TP40014097-CH37-XID_774

You can have subtype and equality constraints on generic type parameter 
and their "associated types".

> I still haven't figured out whether generics are runtime-based or
> compile-time based.

It is actual parametric polymorphism and not a form of macro if that is 
what you mean. I.e. the declaration is type checked only once.

> But some form of generics will be very nice to have.




More information about the Digitalmars-d mailing list