Reference value of structs not optimized or inlined?
Walter Bright
newshound1 at digitalmars.com
Fri Aug 28 01:20:04 PDT 2009
Jeremie Pelletier wrote:
> Isn't it possible to make 'const ref S' or 'in S' generate the same
> machine code as 'in S*'? To me it would seem the semantics of the two
> are the same, with 'const S*' being useful syntax for C compatibility
> while 'in S' and 'const ref S' are both D syntax.
The thing about const is it only specifies a read only view of an
object, it does *not* specify that the referenced object will not
change. That is why pass by value cannot be "optimized" to be pass by
reference.
More information about the Digitalmars-d
mailing list