www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4978] New: Can't get object out of Rebindable: get is private

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4978

           Summary: Can't get object out of Rebindable: get is private
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2010-10-02 18:09:00
PDT ---
This code

import std.typecons;

class T
{
    this() immutable
    {
    }
}

void main()
{
    immutable orig = new T();
    auto bound = rebindable(orig);
    immutable backOut = bound.get;
}


results in this compilation error:

d.d(14): Error: struct std.typecons.Rebindable!(immutable(T)).Rebindable member
original is not accessible
d.d(14): Error: struct std.typecons.Rebindable!(immutable(T)).Rebindable member
original is not accessible


As far as I can determine, get is the intended way to get the object out
Rebindable!() (I certainly can't see any other way), but it doesn't work. And
really, I see no point to get if it won't get you the object bound by
Rebindable!().

I think that get needs to be a property which returns original rather than just
an alias. The alias isn't working, and it makes really hard to use
Rebindable!() when you don't want to be passing Rebindable!() around
everywhere.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4978



--- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2010-10-02 18:14:08
PDT ---
Also, the static ifs at the top are missing any kind of get, so you can't use
get generically with Rebindable. Perhaps what should be done instead is to have
on opCast() which casts to the original. That would work with the first static
if - and obviously the struct in the else - but I'm not sure that it would work
with the second one since it's const when the original could have been
immutable. It is a potential concern though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4978


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from Steven Schveighoffer <schveiguy yahoo.com> 2010-10-04
06:15:59 PDT ---
*** This issue has been marked as a duplicate of issue 3318 ***

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