www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1840] New: Fix ambiguity errors over struct static opCall and regular opCall

reply d-bugmail puremagic.com writes:
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.


-- 
Feb 14 2008
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Nov 03 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1840


bearophile_hugs eml.cc changed:

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



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: -------
Apr 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1840


bearophile_hugs eml.cc changed:

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



Seems fixed. See Issue 6036

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 06 2012
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Dec 27 2012