Create custom data types

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 29 10:52:03 PDT 2015


On Wednesday, 29 April 2015 at 17:17:07 UTC, Dennis Ritchie wrote:
> Hi,
> Is it possible to create simple D user-defined data types 
> without the use of classes and other OOP?
>
> For example, in Ada is done as follows:
>
> -----
> type balance is new Integer range -32_000 .. 32_000;


I think you can use struct for this together with opAssign etc. 
functions in it. So, you can define a new variable that uses 
3-bytes in memory example. But for 32_000, I think limitations 
are based on processor, and not the language.


More information about the Digitalmars-d-learn mailing list