On Saturday, 1 December 2012 at 19:32:27 UTC, bearophile wrote:
I don't know the rationale. There are tons of things I don't
know the rationale of, despite my efforts to learn.
The normal way to write a struct literal in D is this, that
works in most cases:
auto foo = MyStruct(42, 'a');
A
Bobby Bingham:
It appears that this form of struct literal really can only be
used in initializers -- the assignment to a previously declared
varaible fails to compile.
Right. That syntax is not much used in D, there were discussions
about deprecating it fully, I don't know the current statu
I'm just starting out with D, and am wondering about some differences
with C regarding struct literals. In C99, I can do this:
struct MyStruct {
int number;
char letter;
};
int main() {
static struct MyStruct foo = { .number = 42, .letter = 'a' };
struct MyStruct bar = { .number