So why was typedef bad?

Ethan Watson via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 31 07:31:48 PDT 2016


On Wednesday, 31 August 2016 at 14:05:16 UTC, Chris Wright wrote:
> Specifying the default value for the type.

Alias has the same problem in this case.

> Making all typedefs from a base type implicitly convert to each 
> other without warning unless you're careful, which should be a 
> bug.

Which sounds like unique types constructed from other types are 
wanted instead of a typedef.

At the very least, if those were the actual problems, then it 
seems like std.typecons.Typedef has been transformed in to 
something other than a typedef simply for the crime of typedef 
being a subset of alias' functionality. Dropping typedef might 
make sense in favour of alias, but redirecting to something 
entirely different in the official documents... I know I just 
wasted some time evaluating its usefulness at least.

I'm making a distinction here between a typedef and a type mimic 
here because C++ interop is a big factor in our usage, so mixing 
up concepts between a language that's meant to make that easy is 
not ideal. Although looking at std.typecons.Typedef, I'd wonder 
if a typemimic language feature would have been a better way to 
go...


More information about the Digitalmars-d mailing list