[Issue 7014] Better union initialization syntax
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 30 07:30:36 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7014
Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |verylonglogin.reg at gmail.com
--- Comment #2 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-09-30 18:30:34 MSD ---
Another option may be to extend "static initialization" syntax:
---
struct S { int i; double d; }
union U { int i; double d; }
void f(T)(T){}
void main()
{
S s = { d: 5 }; // OK
U u = { d: 5 }; // NG because of Issue 7727
// Original suggestion:
f(S( d: 5 )); // yes, let's not separate structs and unions
f(U( d: 5 ));
// Another option:
f(cast(S) { d: 5 });
f(cast(U) { d: 5 });
}
---
I'd like to require a `cast` even if the argument type is known.
And about original suggestion:
Having naming arguments in D (not only in this case) looks like a good idea
allowing one another coding style.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list