www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5501] New: Variant wrongly assumes that an object's length property returns a size_t

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

           Summary: Variant wrongly assumes that an object's length
                    property returns a size_t
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dransic free.fr



The following code doesn't compile. I hit the problem when using
std.datetime.Interval (which length returns a Duration).

import std.variant;

struct Foo {
    double length() {
        return double.init;
    }
}

unittest {
    Foo foo;
    Variant v = foo;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 29 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5501


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5501


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID



PST ---
This is by design. The length name is special and defined to return size_t
compulsively. A possible solution would be to rename std.datetime.Interval.
Will cc jmdavis.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5501




---

 This is by design. The length name is special and defined to return size_t
 compulsively. A possible solution would be to rename std.datetime.Interval.
 Will cc jmdavis.
I agree. But that makes the length property a quasi-keyword and I think it should be better documented, even if it is already used as such in practice. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013