Thread overview
[Issue 1840] New: Fix ambiguity errors over struct static opCall and regular opCall
Feb 15, 2008
d-bugmail
Nov 04, 2010
strtr@despam.it
Dec 28, 2012
Walter Bright
February 15, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1840

           Summary: Fix ambiguity errors over struct static opCall and
                    regular opCall
           Product: D
           Version: 2.010
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: wbaxter@gmail.com


Since the de-facto way to construct structs is with static opCall, it basically makes it impossible to make interesting functors using structs.  Also gets in the way of various things that one might like to do in numerical code overloading opCall to do alternative indexing styles (for instance to mean raw indexing vs strided indexing, or to mean element indexing rather than row-wise indexing etc).

Unfortunately you quickly run into cases where your static opCalls (fake constructors) conflict with your non-static ones.

You can work around by using something like a create() method instead of static opCalls.  But then users of your code will be confused since they've been trained to look for static opCall to be the "constructor".

Or you can just not overload opCall and use some regular function like "get()".
 But that's not really a good solution for functors, since the whole point
there is that they should be callable like functions.

This needs to be fixed somehow.  The compiler should be able to distinguish
betweem StructName(...) and structInstance(...) usages.  The most obvious
solution is clearly just to allow using this() syntax for structs.


-- 

November 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1840


strtr@despam.it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |strtr@despam.it
            Version|2.010                       |D1 & D2
           Severity|enhancement                 |normal


--- Comment #1 from strtr@despam.it 2010-11-03 18:16:17 PDT ---
I would like to up this to a bug.

S s;
S(); // static void opCall()
s(); // void opCall()

Seen like this the calls have different names, thus should not conflict.

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


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2011-04-28 14:50:10 PDT ---
Bug 4053 seems similar or the same. Both have 1 (different) vote. This is an important issue I hit all the time in my code.

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


bearophile_hugs@eml.cc changed:

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


--- Comment #3 from bearophile_hugs@eml.cc 2012-10-06 11:03:11 PDT ---
Seems fixed. See Issue 6036

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
         Resolution|FIXED                       |WORKSFORME


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