| Ilya Zakharevich on Thu, 30 May 2024 01:14:13 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Using builtin PARI operators in gp |
On Sun, May 12, 2024 at 09:56:46AM +0200, Karim Belabas wrote:
> * Ilya Zakharevich [2024-05-12 05:06]:
> > Up to some extent, one can “reach” the builtin PARI operators in gp:
> There is one already:
>
> ? alias(plus, "_+_")
> ? fold(plus, [1,2,3])
Oups, I did not even realize that fold() is already implemented! 😆
I do not know: should not
fold("_+_", [1,2,3])
“just work”? (Likewise for other uses of anonymous functions?)
> %2 = 6
>
> It's even (sort of) documented:
Hmm:
Alias expansion is performed directly by the internal GP
compiler. Note that since alias is performed at
compilation-time, it …
I think this is not very comprehensible. Probably, it means something
like:
When the internal compiler of PARI compiles an anonymous
subroutine (or other code) and encounters a use of “an aliased
symbol”, an alias expansion happens immediately. Hence there
is no run time penalty.
Additionally, I have no clue what alias() is actually doing. For
example, is
alias(SIN, sin)
a “glorified version” of SIN = sin, or of SIN = builtin::sin? What
about
alias(SIN, "sin")
? Or: is
Sin = sin; alias(SIN, Sin)
(ALWAYS) the same as alias(SIN, sin) ?
Thanks,
Ilya