Re: question on encapsulating format for a gp pari function

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <aHz10xSaZdFmz6ju@seventeen>
On Mon, Jun 30, 2025 at 09:14:03AM -0700, American Citizen wrote:
> Hello:
> I write my gp pari functions as like this
> 
> {fun(a)=
> my(b);
> b=a;
> return(b);
> }
> 
> But recently I noticed that someone who I highly respect writes in this way.
> fun(a)=
> {
>   my(b);
>   b=a;
>   return(b);
> }
> 
> What is the preferred way of doing this? Is the second to allow the function
> signatures to be visible?

As far as GP is concerned this is equivalent, since GP ignore spaces.
The second form is more modern-looking.
In general we omit return(), which is not necessary.

We provide a tutorial covering this topic:
https://pari.math.u-bordeaux.fr/Events/PARI2019b/talks/prog.pdf


Very old GP scripts (for PARI 1.39.15) were written this way

{fun(a,
     b)=
  b=a;
  b;
}
because local() did not exist yet.

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.