January 02
On 1/2/2025 6:32 AM, Derek Fawcus wrote:
> The closest native equivalent in D, would seem to be the following, making use of the new facility.
> 
> ```D
> struct outer {
>      int a;
>      struct inner_ {
>              int b;
>              int c;
>      }
>      inner_ inner;
>      int d;
>      alias b = inner.b;
>      alias c = inner.c;
> };
> ```
> 
> Or is there a nicer way to write that in D?

```
struct outer {
    int a;
    struct {
        int b;
        int c;
    }
    int d;
}
```
January 02
On 1/2/2025 12:56 AM, Richard (Rikki) Andrew Cattermole wrote:
> Its a feature that once you learn that it exists, but not in D, you long for it, even if it isn't worth making noise over.

It's expected when one is an expert in a previous language to long for characteristics not in the current language.

But adding all this stuff in makes the language unwieldy and impractical to learn. Gotta draw the line somewhere.

January 02
On Thursday, 2 January 2025 at 19:08:06 UTC, Walter Bright wrote:
> On 1/2/2025 6:32 AM, Derek Fawcus wrote:
>> The closest native equivalent in D, would seem to be the following, making use of the new facility.
>> 
>> ```D
>> struct outer {
>>      int a;
>>      struct inner_ {
>>              int b;
>>              int c;
>>      }
>>      inner_ inner;
>>      int d;
>>      alias b = inner.b;
>>      alias c = inner.c;
>> };
>> ```
>> 
>> Or is there a nicer way to write that in D?
>
> ```
> struct outer {
>     int a;
>     struct {
>         int b;
>         int c;
>     }
>     int d;
> }
> ```

That does not yield the ability to reference the inner part as an entity/group.  Whereas that is possible with the D struct I proposed.

e.g. using the prior C definition, I can reference it from C as:

```C
#include <stdio.h>

#include "group.c"

void main() {
	struct outer o;

	o.a = 1; o.b = 2; o.c = 3; o.d = 4;
	printf("inner b = %d, inner c = %d\n", o.inner.b, o.inner.c);
	printf("sizeof outer = %lu, sizeof inner = %lu\n", sizeof o, sizeof o.inner);
}
```

or from D as:

```D
import core.stdc.stdio;

import group;

void main() {
	outer o;

	o.a = 1; o.b = 2; o.c = 3; o.d = 4;
	printf("inner b = %d, inner c = %d\n", o.inner.b, o.inner.c);
	printf("sizeof outer = %lu, sizeof inner = %lu\n", o.sizeof, o.inner.sizeof);
}
```

Or more likely, passing the address of o.inner to some other function.
January 02

On Thursday, 2 January 2025 at 19:08:06 UTC, Walter Bright wrote:

>

On 1/2/2025 6:32 AM, Derek Fawcus wrote:

>

The closest native equivalent in D, would seem to be the following, making use of the new facility.

struct outer {
     int a;
     struct inner_ {
             int b;
             int c;
     }
     inner_ inner;
     int d;
     alias b = inner.b;
     alias c = inner.c;
};

Or is there a nicer way to write that in D?

struct outer {
    int a;
    struct {
        int b;
        int c;
    }
    int d;
}

that's hard to learn, why is it possible to do outter.b = 42?

struct outer {
    int a;
    struct {
        int b;
        int c;
    } inner;
    int d;
}

now it is easier to learn, it is an anonymous struct called inner

January 03
On 03/01/2025 8:21 AM, Walter Bright wrote:
> But adding all this stuff in makes the language unwieldy and impractical to learn. Gotta draw the line somewhere.

In this particular case I have a concern with the grammar.

Identifier ';'

It is easily ambiguous, I don't think we can copy it even if we wanted to.

January 02
On Sunday, 29 December 2024 at 04:08:19 UTC, Walter Bright wrote:
> Sorry, but I missed it or it wasn't in the forums.

Never mind, it's impossible for a man to track everything. It came up recently in the context of `@property ref x() => inner.y;` vs `alias x = inner.y;` or something.
January 04

On Thursday, 2 January 2025 at 21:14:25 UTC, ryuukk_ wrote:

>

On Thursday, 2 January 2025 at 19:08:06 UTC, Walter Bright wrote:

>

On 1/2/2025 6:32 AM, Derek Fawcus wrote:

>

The closest native equivalent in D, would seem to be the following, making use of the new facility.

struct outer {
     int a;
     struct inner_ {
             int b;
             int c;
     }
     inner_ inner;
     int d;
     alias b = inner.b;
     alias c = inner.c;
};

Or is there a nicer way to write that in D?

struct outer {
    int a;
    struct {
        int b;
        int c;
    }
    int d;
}

that's hard to learn, why is it possible to do outter.b = 42?

That's how it works in C11. The spec shows some useful use cases:

https://dlang.org/spec/struct.html#anonymous

>
struct outer {
    int a;
    struct {
        int b;
        int c;
    } inner;
    int d;
}

now it is easier to learn, it is an anonymous struct called inner

That complicates the parser, beginners would forget to type the ; after a struct definition and get confused at the parse errors.

Why do you need an anonymous struct type there? Naming it and using the struct name for inner isn't difficult, and it doesn't seem needed that often.

January 04

On Saturday, 4 January 2025 at 20:01:33 UTC, Nick Treleaven wrote:

>

On Thursday, 2 January 2025 at 21:14:25 UTC, ryuukk_ wrote:

>

On Thursday, 2 January 2025 at 19:08:06 UTC, Walter Bright wrote:

>

[...]

that's hard to learn, why is it possible to do outter.b = 42?

That's how it works in C11. The spec shows some useful use cases:

https://dlang.org/spec/struct.html#anonymous

>
struct outer {
    int a;
    struct {
        int b;
        int c;
    } inner;
    int d;
}

now it is easier to learn, it is an anonymous struct called inner

That complicates the parser, beginners would forget to type the ; after a struct definition and get confused at the parse errors.

Why do you need an anonymous struct type there? Naming it and using the struct name for inner isn't difficult, and it doesn't seem needed that often.

anonymous structs are only useful in unions. dot end of the story. Or eventually that can help to have better header. You're just silly quys.

January 05

On Saturday, 4 January 2025 at 20:01:33 UTC, Nick Treleaven wrote:

>

On Thursday, 2 January 2025 at 21:14:25 UTC, ryuukk_ wrote:

>

On Thursday, 2 January 2025 at 19:08:06 UTC, Walter Bright wrote:

>

On 1/2/2025 6:32 AM, Derek Fawcus wrote:

>

The closest native equivalent in D, would seem to be the following, making use of the new facility.

struct outer {
     int a;
     struct inner_ {
             int b;
             int c;
     }
     inner_ inner;
     int d;
     alias b = inner.b;
     alias c = inner.c;
};

Or is there a nicer way to write that in D?

struct outer {
    int a;
    struct {
        int b;
        int c;
    }
    int d;
}

that's hard to learn, why is it possible to do outter.b = 42?

That's how it works in C11. The spec shows some useful use cases:

https://dlang.org/spec/struct.html#anonymous

>
struct outer {
    int a;
    struct {
        int b;
        int c;
    } inner;
    int d;
}

now it is easier to learn, it is an anonymous struct called inner

That complicates the parser, beginners would forget to type the ; after a struct definition and get confused at the parse errors.

Why do you need an anonymous struct type there? Naming it and using the struct name for inner isn't difficult, and it doesn't seem needed that often.

It's same story with tagged union, tuples, .enum, if you don't see them as improvements, there is nothing to argue about, try to use a language that supports them all, and you'll realize that it's like stepping up and upgrading your toolbox

You don't need class anymore, you don't need OOP anymore, you get empowered to use data driven development and it just is better

January 06
On 1/2/2025 11:58 AM, Derek Fawcus wrote:
> That does not yield the ability to reference the inner part as an entity/group.  Whereas that is possible with the D struct I proposed.

True, but it is a very minor convenience and there is still a simple way to do the equivalent.

D doesn't have a separate tag name space for C struct tags, either. Please don't ask for it :-/