On 4/30/17 7:59 PM, Jonathan Marler wrote:
On Sunday, 30 April 2017 at 23:44:32 UTC, Steven Schveighoffer wrote:
On 4/30/17 7:35 PM, Jonathan Marler wrote:
Any reason why "alias this" doesn't work at the module level? If I
recall correctly, a module is really just a "class" under the hood, but
when I tried to use it I got:
Error: alias this can only be a member of aggregate, not module
<module-name>
public import is to modules as alias this is to structs/classes :)
They're actually different.
//
// File: mymodule.d
//
module mymodule;
struct Foo
{
int bar;
void baz();
}
__gshared Foo foo;
alias foo this; // using "alias this" on a module
So you want to alias a struct to a module? That's different than what I
thought, I thought you wanted to alias one module's members into another.
I can't see a reason why it couldn't be added as a feature. I admit I'm
not seeing the benefit though.
You could simulate this via a mixin. e.g.:
void baz()
{
foo.baz;
}
@property ref bar()
{
return foo.bar;
}
-Steve