in-parameter

spir denis.spir at gmail.com
Mon Nov 8 00:03:55 PST 2010


On Mon, 8 Nov 2010 18:13:54 +1000
"Daniel Murphy" <yebblies at nospamgmail.com> wrote:

> "spir" <denis.spir at gmail.com> wrote in message 
> news:mailman.157.1289146124.21107.digitalmars-d at puremagic.com...
> I'd like to know, aside user-side semantics, whether the compiler uses the 
> "in" qualifier for efficiency (pass arrays & structs by ref under the 
> hood?). Well, seems obvious, but there may be some hidden constraint I'm 
> unable to realise.
> 
> The spec states: "The in storage class is equivalent to const scope."
> 
> So, no, the compiler never implicitly uses ref to pass in parameters.
> 
> It could be possible with a rule like "pass by const ref if param.sizeof > x 
> bytes", but I think this would require an abi change. 
 
Then, if I pass a huge array/string or struct as "in", it is copied, right? Is the only way to avoid copy then to pass as ref?
I take the opportunity to ask about dynamic arrays. There is an internally pointed element-array, but is the array's interface (the kind of struct holding ptr & length) itself implicitely referenced?

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list