Virtual value types during compile-time for static type safety, static optimizations and function overloading.

Tamas via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 17 16:44:23 PDT 2015


On Friday, 17 July 2015 at 23:16:51 UTC, ZombineDev wrote:
> On Friday, 17 July 2015 at 23:15:31 UTC, ZombineDev wrote:
>> On Friday, 17 July 2015 at 21:20:41 UTC, Tamas wrote:
>>> Is there a solution that results the same static 
>>> optimizations, but has no runtime penalty, i.e. the functions 
>>> just operates with ints? (At least when compiled)
>>
>> Did you try looking at assembly generated by GDC or LDC with 
>> full optimizations? For example GDC does quite better than DMD 
>> for the proposed SafeInt type:
>> https://github.com/D-Programming-Language/phobos/pull/3389#issuecomment-119005595
>
> Also, see the table at the bottom of this comment:
> https://github.com/D-Programming-Language/phobos/pull/3389#issuecomment-117450524

Thanks for the pointers! My first priority a  performant library, 
secondary is a nice api, 3rd is a nice implementation. So that 
kind of rules put Amy degradation compared to ints. I used DMD, 
BTW.

I see no reason for the necessity of performance degradation. 
Essentially I just want to assign a similar qualifyer like const 
or immutable. They are checked and used at compile time, but 
erased for runtime. Same here.


More information about the Digitalmars-d-learn mailing list