[Issue 10404] Class!T should be the class version of type T

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 19 06:14:00 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10404


irritate <irritate at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irritate at gmail.com


--- Comment #2 from irritate <irritate at gmail.com> 2013-06-19 06:13:57 PDT ---
>  has the same methods as S, with implementations that forward to the member's
methods

I think this idea deserves some independent consideration.  It would be nice to
have some generic tools for wrapping one type around another with flexibility
to automatically override-with-forwarding some/all of its members.

Some brain dump I have about this:

1.  For example, it's very common in Phobos to wrap one range with another. 
I'd like to be able to get automatic forwarding members (and custom ones; and
hide some; all at my option) so that my wrapper range can provide the same
functions as my wrapped range without the boilerplate.
2.  In particular I'd like the qualifiers on my wrapper type's members to be
the same as the wrapped ones.  So if my inner range has a const length
property, mine will be made const at instantiation, etc.  (This reminds me of
inout for function parameters).  Maybe this would obviate the need for some of
the rampant Unqual that goes on when wrapping ranges.
3.  I tried to use __traits to creating a wrapping template, but I am an
amateur at this.  I also could not find a good way to define a member with the
same qualifiers as another type's member.
4.  Getting generic functionality for wrapping would align with "prefer
composition to inheritance".

Sorry if I am speaking out of turn.  I have just started looking at issues in
Phobos and have already run into these problems with boilerplate/qualifiers
with wrapping ranges.  And when I saw this issue for Class!T, I thought maybe
wrapping a struct in a class was just a special case of what I wanted with
wrapping one type in another.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list