unexpected double evaluation of statement.

Started by Maurizio, November 23, 2003, 04:47:32 AM

Previous topic - Next topic

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

Lutz

#1
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:



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


Lutz

Maurizio

#2
Thank you very much

Maurizio