www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - Grouped named import

reply ryuukk_ <ryuukk.dev gmail.com> writes:
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;
```


https://dlang.org/spec/module.html#renamed_imports
Jul 22
next sibling parent reply Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 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;
 ```


 https://dlang.org/spec/module.html#renamed_imports
Is it equivalent to this? ```d import c = sqlite3; import miniz; ``` If yes, this requires no DIP. But honestly, the reason why D requires separate import statements for renaming stuff is that it’s much clearer.
Jul 22
next sibling parent reply Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Monday, 22 July 2024 at 12:06:52 UTC, Quirin Schroll wrote:
 On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 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;
 ```


 https://dlang.org/spec/module.html#renamed_imports
Is it equivalent to this? ```d import c = sqlite3; import miniz; ``` If yes, this requires no DIP. But honestly, the reason why D requires separate import statements for renaming stuff is that it’s much clearer.
I just realized one can do this: ```d import x = std.stdio; import x = std.file; ``` If that is intended, it’s especially important for clarity that separate import statements are required.
Jul 22
next sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 12:29:24 UTC, Quirin Schroll wrote:
 I just realized one can do this:
 ```d
 import x = std.stdio;
 import x = std.file;
 ```

 If that is intended, it’s especially important for clarity that 
 separate import statements are required.
I didn't know it was possible, that's good to know, no need for that DIP then, case is closed, thanks!
Jul 22
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 12:47:34 UTC, ryuukk_ wrote:
 On Monday, 22 July 2024 at 12:29:24 UTC, Quirin Schroll wrote:
 I just realized one can do this:
 ```d
 import x = std.stdio;
 import x = std.file;
 ```

 If that is intended, it’s especially important for clarity 
 that separate import statements are required.
I didn't know it was possible, that's good to know, no need for that DIP then, case is closed, thanks!
I just tested, it doesn't work... `onlineapp.d(2): Error: import `onlineapp.x` conflicts with import `onlineapp.x` at onlineapp.d(1)`
Jul 22
parent Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Monday, 22 July 2024 at 12:49:29 UTC, ryuukk_ wrote:
 On Monday, 22 July 2024 at 12:47:34 UTC, ryuukk_ wrote:
 On Monday, 22 July 2024 at 12:29:24 UTC, Quirin Schroll wrote:
 I just realized one can do this:
 ```d
 import x = std.stdio;
 import x = std.file;
 ```

 If that is intended, it’s especially important for clarity 
 that separate import statements are required.
I didn't know it was possible, that's good to know, no need for that DIP then, case is closed, thanks!
I just tested, it doesn't work... `onlineapp.d(2): Error: import `onlineapp.x` conflicts with import `onlineapp.x` at onlineapp.d(1)`
It doesn’t work for module-scope imports, as you point out, but it’s not diagnosed for function-scope imports. [Filed a bug.](https://issues.dlang.org/show_bug.cgi?id=24672)
Jul 23
prev sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 12:29:24 UTC, Quirin Schroll wrote:
 If that is intended, it’s especially important for clarity that 
 separate import statements are required.
Invalid argument, goal is conciseness Your example is confusing because of duplication Mine is simple and clear, i suggest you read about other languages who successfully adopted similar feature Zig and Typescript for example
Jul 22
prev sibling next sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 12:06:52 UTC, Quirin Schroll wrote:
 On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 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;
 ```


 https://dlang.org/spec/module.html#renamed_imports
Is it equivalent to this? ```d import c = sqlite3; import miniz; ``` If yes, this requires no DIP. But honestly, the reason why D requires separate import statements for renaming stuff is that it’s much clearer.
No, i specifically wrote grouped, there might be a better word for it 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
Jul 22
prev sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 12:06:52 UTC, Quirin Schroll wrote:
 On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 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;
 ```


 https://dlang.org/spec/module.html#renamed_imports
Is it equivalent to this? ```d import c = sqlite3; import miniz; ``` If yes, this requires no DIP. But honestly, the reason why D requires separate import statements for renaming stuff is that it’s much clearer.
In retrospect, you clearly do not understand both the feature, the suggestion and the point of the feature This is sad
Jul 22
parent ryuukk_ <ryuukk.dev gmail.com> writes:
 moderator, please delete this thread, it is spam
Jul 22
prev sibling next sibling parent reply Dennis <dkorpel gmail.com> writes:
On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 ...
I deleted some posts here and a duplicate thread. ryuukk_ When your DIP Idea is not understood, please clarify it in the same thread. It's the DIP author's responsibility to convey their idea to others. Do not take it out on the person giving feedback, and do not try to replace the thread with a new one. I understand you don't want to the thread to be cluttered with initial misunderstandings, but this forum is not like git where you can easily amend and rebase if you mess up. If you want to avoid this situation, elaborate more in your initial DIP idea post with complete examples and explanations. Let's keep this thread about the DIP idea itself now, thanks!
Jul 22
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Monday, 22 July 2024 at 15:27:35 UTC, Dennis wrote:
 On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 ...
I deleted some posts here and a duplicate thread. ryuukk_ When your DIP Idea is not understood, please clarify it in the same thread. It's the DIP author's responsibility to convey their idea to others. Do not take it out on the person giving feedback, and do not try to replace the thread with a new one. I understand you don't want to the thread to be cluttered with initial misunderstandings, but this forum is not like git where you can easily amend and rebase if you mess up. If you want to avoid this situation, elaborate more in your initial DIP idea post with complete examples and explanations. Let's keep this thread about the DIP idea itself now, thanks!
I asked for you to remove my thread, so can you please remove my thread? thanks
Jul 23
parent reply Dennis <dkorpel gmail.com> writes:
On Tuesday, 23 July 2024 at 10:14:18 UTC, ryuukk_ wrote:
 I asked for you to remove my thread, so can you please remove 
 my thread? thanks
We delete posts when they contain personal insults (both explicit and underhanded) or when they are off-topic to the point of derailing the thread. We can delete a post by special request from the author, but in the case of this thread, Quirin made replies perfectly following the DIP forum guidelines, which we won't delete without a good reason. What I can do is informally close the thread: From here on out, subsequent replies to this thread will be deleted.
Jul 23
parent ryuukk_ <ryuukk.dev gmail.com> writes:
On Tuesday, 23 July 2024 at 11:11:42 UTC, Dennis wrote:
 On Tuesday, 23 July 2024 at 10:14:18 UTC, ryuukk_ wrote:
 I asked for you to remove my thread, so can you please remove 
 my thread? thanks
We delete posts when they contain personal insults (both explicit and underhanded) or when they are off-topic to the point of derailing the thread. We can delete a post by special request from the author, but in the case of this thread, Quirin made replies perfectly following the DIP forum guidelines, which we won't delete without a good reason. What I can do is informally close the thread: From here on out, subsequent replies to this thread will be deleted.
Brother, i ask you again to remove my content from your website, why is it hard for you to understand that i want my messages to be removed Have you heard of GDPR?
 What I can do is informally close the thread:
No, what you will do is remove this thread, again, i ask you to please remove my thread
Jul 23
prev sibling parent Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Monday, 22 July 2024 at 11:23:51 UTC, ryuukk_ wrote:
 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;
 ```


 https://dlang.org/spec/module.html#renamed_imports
Now that I understand what you mean, I suggest the following syntax: ```d import c { sqlite3, miniz } ``` Essentially, you propose an `import` construct that creates a namespace. If you want a suggestion for the DIP name: _Import Namespaces_ Honestly, I like this. It’s essentially equivalent to creating a module named `c` and `public import`ing all the symbols listed in the braces. (Maybe this doesn’t require a DIP, I don’t know.)
Jul 23