digitalmars.D.learn - import except one?
- Puming (18/18) Jun 26 2014 Hi,
- bearophile (7/16) Jun 26 2014 A similar idea is present in Haskell, but it was refused by
- Puming (9/28) Jun 26 2014 Thanks :-)
- Chris Nicholson-Sauls (6/39) Jun 27 2014 I wasn't in that particular discussion, but based on history, I
- sigod (3/3) Jun 26 2014 ```
- sigod (3/3) Jun 26 2014 Sorry, wrong one.
- sigod (7/7) Jun 26 2014 Dirty solution:
- Puming (8/15) Jun 26 2014 I'm currenly renaming my own symbol:
- Kapps (3/3) Jun 29 2014 A bit late, but you should also be able to do:
- Puming (3/6) Jun 29 2014 Thanks, so an alias or an additional single symbol import will
Hi, I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.process.Config, but I need many other symbols in scriptlike and std.process. What I want to achieve is to import ALL symbols from scriptlike EXCEPT std.process.Config, something like: ```d import scriptlike: !Config; ``` or rename it AND import all other symbols, to resolve the confliction. ```d import scriptlike: *, Cfg = Config; ``` I don't know how to achieve these effects, selective import and rename seems to only import the one I specified.
Jun 26 2014
Puming:I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.process.Config, but I need many other symbols in scriptlike and std.process. What I want to achieve is to import ALL symbols from scriptlike EXCEPT std.process.Config, something like: ```d import scriptlike: !Config;A similar idea is present in Haskell, but it was refused by Walter. The use of scriptlike is going to cause you similar problems, it's not for a fine tuning of imports. Bye, bearophile
Jun 26 2014
On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote:Puming:Thanks :-) I wander what was the rationale behind Walter's rejection. IMHO if we have a selective filter mechanism for imports, the complement exclude mechinism works as well. But of cause we are not that far yet, final, nothrow, pure and others don't have their complements either.I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.process.Config, but I need many other symbols in scriptlike and std.process. What I want to achieve is to import ALL symbols from scriptlike EXCEPT std.process.Config, something like: ```d import scriptlike: !Config;A similar idea is present in Haskell, but it was refused by Walter.The use of scriptlike is going to cause you similar problems, it's not for a fine tuning of imports.The problem is that we don't have a complete mechanism to fine tuning the imports. Selective filtering is only half of the cake.Bye, bearophile
Jun 26 2014
On Friday, 27 June 2014 at 05:26:09 UTC, Puming wrote:On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote:I wasn't in that particular discussion, but based on history, I imagine Walter's argument was probably along the lines of just use a static import for both modules and use either aliasing or FQN's for the symbols you need. That and inner scope imports.Puming:Thanks :-) I wander what was the rationale behind Walter's rejection. IMHO if we have a selective filter mechanism for imports, the complement exclude mechinism works as well. But of cause we are not that far yet, final, nothrow, pure and others don't have their complements either.I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.process.Config, but I need many other symbols in scriptlike and std.process. What I want to achieve is to import ALL symbols from scriptlike EXCEPT std.process.Config, something like: ```d import scriptlike: !Config;A similar idea is present in Haskell, but it was refused by Walter.The use of scriptlike is going to cause you similar problems, it's not for a fine tuning of imports.The problem is that we don't have a complete mechanism to fine tuning the imports. Selective filtering is only half of the cake.Bye, bearophile
Jun 27 2014
Sorry, wrong one. There seems no solution for this. So, you must use fully qualified name.
Jun 26 2014
Dirty solution: ``` import scriptlike; import your_module; import your_module : Config; ``` So, `Config` from your module will override one from scriptlike.
Jun 26 2014
On Thursday, 26 June 2014 at 16:02:15 UTC, sigod wrote:Dirty solution: ``` import scriptlike; import your_module; import your_module : Config; ``` So, `Config` from your module will override one from scriptlike.I'm currenly renaming my own symbol: ```d import scriptlike; import config : Cfg = Config; ``` Your solution works for me :-) Thanks
Jun 26 2014
A bit late, but you should also be able to do: import scriptlike; alias Config = std.process.Config;
Jun 29 2014
On Sunday, 29 June 2014 at 07:28:12 UTC, Kapps wrote:A bit late, but you should also be able to do: import scriptlike; alias Config = std.process.Config;Thanks, so an alias or an additional single symbol import will shadow the earlier imported symbol. That's fine for me :-)
Jun 29 2014