Re: calling by reference

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <Z9BWfe8fCp8yG_bj@seventeen>
On Tue, Mar 11, 2025 at 04:00:13PM +0100, Ruud H.G. van Tol wrote:
> On 2025-03-11 15:46, Bill Allombert wrote:
> > On Tue, Mar 11, 2025 at 03:27:28PM +0100, Ruud H.G. van Tol wrote:
> > > The user manual states:
> > > 
> > > 2.7.2 [...] If an argument is prefixed by a tilde ~ in the function
> > > declaration and the call, it is passed by reference. (If either the
> > > declaration or the call is missing a tilde, we revert to a call by value.)
> > Actually it depends if the variable is lexically or dynamically scoped.
> > Please do not forget the ~!
> 
> But with a dynamically scoped L:
> 
> ? L=List([1,2,3]); print(L); listinsert(L,42,1); print(L); listpop(L,2);
> print(L);
> List([1, 2, 3])
> List([42, 1, 2, 3])
> List([42, 2, 3])
> 
> the missing ~ appears to work fine.

The reason is that listinsert and listpop are C functions, which are
prototyped.
But please really do not omit the ~, at some point PARI will require it.

Cheers,
Bill.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.