C `restrict` keyword in D
Johan Engelen via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 4 11:03:51 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.
It's need for auto-vectorization, for example.
I would support an LDC PR for adding a magic UDA to be able to
attach 'restrict' with C-semantics to function parameters. E.g.
```
// add restrict to parameters 1 and 2
void foo(int, int*, int*) @restrict(1,2)
```
-Johan
More information about the Digitalmars-d
mailing list