Re: Tcl C extn - Scoping in extended cmds - how to?



On Jun 28, 12:46 pm, "MartinLemburg@UGS" <martin.lemburg....@xxxxxxx>
wrote:

so far as I know, no tcl command (C function registered as tcl
command) creates a call-stack-scope on its execution.


On the contrary, every proc starts by creating a stack frame. Only
certain specific ones (like control structures) immediately pop back
from it through [uplevel].

If you need just that fresh frame and nothing else:

proc separate_frame __code {eval $__code}

set x 1
separate_frame {
set x 2
puts $x
}
puts $x

=>
2
1

I guess the OP could generalize this to his domain, with procs doing
real things in addition to the frame.

Now as to whether such style should be encouraged, I'm tempted to
agree with you.
But I'll leave it to the OP to decide if it makes sense in his problem
domain.

-Alex

.



Relevant Pages

  • Re: can menu or a menubutton have a command associated with it ?
    ... I'm attaching the proc I modified but also the definition of "base' ... puts "\n HISTOGRAM DRAWN!" ... set aint 1.e10 ... frame $base.frame_labels_bxbybz ...
    (comp.lang.tcl)
  • Re: tk widget
    ... proc LoadTextFileData { ... I define two different types of parts: widget ... > frame .partnum ... > set type "widget" ...
    (comp.lang.tcl)
  • Re: doubt in tcl
    ...    I am going through one my automation team scripts. ... But as far as I know, first word should ... alsways be the tcl command or proc, ...
    (comp.lang.tcl)
  • Re: why adding two buttons in a row screws up the whole GUI ?
    ... It starts the interpreter but it cannot execute any of the proc. ... How is it posbbile to check the syntax of some code added to a proc? ... I placed the two buttons in such a frame and then reconfigured its row ... -sticky nesw ...
    (comp.lang.tcl)
  • Re: doubt in tcl
    ... alsways be the tcl command or proc, ... But dut is not a proc or tcl command. ... It varies from script to script. ...
    (comp.lang.tcl)