Re: reference parameters

"Ruud H.G. van Tol" <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <[email protected]>
On 2023-12-25 19:34, Bill Allombert wrote:
> On Mon, Dec 25, 2023 at 05:46:37PM +0100, Ruud H.G. van Tol wrote:
>> ? ??listput
>> listput( list,x,{n}):
> Not that this is a bug in the doc generator, the fixed version outputs
>    listput(~list,x,{n}):
>
> (~ is an unbreakable space in TeX).
>
>>     Sets the n-th element of the list list (which must be of type t_LIST)
>> equal to x. If n is omitted, or greater than the list length, appends x. The
>> function returns the inserted element.
>>
>>     ? L = List();
>>     ? listput(~L, 1)
>>     %2 = 1
>>     ? listput(~L, 2)
>>     %3 = 2
>>     ? L
>>     %4 = List([1, 2])
>>
>> Note the ~ L: this means that the function is called with a reference to L
>> and changes L in place.
>>
>> Is that explicit reference notation still relevant?
> Why not ?
>
> We allow to omit the "~" for backward compatibility only.
> This is mandatory for user-defined functions, because GP functions
> are not prototyped.


OK, I presumed that (it would be safe to make) both

listput( ~L, ... ) and listput( L, ... )do exactly the same. IOW, I 
expect that without the "~" the function is also "called with a 
reference to L and changes L in place." -- Ruud
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.