digitalmars.D - Issue 11666: "Separation of platforms", and module declaration
- Mike (24/24) Aug 08 2014 I'm exploring a technique in D that may help provide an alternate
- H. S. Teoh via Digitalmars-d (17/33) Aug 08 2014 [...]
I'm exploring a technique in D that may help provide an alternate solution to issue 11666 - Separate each platform's port to its own folder [1]. The idea is to have the same module declaration in multiple files, but guarded by `version`. // port_linux.d version (linux): module port; // port_windows.d version (Windows): module port; Unfortunately, this fails to compile with the following error: Error: Declaration expected, not 'module' So, it appears the compiler currently requires the module declaration to appear first in the file. A related issue is 12567 - Modules can't be marked deprecated [2]. * Is this an arbitrary limitation, or is there a technical reason for it? * Would a PR allowing `version()`, attributes, etc... to appear before the module declaration have any unintended consequences? Thanks in advance for your thoughtful replies, Mike [1] https://issues.dlang.org/show_bug.cgi?id=11666 [2] https://issues.dlang.org/show_bug.cgi?id=12567
Aug 08 2014
On Sat, Aug 09, 2014 at 05:08:09AM +0000, Mike via Digitalmars-d wrote:I'm exploring a technique in D that may help provide an alternate solution to issue 11666 - Separate each platform's port to its own folder [1]. The idea is to have the same module declaration in multiple files, but guarded by `version`. // port_linux.d version (linux): module port; // port_windows.d version (Windows): module port; Unfortunately, this fails to compile with the following error: Error: Declaration expected, not 'module'[...] What about this: // port.d module port; version(linux) public import port_linux; version(Windows) public import port_windows; // port_linux.d ... // Linux implementation here // port_windows.d ... // Windows implementation here ? T -- LINUX = Lousy Interface for Nefarious Unix Xenophobes.
Aug 08 2014
On Saturday, 9 August 2014 at 05:38:33 UTC, H. S. Teoh via Digitalmars-d wrote:On Sat, Aug 09, 2014 at 05:08:09AM +0000, Mike via Digitalmars-d wrote:Doesn't that introduce a new namespace?The idea is to have the same module declaration in multiple files, but guarded by `version`. // port_linux.d version (linux): module port; // port_windows.d version (Windows): module port; Unfortunately, this fails to compile with the following error: Error: Declaration expected, not 'module'[...] What about this: // port.d module port; version(linux) public import port_linux; version(Windows) public import port_windows; // port_linux.d ... // Linux implementation here // port_windows.d ... // Windows implementation here
Aug 08 2014
On Saturday, 9 August 2014 at 06:00:05 UTC, Mike wrote:On Saturday, 9 August 2014 at 05:38:33 UTC, H. S. Teoh viaIt will have "dual" namespace - both `port.symbol` and `port_linux.symbol` will be valid qualified paths (though fullyQualifiedName!symbol is likely to show the latter)What about this: // port.d module port; version(linux) public import port_linux; version(Windows) public import port_windows; // port_linux.d ... // Linux implementation here // port_windows.d ... // Windows implementation hereDoesn't that introduce a new namespace?
Aug 09 2014