digitalmars.D - C#4 Covariance/Contravariance
- bearophile (4/4) Jun 07 2009 From the last C#:
- Lionello Lunesu (3/7) Jun 09 2009 Lionello likes this
- Robert Fraser (3/13) Jun 09 2009 In D if you want to treat a Template!(SomeClass) as a Template!(Object),...
- bearophile (4/6) Jun 09 2009 How is this related to Covariance/Contravariance and in/out keywords, as...
- Robert Fraser (2/10) Jun 09 2009 Errr... isn't that the point of covariance/contravariance?
- bearophile (4/5) Jun 10 2009 I don't know some of the things I post here. I just assume people here k...
- Lionello Lunesu (4/17) Jun 09 2009 Does not work for interfaces though.
- Daniel Keep (17/39) Jun 09 2009 Hell, it's not even safe.
http://codepad.org/kQgbwAqJ Bye, bearophile
Jun 07 2009
"bearophile" <bearophileHUGS lycos.com> wrote in message news:h0ggl7$60f$1 digitalmars.com...http://codepad.org/kQgbwAqJ Bye, bearophileLionello likes this
Jun 09 2009
Lionello Lunesu wrote:"bearophile" <bearophileHUGS lycos.com> wrote in message news:h0ggl7$60f$1 digitalmars.com...In D if you want to treat a Template!(SomeClass) as a Template!(Object), it's as easy as "cast(Template!(Object)) cast(void*) x"http://codepad.org/kQgbwAqJ Bye, bearophileLionello likes this
Jun 09 2009
Robert Fraser:In D if you want to treat a Template!(SomeClass) as a Template!(Object), it's as easy as "cast(Template!(Object)) cast(void*) x"How is this related to Covariance/Contravariance and in/out keywords, as shown Bye, bearophile
Jun 09 2009
bearophile wrote:Robert Fraser:Errr... isn't that the point of covariance/contravariance?In D if you want to treat a Template!(SomeClass) as a Template!(Object), it's as easy as "cast(Template!(Object)) cast(void*) x"How is this related to Covariance/Contravariance and in/out keywords, as shown Bye, bearophile
Jun 09 2009
Robert Fraser:Errr... isn't that the point of covariance/contravariance?I don't know some of the things I post here. I just assume people here know better than me. Bye, bearophile
Jun 10 2009
"Robert Fraser" <fraserofthenight gmail.com> wrote in message news:h0mui6$2rlh$1 digitalmars.com...Lionello Lunesu wrote:Does not work for interfaces though. L."bearophile" <bearophileHUGS lycos.com> wrote in message news:h0ggl7$60f$1 digitalmars.com...In D if you want to treat a Template!(SomeClass) as a Template!(Object), it's as easy as "cast(Template!(Object)) cast(void*) x"http://codepad.org/kQgbwAqJ Bye, bearophileLionello likes this
Jun 09 2009
Lionello Lunesu wrote:"Robert Fraser" <fraserofthenight gmail.com> wrote in message news:h0mui6$2rlh$1 digitalmars.com...Hell, it's not even safe. class Template(T) { static T instance; final T getInstance() { return instance; } } Or class Template(T) { static if( is( T == SomeClass ) ) { bool boom() { return true; } } void stuff(); } (cast(Template!(Object)) cast(void*) new Template!(SomeClass)).stuff();Lionello Lunesu wrote:Does not work for interfaces though. L."bearophile" <bearophileHUGS lycos.com> wrote in message news:h0ggl7$60f$1 digitalmars.com...In D if you want to treat a Template!(SomeClass) as a Template!(Object), it's as easy as "cast(Template!(Object)) cast(void*) x"http://codepad.org/kQgbwAqJ Bye, bearophileLionello likes this
Jun 09 2009