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



Hi,

I am using Tcl C extension to create extended commands like this:

set var 1
block b {
register r {
field f {
bits 8
}
}
}

Where "block", "register", "field", "bits", etc are my extended
commands.

Now, when I do command extensions like this using
"Tcl_CreateCommand(interp, ...)", the scope actually remains the same
i.e. inside the "field" in the above example, I am actually able to
access $var. In other words, the following becomes possible.

set var 1
field f {
echo $var //This works fine...In Tcl proc scoping semantics,
it is not allowed unless upvar or global is used.
bits 8
}

But I actually want my commands to have Tcl proc semantics as far as
scoping is concerned, so that the above code becomes invalid and the
following (pure Tcl way) should only be allowed.

set var 1
field f {
upvar $var local_var
echo $local_var
bits 8
}

So, I just wanted to know if there is some way by which I can
configure my extended Tcl commands to follow the "proc" semantics as
far as scoping is concerned.

Thanks for your time and willingness to help,
Arijit

.



Relevant Pages

  • Re: Tcl C extn - Scoping in extended cmds - how to?
    ... no tcl command (C function registered as tcl ... create a new scope, so that it may access all local variables inside ... There are "raw" or low level tcl commands representing the WIN32 API ...
    (comp.lang.tcl)
  • Re: looking for tcl based Cisco like command line interface
    ... TinyTcl and Jim would be fine to save resources, but first is missing some newer tcl sub-/commands and later has no exec-command at all. ... Only want to install one single tcl/etcl/tclkit interpreter and a single tcl script. ... Funny, the cli can be run from any computer remote,using snmp get/get-next/set for communication to the network device, therefore got a remote console program too. ... extreme environments) based on ARM or Coldfire processor using Debian Linux/ucLinux should be extended with a CLI that is similar in behaviour, handling and naming conventions to the well known cisco command line interface (several user-visible application-specific commands, along with a help, different management operation levels like "enable", "config", line driven only, tab expansion, no special graphics or ascii terminal commands) ...
    (comp.lang.tcl)
  • Re: Language Specification - Where is it?
    ... >> the Endekalogue, the semantics aren't described ... > commands have semantics. ... The first is the semantic of the Tcl syntax and the behaviour and order ... all the rest of the language can be in theory implemented using this ...
    (comp.lang.tcl)
  • Re: Constants for catch return values?
    ... > proc like [tokenize]. ... As an aside, in TCL 8.5, I figure you could do the inverse conversion ... 101 commands that each deal with one aspect of it (except where those ... of pattern matching) Two examples of my own; I had a script that had ...
    (comp.lang.tcl)
  • Re: looking for tcl based Cisco like command line interface
    ... commands, along with a help, different management operation levels like ... As tcl is very powerful a smaller tcl to achieve faster startup may be ... cli commands to snmp get/get-next/set. ... is based on tcl it would even be possible to extend the rights of this ...
    (comp.lang.tcl)