User Defined Attributes

bearophile bearophileHUGS at lycos.com
Tue Nov 13 17:22:34 PST 2012


Walter Bright:

(I know this sub-discussion is a bit OT, but not too much, and I 
think it's not wasted time.)

>But D does not require that. It's up to the programmer.<

Oh, but the use of "newtype" is not required in Haskell; 
programmers are free to use it, or to use normal basic types as 
Int, Integer, Double, etc. Probably newtype is not that useful in 
little programs. And even in larger programs it's better to not 
use it too much.

And the use of that "using" in a newtype is not standard Haskell, 
it's a GHC compiler extension to the language, that you have to 
ask with a compilation switch or an annotation inside the code. 
That "using" attached to a newtype allows you to both use a 
newtype like its base type (like the underlying Int), or to 
choose where the newtype must not do what its base type is able 
to do (this technically means what typeclasses it conforms to or 
not). I think D Typedef should allow something similar, despite D 
has no typeclasses. As an example, currently D Typedef is kind of 
useless if you want to use it to define a new array type.

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list