Why is this D code slower than C++?

Dave Dave_member at pathlink.com
Thu Jan 18 05:44:25 PST 2007


%u wrote:
> Lionello Lunesu Wrote:
>> No, it can't.. Passing a struct by ref will result in unexpected 
>> behavior if it changes in some other thread. As always, the default 
>> should be safe no matter what, and that means copying the struct's contents.
> That's right for structs.
>  
>> I guess a new modifier like "byref" is the only option..
> "byref" is the wrong word here because the real meaning is "value parameter that is not assigned to". Thus "const" is right and already reserved.

That's Ok as long as all D compilers will most likely rightly determine whether or not to pass the 
const byref as an optimization. Since this is probably not realistic, I think something like 'byref' 
is called for. There's been a great debate as to whether or not 'const' is actually enforceable, and 
unless it is, it would not really be of any value as an optimizer hint (like const can't be counted 
on as an optimizer hint for C++).


More information about the Digitalmars-d-learn mailing list