help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: avoiding copying arguments by value when calling a function


From: Sergei Steshenko
Subject: Re: avoiding copying arguments by value when calling a function
Date: Tue, 21 Aug 2012 03:55:25 -0700 (PDT)


--- On Mon, 8/20/12, Jordi Gutiérrez Hermoso <address@hidden> wrote:

> From: Jordi Gutiérrez Hermoso <address@hidden>
> Subject: Re: avoiding copying arguments by value when calling a function
> To: "Sergei Steshenko" <address@hidden>
> Cc: "Carnë Draug" <address@hidden>, address@hidden
> Date: Monday, August 20, 2012, 7:29 AM
> On 20 August 2012 10:25, Sergei
> Steshenko <address@hidden>
> wrote:
> > On Mon, 8/20/12, Carnë Draug <address@hidden>
> wrote:
> >> On 20 August 2012 14:55, Sergei Steshenko <address@hidden>
> >> wrote:
> > [snip]
> >> Seems the manual
> >> http://www.gnu.org/software/octave/doc/interpreter/Call-by-Value.html
> >> is incorrect.
> > [snip]
> >> Carnë
> >>
> >
> > FTM: "each argument in a function call is evaluated and
> assigned to
> > a temporary location in memory before being passed to
> the function."
> >
> > well, in the light of given explanations indeed
> incorrect. i.e. bug
> > in documentation.
> 
> COWs look like pass by value if you ignore memory
> allocation. From the
> user's point of view, a COW *is* pass by value. COWs are
> supposed to
> be a transparent optimisation. This is why the manual
> further down
> says,
> 
>     Even though Octave uses pass-by-value
> semantics for function
>     arguments, values are not copied
> unnecessarily.
> 
> I don't think there is a documentation bug.
> 
> - Jordi G. H.
> 

"if you ignore memory allocation" - does memory allocation happen ?

If yes, is it ultimately a system call ('malloc', etc.) ?

If yes, then it slows down execution - because of the system call.

Thanks,
  Sergei.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]