Charles Greathouse on Fri, 22 Jun 2012 17:23:40 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Assigning closure names |
How is Pi handled now (in 2.6.0)? One still types "Pi" rather than Pi()". Charles Greathouse Analyst/Programmer Case Western Reserve University On Fri, Jun 22, 2012 at 11:13 AM, Karim Belabas <Karim.Belabas@math.u-bordeaux1.fr> wrote: > * Dirk Laurie [2012-06-22 16:54]: >> Consider the following GP session. >> >> ? type(Ser) >> %1 = "t_CLOSURE" >> ? type(Vec) >> %2 = "t_VEC" >> >> Deduction: when a built-in function may be called >> with an empty parameter list, the bare name is >> interpreted as a function call, not as a reference >> to the closure. > > Originally an old misguided design decision of mine: I had decided to > allow 'f' as a shortcut for 'f()'. In the old interpretor -- before > Bill's rewrite --, this had the small advantage of allowing 'Pi' as a > shortcut for 'Pi()'. > > Note that your specific example only works in pari-stable. In > pari-2.6.*, Vec() has a mandatory argument. > >> Is there a way to access the closure "Vec" as a Pari object? > > I do not see any simple way, maybe Bill will have a clever idea. > Here's a close variant > > (17:06) gp > f = x->Vec(x); > (17:06) gp > type(f) > %2 = "t_CLOSURE" > (17:06) gp > f(x + 2) > %3 = [1, 2] > > There's a minor difference, though: f has a mandatory argument, contrary > to (pari-stable-)Vec. > > > This also works without arguments: > > (17:09) gp > f = ()->Pi > %4 = ()->Pi > (17:11) gp > f() > %5 = 3.1415926535897932384626433832795028842 > > Cheers, > > K.B. > -- > Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 > Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 > 351, cours de la Liberation http://www.math.u-bordeaux1.fr/~belabas/ > F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP] > ` >