Page 1 of 1

unexpected double evaluation of statement.

Posted: Sun Nov 23, 2003 12:47 pm
by Maurizio
I'm trying to automatically generate names for tk widgets
this is a sample I've written

(define (newname parent) (string parent "." (inc 'cnt)) )
(define (opt opts) (if (string? opts) opts ""))

(define (toplevel opts) (tk "toplevel " (opt opts)) )
(define (frame parent opts) (tk "frame " (newname parent) " " (opt opts)) )

strangely, if try the following statements :

(set 'cnt 1)
(set 'top (toplevel ".main"))
(set 'frame1 (frame top))

frame1 get the value ".main.3", instead of ".main.2"

While in this case it has no bad effects, however it's disturbing...

What happens ?

Regards

Maurizio

Posted: Sun Nov 23, 2003 4:54 pm
by Lutz
this is a bug in the 'tk' macro which is evaluating (newname parent) twice. This will be fixed in the next version.

As workaorund meanwhile:

Code: Select all

(define (frame parent opts) 
  (set 'pn (newname parent))
  (tk "frame " pn " " (opt opts)) ) 
Lutz

Posted: Sun Nov 23, 2003 8:21 pm
by Maurizio
Thank you very much
Maurizio