[Issue 1840] New: Fix ambiguity errors over struct static opCall and regular opCall
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 14 20:06:49 PST 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 at digitalmars.com
ReportedBy: wbaxter at 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.
--
More information about the Digitalmars-d-bugs
mailing list