Bug in (timer 'symbol)

Q&A's, tips, howto's
Locked
pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Bug in (timer 'symbol)

Post by pjot »

Hi,

According to the manual, (timer 'symbol) should return the elapsed time of the timer with newLisp 8.6.1, which I am currently using.

Code: Select all

(define (callback)
	(println "Callback...")(set 'done true))

(timer 'callback 5.0)

(while (not done)
	(println (timer 'callback))
	(sleep 100))
So the result of this program should be a climbing series of values. This is OK in Windows. In Linux however, this is the result:
peter@Solarstriker:~/programming/newlisp$ ./bla.lsp
0
1.89
1.78
1.67
1.56
1.45
1.34
1.23
1.12
1.01
2.9
2.79
2.68
2.57
2.46
2.35
2.24
2.13
2.02
3.91
3.8
3.69
3.58
3.47
3.36
3.25
3.14
3.03
4.92
4.81
4.7
4.59
4.48
4.37
4.26
4.15
4.04
5.93
5.82
5.71
5.6
5.49
5.38
5.27
5.16
5.05
Callback...
Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Line 4826 in the file 'newlisp.c' should look like this (only added the brackets here):

Code: Select all

seconds = duration - (outVal.it_value.tv_sec + outVal.it_value.tv_usec / 1000000.0);
Now the result of the testprogram looks like:
0
0.11
0.22
0.33
0.44
0.55
0.66
0.77
0.88
0.99
1.1
1.21
1.32
1.43
1.54
1.65
1.76
1.87
1.98
2.09
2.2
2.31
2.42
2.53
2.64
2.75
2.86
2.97
3.08
3.19
3.3
3.41
3.52
3.63
3.74
3.85
3.96
4.07
4.18
4.29
4.4
4.51
4.62
4.73
4.84
4.95
Callback...
Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Nice one ! thanks ;-)
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks for the fix Peter. I will make a development release during the coming week and for mid September we will have a new official release.

Lutz

Locked