digitalmars.dip.ideas - Grouped named import
- ryuukk_ (17/17) Jul 22 Saw this somewhere, and to be honest, that's something i always
- Walter Bright (10/10) Jul 28 D already has namespaces:
- Quirin Schroll (25/35) Jul 29 Yeah, nice.
- ryuukk_ (9/19) Aug 03 Your example didn't work, i needed:
Saw this somewhere, and to be honest, that's something i always wanted to be able to do That may be something i could try to implement, sounds relatively easy ```D import c = sqlite3, miniz; ``` It means, symbols from sqlite3 and miniz are isolated into the c name Example: ```D c.sqlite3_init(); c.miniz_init(); ``` This is useful for ImportC, in case of symbol clashes with libc symbols from druntime for example https://dlang.org/spec/module.html#renamed_imports
Jul 22
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.
Jul 28
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: ```d 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`: ```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.
Jul 29
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: ```D struct c { public import sqlite3, miniz; } ``` I never thought it would work, thanks for sharing
Aug 03