Thread overview
[Issue 4916] New: struct VariantN does not overload ()
Sep 23, 2010
Austin Hastings
Dec 02, 2010
Rob Jacques
Jan 09, 2011
Rob Jacques
Oct 25, 2013
Andrej Mitrovic
September 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4916

           Summary: struct VariantN does not overload ()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: ah08010-d@yahoo.com


--- Comment #0 from Austin Hastings <ah08010-d@yahoo.com> 2010-09-22 20:11:45 PDT ---
This code:
==============
module scratch;

import std.variant;

unittest {
    Variant v;

    int foo() { return 1; }

    v = &foo;

    v();
}
================
Produces this error:
================
$ dmd -unittest -run bronze/util/scratch.d
bronze\util\scratch.d(12): Error: struct VariantN does not overload ()
===============

IMO, this is a design flaw: Variants claim to support function and delegate pointers, and it seems obvious that supporting them should support invoking them. (In particular, since functions and delegates are different sizes, Variants should be very useful in this role, except ...)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4916


Rob Jacques <sandford@jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandford@jhu.edu
         Depends on|                            |4053
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4916


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: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4916



--- Comment #1 from Rob Jacques <sandford@jhu.edu> 2011-01-09 08:43:29 PST ---
Note that as listed in Bug 4053, struct constructors and opCall are not compatible, so the v() syntax isn't possible. In the update to variant I've been working on, I've added a .call method, which supports functions, delegates, opCall, etc. Also, multi-argument opCall should be supported:

unittest {
    Variant v;
    int foo(int x, int y) { return x+y; }
    v = &foo;
    assert(v(4,6) == 10);
}

See https://jshare.johnshopkins.edu/rjacque2/public_html/variant.mht

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4916



--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> 2013-02-26 09:07:24 PST ---
https://github.com/D-Programming-Language/phobos/pull/1152

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4916



--- Comment #3 from github-bugzilla@puremagic.com 2013-10-24 18:30:41 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/27733b1cc4dd32f34a4b6b45c73959f2ccab501e issue 4916

https://github.com/D-Programming-Language/phobos/commit/92c71f45f8e6216d5091bcd56e6fe38b49ec1eda Merge pull request #1152 from andralex/4916

Fix Issue 4916: struct VariantN does not overload ()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4916


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


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