digitalmars.D - deprecated alias
- Vathix (22/22) Jan 22 2005 Say I have a class named Fubar but then realize I didn't type it how I
- Ben Hinkle (10/20) Jan 25 2005 The std.stream module also has "deprecated aliases" for the old ReadErro...
Say I have a class named Fubar but then realize I didn't type it how I
wanted, so I wish to rename it to FooBar and deprecate Fubar, so I try
this:
class FooBar // Renamed from Fubar.
{
// ... tons of code ...
}
deprecated alias FooBar Fubar; // Keep old name for compatibility.
But Fubar isn't treated as deprecated because the alias only uses the
attributes of FooBar.
I believe that many people will want to do what I've attempted. I think
"deprecated", "private", "protected", "public" and "package" attributes
should apply to aliases and not inherit them from their base becuase those
attributes effect how the name is accessed, not the storage.
Here's an example,
class A { private static int a; }
class B { alias A.a b; }
B.b would be public static. static affected the storage of A.a, private
only affected the name. The current protection of B applied to B.b making
it public, but its storage is still static.
Thanks,
- Chris
Jan 22 2005
"Vathix" <vathix dprogramming.com> wrote in message
news:opsk1hd3vekcck4r tc3-ppp213.dialup.wzrd.com...
Say I have a class named Fubar but then realize I didn't type it how I
wanted, so I wish to rename it to FooBar and deprecate Fubar, so I try
this:
class FooBar // Renamed from Fubar.
{
// ... tons of code ...
}
deprecated alias FooBar Fubar; // Keep old name for compatibility.
But Fubar isn't treated as deprecated because the alias only uses the
attributes of FooBar.
The std.stream module also has "deprecated aliases" for the old ReadError
etc classes. It would be cool to be able to do more than just put a comment
in the code saying "this alias is deprecated please don't use it".
The alternative to using an alias by having both the old class ReadError and
the new class ReadException is that ReadError would never get thrown by the
code so it's useless for user code to try to catch it. So I expect in
practise many uses of "deprecated" would be for aliases instead of for
classes and other declarations.
Jan 25 2005








"Ben Hinkle" <bhinkle mathworks.com>