null and type safety

Hxal hxal at freenode.irc
Thu Nov 6 02:00:18 PST 2008


Walter Bright wrote:
> If that cannot be done in D, then D needs some design improvements.
> Essentially, any type should be "wrappable" in a struct which can alter
> the behavior of the wrapped type.
> 
> For example, you should also be able to create a ranged int that can
> only contain values from n to m:
> 
> RangedInt!(N, M) i;
> 
> Preserving this property of structs has driven many design choices in D,
> particularly with regards to how const fits into the type system.

Does that mean we're getting implicit cast overloads?
Because without RangedInt!(N, M).opImplicitCastFrom(int i)
you can't pass int values to functions accepting RangedInt
instances. You can't pass a different RangedInt!(X, Y) either.
It defeats the purpose of implicit range checking if you
have to write litanies like foo(RangedInt!(1,10).check(i))
just to call a function.

Sorry to jump the topic like that, but last time I asked
my thread got hijacked. :P




More information about the Digitalmars-d mailing list