Bill Allombert on Sun, 09 Jul 2023 11:02:21 +0200


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

Re: How to do t_INT bit operations?


On Thu, Jul 06, 2023 at 09:56:52AM +0200, Ruud H.G. van Tol wrote: > 
> On 2023-07-06 09:14, hermann@stamm-wilbrandt.de wrote:
> 
> > print(Str(gettime())"ms");
> 
> Just to nitpick:
> 
> Str() can be used as a string-concatter,
> but print() already does that itself.
> 
> AFAIK, these do about all the same:
> 
> print(Str(gettime())"ms");
> print(Str(gettime())ms);
> print(Str(gettime()),"ms");
> print(Str(gettime(),"ms"));
> print(Str(gettime()ms));
> print(gettime()ms);
> print(gettime(), "ms");

Point of order:
The comma-less form of print, Str, etc. should be considered as deprecated.
It is not entirely well-specificied.
(for example, in old GP versions 'print("a"+1)' gives 'a1')

When I wrote the new GP parser, I try to I kept it to avoid breaking old GP script,
but it should not be used for new script.

gettime() is also not recommended for new scripts because is not reentrant:

fm(n)=gettime();my(F=factor(2^n-1));print("time for ",n,":",gettime());F;
total(a,b)=gettime();for(n=a,b,fm(n));print("total time:",gettime());

We get
? total(200,210)
time for 200:4
time for 201:118
time for 202:462
time for 203:9
time for 204:0
time for 205:61
time for 206:151
time for 207:40
time for 208:14
time for 209:123
time for 210:0
total time:0

the total is wrong.
getabstime do not have this problem.
Maybe we should introduce a short-cut for [getabstime(), getwalltime()]
for parallel scripts.

Cheers,
Bill