C `restrict` keyword in D
jmh530 via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 4 08:03:27 PDT 2017
On Sunday, 3 September 2017 at 03:04:58 UTC, Uknown wrote:
> I just hope to have a nice discussion on this topic here.
>
> Thanks!
>
You might find interesting the reference capabilities of Pony:
https://tutorial.ponylang.org/capabilities/reference-capabilities.html
So with respect to restrict, there are a few that might be
relevant.
iso - can only have one reference
box - similar to const function parameters in D, can give out
read-only views
trn - sort of the reverse of const, it's like a write unique, you
can write to, but other people cannot
When I think of restrict, it's like telling the compiler that
these two pointers don't overlap their data. By contrast, if you
pass parameters to a function with these reference capabilities,
then it would be providing the compiler slightly different
information. If you pass iso, it tells the compiler that no other
variable pointers to this variable. If you use box (const),
you're telling the compiler that you won't modify it in this
function. If you use trn, you're telling the compiler that this
reference is the only way to modify the variable (i.e. another
variable in the function cannot modify it).
I'm not an expert on pony or anything, so I'm not sure how
complicated this makes things with aggregate types.
More information about the Digitalmars-d
mailing list