Re: invoked "break" outside of a loop



Russell Trleleaven wrote:
Sorry to belabor the point but I was hoping someone would explain why
"break"
"uplevel break"
and
"namespace eval :: break"
don't work like I thought they might.

As you've learned, [break] is simply a return with a special code attached. Hence, when you invoke [break], it invokes a command that returns that special code, which is caught inside your proc, which leads to the error. I.e., the proc is converting the return from [break] into a different type of return, since [break] is invoked several levels down the return stack from the [for] loop.

For example...

proc AA {} {
BB
puts "got here AA"
|

proc BB {} {
if {[catch {
uplevel "set x 0"
}]} { puts "caught something" }
puts "got here BB"
}

Now, given that [set x 0] there return no error, nothing prints.

Were the [set x 0] to be replaced with an error call, you would expect the catch to catch it, yes?

Hence, since [break] is simply a kind of error, that error return is returned to the caller for use in [catch]. Since there is no [catch], it propagates up to the environment of the proc, where proc is about to return, and says "Hey, why are you throwing a [break] without an appropriate [catch]?"

Does that help?

--
Darren New / San Diego, CA, USA (PST)
Just because you find out you are
telepathic, don't let it go to your head.
.



Relevant Pages

  • Blocking with vwait and event loop
    ... I've adopted the common approach of using "puts" to send a request and ... If I use the button invoke method it works fine. ... The main file defines the myCommand proc which initiates ... The response is then forwarded to the "proc" _myCommand for processing. ...
    (comp.lang.tcl)
  • Re: invoking
    ... Make that "invoking a proc by space key, ... However, it won't invoke either button if focus is on X and Y, but it will invoke either button if focus is on Z". ... set class ...
    (comp.lang.tcl)
  • Re: how to retrieve [RecordsAffected] count from cmd.Excecute in V
    ... simple insert from tbl1 to tbl2 and the related ADO code to invoke the SP ... And here is the related ADO code to invoke the Proc and get the "Records ... cmd.ActiveConnection.CursorLocation = adUseClient '--I have also tried ...
    (microsoft.public.data.ado)
  • Re: how to retrieve [RecordsAffected] count from cmd.Excecute in V
    ... simple insert from tbl1 to tbl2 and the related ADO code to invoke the SP ... And here is the related ADO code to invoke the Proc and get the "Records ... cmd.ActiveConnection.CursorLocation = adUseClient '--I have also tried ...
    (microsoft.public.data.ado)
  • Re: WLM for toddlers
    ... If the application environment is stopped, the PROC is never invoked. ... It will invoke more PROCs, if applicable, if the AE is started. ... This is independent of DB2, except DB2 will use the associated PROC for DDF work. ...
    (bit.listserv.ibm-main)