Is it's correct to say that ALL types that can grow are place on heap?
drug2004 at bk.ru
Tue Sep 11 12:07:14 UTC 2018
11.09.2018 13:11, Timoses пишет:
> Is this why it is said that passing parameters by value can be more
> Cause for a ref parameter it would require passing the address which
> would require to be allocated?
> Aww, I really would love some insights into function parameter passing.
> Why is it said that passing by value can be more efficient at times?
> Since it is also said that passing large structs by value can be
> expensive, why then would it not be cheaper to ALWAYS pass everything by
> reference? What mechanism is behind the scene that follows one to reason
> that sometimes passing by value is less expensive?
> I get that passing an int by reference would cause indirections which
> need to be resolved whereas passing the int by value is just one copy (I
> This topic kinda seemed fit for my question that I was carrying around
> for some time.
If data size is less or equal to total size of available registers (that
can be used to pass values) than passing by value is more efficient.
Passing data with size less than register size by reference isn't
efficient because you pass pointer (that has register size) and access
memory using it.
More information about the Digitalmars-d-learn