Denis Simon on Tue, 04 Jul 2023 15:53:07 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Question on "assert()" implementation in GP


Hi Hermann,

Instead of ##, you can use gettime() and getabstime().

Denis SIMON.

----- Mail original -----
> De: hermann@stamm-wilbrandt.de
> À: "pari-users" <pari-users@pari.math.u-bordeaux.fr>
> Envoyé: Mardi 4 Juillet 2023 14:54:37
> Objet: Re: Question on "assert()" implementation in GP

> On 2023-07-04 13:20, hermann@stamm-wilbrandt.de wrote:
>> Is there some other mechanism than "quit()" that can be used to
>> achieve stopping in "gp < script" mode?
>> 
>> 
> I reread Bill's referenced email on "gp < script", and the reason was
> using ## to report time of last command. That is only possible with "gp
> < script".
> 
> But without "##" and probably other features, "gp script" does what I
> want, abort on assert.
> And no "quit()" is needed, "error()" aborts itself.
> 
> $ diff asst.gp asst.2.gp
> 1c1
> < assert(b, v, s) = { if(!(b), error(Str(v) " " Str(s))); quit }
> ---
>> assert(b, v, s) = { if(!(b), error(Str(v) " " Str(s))) }
> $
> $ gp -q asst.2.gp
>   ***   at top-level: assert(x==5,x,"wrong")
>   ***                 ^----------------------
>   ***   in function assert: if(!(b),error(Str(v)" "Str(s)))
>   ***                               ^-----------------------
>   ***   user error: 4 wrong
>   ***   Break loop: type 'break' to go back to GP prompt
> break>
> 
> 
> So the question remaining is:
> How can I measure runtime of a GP command in "gp script" mode, since
> "##" does not work in that mode?
> 
> 
> Regards,
> 
> Hermann.