[Issue 4533] Ban public aliases to private symbols
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 30 13:52:38 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4533
--- Comment #3 from Tomasz Sowiński <tomeksowi at gmail.com> 2010-07-30 13:52:33 PDT ---
(In reply to comment #2)
> The problem is, attributes in D are not as in Java, they can be applied to a
> lot of symbols, like:
>
> ---
> private int j;
>
> public:
>
> int i;
> // another bunch of stuff
> alias j k;
> ---
>
> Should the compiler complain at that alias? What about this:
Of course, accessed from a different module it fails like my example.
> ---
> void f() {}
>
> extern (C):
>
> void g() {}
> // another bunch of stuff
> alias f h;
> ---
>
> Should the compiler complain about non-sense extern (C) alias? What about
> const? You can "revert" the extern (C) with extern (D) and public with private,
> but there is no "mutable" to revert const.
Yes, it should complain. I think it doesn't matter that there's no "revert". If
it's wrong then apply a different attribute or move it outside the attribute
scope or whatever, just fix it :)
> This is a bigger problem on how attributes work in D, and there were some
> threads about the issue.
>
> And I'm not saying I'm against issuing error when attributes are applied to
> things that doesn't make sense, I'm just sharing some problems about the issue
> :)
I wasn't aware of problems with attributes in general, thanks for bringing this
up. That just made me try:
const alias char C; // C is char, not const(char)
Also, you can alias members from *outside*, which seems pointless and weird:
class A {
void foo() {}
}
alias A.foo goo;
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list