[Issue 12120] Static opCall for structures skipped (Github HEAD)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 9 18:12:09 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12120


Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow at gmail.com


--- Comment #4 from Vladimir Panteleev <thecybershadow at gmail.com> 2014-02-10 04:12:04 EET ---
(In reply to comment #2)
> If you define constructors in a struct, the syntax `Type()` should be reserved
> for default construction.
> 
> If you want to support both Foo() and Foo(1), you should change the constructor
> to static Foo opCall(int).

If I understood this change correctly, I don't think it is a good change, as I
mentioned in the pull request:
https://github.com/D-Programming-Language/dmd/pull/3221

This issue only serves as further evidence towards that.

(In reply to comment #3)
> I am sorry if I missed something, but how do I initialize a struct object
> element from a call to Foo()? I believe default constructors are not allowed
> for structs.

static Foo opCall()
{
    Foo foo;
    foo.bar = ...;
    return foo;
}

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


More information about the Digitalmars-d-bugs mailing list