[DIP] In-place struct initialization
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 2 08:59:04 PDT 2016
On 2016-07-31 06:55, deadalnix wrote:
> That doesn't help. In fact, it makes things worse as now constructor
> calls and function call do not have the same syntax. You've just created
> an holly mess in the parser.
>
> If something we should strive to get constructor call more like regular
> function call rather than less (for instance by behaving the same way
> when it comes to IFTI).
>
> It is also unclear how overload resolution is supposed to work.
>
> If I may suggest one thing it is to not start with the intended result
> for the DIP, but start from the intended change int he language, then,
> and only then, examine what comes out of it.
I think that there's a confusion here. The suggestion requires that the
type of the struct is included. In Ruby this is not required (there is
no named type). I don't see how adding a colon to a struct initializer
would mess up the grammar.
struct Foo
{
int a;
int b;
}
void bar(Foo foo);
bar(Foo(1, 2)); // allowed today
bar(Foo(a: 1, b: 2)); // allowed in this suggestion
bar(a: 1, b: 2); // _not_ allowed in this suggestion
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list