C `restrict` keyword in D

Uknown via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 5 02:02:34 PDT 2017


On Monday, 4 September 2017 at 14:28:14 UTC, Dukc wrote:
> On Sunday, 3 September 2017 at 03:04:58 UTC, Uknown wrote:
>> In C, the `restrict` keyword implies that 2 or more pointer 
>> arguments in a function call do not point to the same data.
>
> I really don't see where the restrict keyword is needed at all, 
> neither in C nor in D. If you want to imply to the compiler 
> that there is no need to reload the pointed data between uses, 
> just assign it to a local.

You can see the second answer on this Stack overflow question[1]. 
It explains how `restrict` can be used in C to tell the compiler 
that there won't be any aliasing between two pointers, and the 
optimizations the compiler can do, given this knowledge.

[1] 
https://stackoverflow.com/questions/745870/realistic-usage-of-the-c99-restrict-keyword#745877


More information about the Digitalmars-d mailing list