From Ada 2012
bearophile
bearophileHUGS at lycos.com
Thu May 3 17:34:34 PDT 2012
H. S. Teoh:
> This makes me wonder if such a thing is implementable in D
> without sacrificing efficiency.
Part of it is surely implementable. But if it's not in Phobos no
one will use it, and even if you put those things in Phobos, I
suspect you will not see a lot of D code in the wild using them.
> but the converse assignment will have a check,
> either runtime or compile-time if possible, to ensure the
> assigned value is within range).
Performing those tests at compile-time is currently generally not
possible in D because despite D has strong compile-time skills,
the code is run at compile time only if's evaluated in a static
context. At best you have to wrap your literals in some template
call, that calls CT code, but it's not natural coding and I am
not sure it's enough in all cases. There are ways to solve this
problem introducing some extra capabilities in D, in the last
years I have suggested several alternative ideas to do similar
things, but they were ignored every time.
Bye,
bearophile
More information about the Digitalmars-d
mailing list