Re: Is this a legitimate use of "reutrn -level"?
- From: Don Porter <dgp@xxxxxxxx>
- Date: Mon, 11 Aug 2008 13:18:41 -0400
Adrian Davis wrote:
Consider the following:-
# Example
proc proc0 {} {
puts "This is proc0"
proc1
puts "Back in proc0"
}
proc proc1 {} {
puts "This is proc1"
proc2
puts "Back in proc1"
}
proc proc2 {} {
puts "This is proc2"
return -level 2
}
# End of example
...which displays the following when run...
This is proc0
This is proc1
This is proc2
Back in proc0
...Which is exactly what I want. Under certain conditions in "proc2" I
want to continue processing from the point after the call to "proc1"
in "proc0". The above use of "return -level 2" seems to work Ok, but
I'm not sure if this a legitimate/supported use of this option. The
man page doesn't seem to be clear on this point. Is this usage
correct?
This is valid, but fragile. These routines are using the commands
in an acceptable way, but the danger is in whether other callers of
the [proc2] command will get surprised in bad ways. You'll want the
docs for [proc2] to be very very clear that it returns the TCL_RETURN
return code, and callers need to use it in situations where that makes
sense, or be prepared to [catch] it.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@xxxxxxxx Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
.
- References:
- Is this a legitimate use of "reutrn -level"?
- From: Adrian Davis
- Is this a legitimate use of "reutrn -level"?
- Prev by Date: Is this a legitimate use of "reutrn -level"?
- Next by Date: Widgets <-> letters size
- Previous by thread: Is this a legitimate use of "reutrn -level"?
- Next by thread: Widgets <-> letters size
- Index(es):
Relevant Pages
|