Re: bug in simplify_shallow

Karim Belabas <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <[email protected]>
* Ruud H.G. van Tol [2023-08-27 15:42]:
> 
> On 2023-08-27 14:58, Bill Allombert wrote:
> > [...]to be honest I did not remember that listput returned x and it is
> > not explicitly documented
> 
> ? ??listput
> listput( list,x,{n}):
> 
>    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.
> 
> So "returns the inserted element".

What "the inserted element" means is ambiguous in the context of PARI's
memory model. What the implementation does is return a direct pointer to
the new list entry, that inserted element being a clone of the input x.

What Bill and I suggested was to return "a copy of the inserted element"
instead. I don't really see a scenario where this would break
compatibility ... except this would make insertion about twice slower,
even in cases where the returned value is ignored.

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
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.