inout verses ref

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Mar 10 09:27:05 PDT 2008


"Spacen Jasset" <spacenjasset at yahoo.co.uk> wrote in message 
news:fr3m65$bse$1 at digitalmars.com...
> These two attributes seem to do similar things. Infact, do they do the 
> same thing? Or is it that in the case of ref a reference is passed, and in 
> the case of inout a value is copies in via the stack and then passed back 
> out?
>
> Why would one use inout instead of ref since inout must be slower for 
> larger objects.

They are exactly the same.  There is no semantic difference, only what word 
is used.

'ref' was introduced in anticipation of reference return values or possibly 
even general reference types.  Having an 'inout' return value or an 'inout' 
integer doesn't make much sense other than with parameters, but 'ref' does. 




More information about the Digitalmars-d-learn mailing list