Fixing enum names in Phobos

Jonathan M Davis jmdavisProg at gmx.com
Thu Aug 4 08:59:11 PDT 2011


On Thursday 04 August 2011 07:33:55 Andrei Alexandrescu wrote:
> On 8/4/11 12:16 AM, Jonathan M Davis wrote:
> > So, does anyone actually have an opinion on this? Should we fix the
> > names or not?
> 
> We should probably fix the names. A migration path is to simply keep
> both names for a year or so and remove documentation for old names. For
> example:
> 
> enum Variadic {
>    no, /// doc
>    NO = no,
>    c, /// doc
>    C = c,
>    d, /// doc
>    D = d,
>    typesafe, /// doc
>    TYPESAFE = typesafe
> }

Except that that breaks any code that does something like 
EnumMembers!Variadic. For some enums, that probably wouldn't break anyone's 
code. But you can't know for sure whether anyone is using EnumMembers on a 
particular enum.  It would also change the values of the enums, which could 
also break code, which wouldn't be an issue for some enums, but it might be 
for some (and someone could always have been foolish and relied on their exact 
values).

So, simply adding enum values could silently break code. Fixing the enum names 
without attempting a migration path, on the other hand, would result in errors 
where the spellchecker would tell the programmer exactly what to do. It would 
be a bit annoying, but all they'd have to do is go fix their spelling in the 
cases where they used those enums and then they'd be done. Not to mention, I 
don't think that we can actually deprecate enums anyway, so we'd have to go 
straight from "scheduled for deprecation" to removed (so, I guess that it 
would be "schedule for removal" instead).

In this particular case, I don't think that you can really provide a clean 
migration path. The best that you could do would be to replace all of the 
enums with duplicate enums whith different names and fixed names for their 
values. But then you'd end up with a bit of a mess with stuff having to deal 
with both enums, and it may not always be possible for something which was 
using one enum to then have two versions - one for the old enum type and one 
for the new.

I think that it would be far better to just fix the names immediately. It's not 
great, but I don't think that we have much choice if we're going to fix them - 
which is part of why I didn't just go and fix the names.

- Jonathan M Davis


More information about the Digitalmars-d mailing list