Thread overview
Re: Grouped named import
Jul 28, 2024
Walter Bright
Jul 29, 2024
Quirin Schroll
Aug 03, 2024
ryuukk_
July 28, 2024
D already has namespaces:

https://dlang.org/spec/attribute.html#namespace

A struct can also be used as a namespace:

```
struct c
{
    import sqlite3, miniz;
}
```

I've been using field-less structs this way myself.
July 29, 2024

On Sunday, 28 July 2024 at 18:01:43 UTC, Walter Bright wrote:

>

D already has namespaces:

https://dlang.org/spec/attribute.html#namespace

A struct can also be used as a namespace:

struct c
{
    import sqlite3, miniz;
}

I've been using field-less structs this way myself.

Yeah, nice.

For run.dlang.io, command-line args: -i -run main.d:

--- x.d

import std.stdio;
void f() { writeln("x.f()"); }


--- y.d

import std.stdio;
void f() { writeln("y.f()"); }


--- main.d

extern(C++, c)
{
    import x, y;
}

void main()
{
    c.x.f();
    c.y.f();
}

For that reason, I think, import Identifer { Imports... } wouldn’t even need a DIP, it would just be an enhancement that lowers to extern(C++, Identifier) { import Imports...; }. Using extern(C++, Identifier) is kind of a hack.

August 03, 2024

On Sunday, 28 July 2024 at 18:01:43 UTC, Walter Bright wrote:

>

D already has namespaces:

https://dlang.org/spec/attribute.html#namespace

A struct can also be used as a namespace:

struct c
{
    import sqlite3, miniz;
}

I've been using field-less structs this way myself.

Your example didn't work, i needed:

struct c
{
    public import sqlite3, miniz;
}

I never thought it would work, thanks for sharing