memcpy() comparison: C, Rust, and D

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 1 22:11:07 PST 2017


Walter Bright <newshound2 at digitalmars.com> wrote:
> On 2/1/2017 9:22 AM, Tobias Müller wrote:
>> You wouldn't use memcpy but just assign the slices.
> 
> I clearly made a mistake in this example. I wanted to show how a compiler learns 
> things from the declaration by using a very familiar declaration. But it keeps 
> getting diverted into what people (and some compilers) "know" about memcpy that 
> is not in the declaration.

I also showed you how memcpy could look like in Rust, I think it's only
fair to also point out that this would be fairly unidiomatic.

Apart from that, the entire point of building a safe wrapper around an
unsafe FFI function is to exploit additional knowledge that is not present
in the C declaration, but only in documentation. It's not relevant if that
wrapper is built into the language or a library function.
After all, to write the D declaration you also had to exploit that
knowledge once.



More information about the Digitalmars-d mailing list