Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl odd if statement syntax doesn't always work.

Closed / Rejected4ef142a41aa53e6a32ded9c16e7dfbfaeef2dd6dCreated 8 years agoUpdated 8 years ago
Descriptionplain2018-09-03 17:55:16
References:
   http://core.tcl.tk/tk/info/4e2d985d4a73aa3f

   https://groups.google.com/d/topic/comp.lang.tcl/5Gyb2fPy4lo/discussion

The if statement syntax:

  $cb instate disabled { return }

does not always work.  This is found in the ttk library code.

I don't know if this style should be supported or not.  If not, this 
ticket could be closed, and the changes outlined in the Tk ticket can be made.
dkfhtml2018-09-03 19:57:20

The implementation is here. How does it not work?

bllplain2018-09-03 20:17:43
I don't think the instate command is failing, I think it is
the "expr {return}" that is not (sometimes) working.


I have a wrapper around a ttk::combobox.

In the ttk::combobox code, the 'Post' procedure, the following statement
with the return works for a normal ttk::combobox:

puts "AAA:[$cb cget -state] / [$cb instate disabled]"
puts "BBB:[$cb state] / [$cb instate disabled]"
    $cb instate disabled  { return }
puts "   post"

Output when using my wrapper:

AAA:disabled / 1
BBB:disabled hover / 1
   post 

If I change it to:

   if { [$cb instate disabled] } { return }

it does work.
bllplain2018-09-03 20:41:52
Ok, I thought it was some weird syntax, and I have
been notified that it is actually part of the instate command.

Since I have a wrapper around ttk::combobox, could it be return-ing
to the wrong level???
oehharwiki2018-09-04 09:29:27

As it is apparently an issue of the TK "instate" command, it should be discussed there. Here is the Tk ticket: http://core.tcl.tk/tk/info/4e2d985d4a73aa3f

Closed here.

bllplain2018-09-04 14:31:58
More of a problem of uplevel not processing return statements correctly.
dgpplain2018-09-04 17:28:16
Please note that [uplevel] controls the substitution and 
resolution context of a script evaluation. It does not change
the actual recursion level of the active stack. Hence it has
no impact on how TCL_RETURN is processed.
dgpplain2018-09-04 17:29:47
Note also that Tk binding has its own set of rules
for handling exceptional return codes.
Log in (anonymous is fine) to add a comment.