Idea: Lazy upcasting
Marcin Kuszczak
aarti at interia.pl
Tue Mar 27 15:49:22 PDT 2007
Reiner Pope wrote:
>
> How about:
>
> interface Storage
> {
> Storage param1(int);
> }
>
> abstract class StorageImpl(T) : Storage {
> static assert(is(typeof(this) == T));
>
> T param1(int p1)
> {
> this.p1 = p1;
> return cast(T)this;
> }
> private int p1;
> }
>
> class SpecificStorage : StorageImpl!(SpecificStorage) {
> SpecificStorage param2(bool p2) {
> this.p2 = p2;
> return this;
> }
> private bool p2;
> }
>
> That should already work.
>
> Cheers,
>
> Reiner
I get problems with compiling this (I put info in another post). But even if
it would work I think that problem should be just fixed not only worked
around. For my own "hot-fix" workaround I used template mixin.
The problem is that solution is just complicated for simple use. It's
*unnecessary* complicated as it can be solved by fixed current clumsy
covariant feature.
Best what could be worked out up till now is in:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=51241
(It's my before previous post.)
--
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------
More information about the Digitalmars-d
mailing list