struct, ref in, and UFCS

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 1 03:21:06 PDT 2014


On Tuesday, 1 July 2014 at 07:53:27 UTC, bearophile wrote:
> Puming:
>
>> is this a good practice to use `ref in` with structs instead 
>> of traditional pointer syntax (which does not play well with 
>> UFCS though) ? Is there any perfomance implications with `ref 
>> in`? I tried that it does not seem to copy the parameter value,
>
> A "ref" is equivalent to a pointer that can't be null, so 
> performance is the same as using a pointer (so it's good for 
> larger structs, but not good if your struct is tiny).
>
> Bye,
> bearophile

Thanks for the clarification. Now I can safely assume ref is 
better than pointer here because it plays nicely with UFCS.


More information about the Digitalmars-d-learn mailing list