Re: Does "case" work on widgets?

From: Erick Gallesio <eg_at_kaolin.unice.fr>
Date: Fri, 04 Nov 1994 10:48:45 +0000

>
> The "case" construct doesn't seem to work with widgets. For example
> the following code:
>
> (define z (case .m
> (.m ".m")
> (.x ".x")
> (else "other")))
>
> (write z)
> (newline)
>
> Will print "other" when I expect it to print ".m" (I checked and eqv?
> returns true for (eqv? .m .m).
>
> If the "case" is re-written as a "cond" using eqv? then it works, so
> it's not a big deal, but I thought I'd let everybody know.
>

This is not a bug. In fact the '.m' in the case expression is evaluated and
its
value is a Tk-command (and not the symbol .m). The situation is exactly the
same
as
(define a 'b)
(write (case a
          (a "a")
          (b "b")))

Here, the value printed is "b" (the value of the a symbol) and not "a".
Using the widget-name primitive could solve your problem.

   (define z (case (widget-name .m)
                 (.m ".m")
                 (.x ".x")
                 (else "other")))
 
   (write z)
   (newline)

should work.






                -- Erick
Received on Fri Nov 04 1994 - 10:49:44 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST