unexpected double evaluation of statement.

Q&A's, tips, howto's
Locked
Maurizio
Posts: 52
Joined: Mon Jul 28, 2003 3:06 pm
Location: Italy

unexpected double evaluation of statement.

Post 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

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

Post 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

Maurizio
Posts: 52
Joined: Mon Jul 28, 2003 3:06 pm
Location: Italy

Post by Maurizio »

Thank you very much
Maurizio

Locked