6 days ago

On Sunday, 28 September 2025 at 00:51:19 UTC, Dennis wrote:

>

Metrics metrics;
struct Metrics
{
double ascender = 0;
double descender = 0;
double underlineY = 0;
double underlineThickness = 0;
}

If we wanted to support this, perhaps have an anonymous struct expression:

    auto metrics = struct {
        double ascender = 0;
        double descender = 0;
        double underlineY = 0;
        double underlineThickness = 0;
    }();

This would be the struct counterpart to a NewAnonClassExpression. Though for consistency perhaps it should be struct (NamedArgumentList) { DeclDefs }.

6 days ago

On Sunday, 28 September 2025 at 11:59:42 UTC, Nick Treleaven wrote:

>

If we wanted to support this, perhaps have an anonymous struct expression:

    auto metrics = struct {
        double ascender = 0;
        double descender = 0;
        double underlineY = 0;
        double underlineThickness = 0;
    }();

This would be the struct counterpart to a NewAnonClassExpression. Though for consistency perhaps it should be struct (NamedArgumentList) { DeclDefs }.

I thought, supporting the C syntax would be good enough, example:

struct {
    int x, y, z;
} anons[8], other_var;

But if D already has anonymous class expression, than it would be confusing.

Anyway, what I find intriguing is something like:

MyTemplatedTHing!(
  struct {
    int i, j, k;
    auto somethingUseful => "hmmm";
  }
)();
1 2 3
Next ›   Last »