System programming in D (Was: The God Language)
Walter Bright
newshound2 at digitalmars.com
Thu Dec 29 12:00:12 PST 2011
On 12/29/2011 11:47 AM, Walter Bright wrote:
> On 12/29/2011 3:19 AM, Vladimir Panteleev wrote:
>> I'd like to invite you to translate Daniel Vik's C memcpy implementation to D:
>> http://www.danielvik.com/2010/02/fast-memcpy-in-c.html
>
> Challenge accepted.
This does compile, though I did not test or benchmark it.
Examining the assembler output, it inlines everything except COPY_SHIFT,
COPY_NO_SHIFT, and COPY_REMAINING. The inliner in dmd could definitely be
improved, but that is not a problem with the language, but the implementation.
Continuing in that vein, please note that neither C nor C++ require inlining of
any sort. The "inline" keyword is merely a hint to the compiler. What inlining
takes place is completely implementation defined, not language defined.
The same goes for all those language extensions you mentioned. Those are not
part of Standard C. They are vendor extensions. Does that mean that C is not
actually a systems language? No.
I wish to note that the D version semantically accomplishes the same thing as
the C version without using mixins or CTFE - it's all straightforward code,
without the abusive preprocessor tricks.
More information about the Digitalmars-d
mailing list