Supertypes, subtypes, and more

Justin Whear via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 25 13:59:00 PDT 2014


On Wed, 25 Jun 2014 15:33:14 +0000, bearophile wrote:
 
> I think where you expect a String you can send a Social_Security_Number,
> but where it expects a Social_Security_Number it doesn't accept a
> String. (The Dynamic_Predicate and Static_Predicate of modern Ada allow
> to perform such restrictions.) So I think there are some analogies with
> OOP.
> 
> I'd like to do something like this in D, with structs/values.
> 
> Bye,
> bearophile

Does this do everything you're looking for?
http://dpaste.dzfl.pl/50531f5b1356

The only potential problem I see is that the invariant presumably won't 
be compiled in when in release mode.


More information about the Digitalmars-d mailing list