September 13

On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:

>
struct Test
{
    int test;
}

struct Data
{
    Test[8] test;
}

void add(Data data)
{
}

extern(C) void main()
{
    add( Data(test: [ {test: 1}] ) );
}

You are passing a struct literal to add. A struct literal is an expression:
https://dlang.org/spec/struct.html#struct-literal

>

A struct literal consists of the name of the struct followed by a parenthesized named argument list

So [ {test: 1}] is parsed as an array literal (because it is an expression), not an array intializer. {test: 1} in expression context is parsed as an invalid function literal (because there's no semi-colon).

September 13

On Friday, 13 September 2024 at 10:55:11 UTC, Nick Treleaven wrote:

>

On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:

>
struct Test
{
    int test;
}

struct Data
{
    Test[8] test;
}

void add(Data data)
{
}

extern(C) void main()
{
    add( Data(test: [ {test: 1}] ) );
}

You are passing a struct literal to add. A struct literal is an expression:
https://dlang.org/spec/struct.html#struct-literal

>

A struct literal consists of the name of the struct followed by a parenthesized named argument list

So [ {test: 1}] is parsed as an array literal (because it is an expression), not an array intializer. {test: 1} in expression context is parsed as an invalid function literal (because there's no semi-colon).

This should be allowed, another DIP idea, if anyone still care about improving the language

1 day ago
https://x.com/SebAaltonen/status/1848311998376738892/

https://x.com/FlohOfWoe/status/1848357742240518436

https://x.com/SebAaltonen/status/1848336276308554192

https://x.com/FlohOfWoe/status/1848355671554535764

If you want to attract talents, you have to provide them with the tools to be at least as productive and efficient as with C

I read, learn and get inspiration from these kind of people

I get rewarded as a result, relatively fast code (i'm still improving as i learn), ~0.4s clean build, and 300kb WASM file



1 2
Next ›   Last »