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



arijit79@xxxxxxxxx wrote:

...

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
}

As no one has answered your technical request yet, here is my 2 cents.

Here's my guess at proc semantics stolen from old code of mine. No warranty
given.. no compilers used to test this:

#include "tclInt.h"

Tcl_ObjCmdProc FieldObjCmd;

int
FieldObjCmd (xxx)
{
# check for objc count
# do what you need with the first arg, i'm not sure.

{
Tcl_Namespace *nsPtr = Tcl_FindNamespace(interp, "::", 0L, 0);
CallFrame frame;
Proc proc;

Tcl_PushCallFrame(interp, (Tcl_CallFrame *)&frame, nsPtr, 1);
proc.numCompiledLocals = 0;
proc.firstLocalPtr = 0;
proc.lastLocalPtr = 0;
frame.procPtr = &proc;

result = Tcl_EvalObj(interp, objv[2]);

Tcl_PopCallFrame(interp);

if (result == TCL_ERROR) {....}
}
}

{
...
Tcl_CreateObjCommand(interp, "field", FieldObjCmd, NULL, NULL);
...
}

--
"All this modern technology just makes people try to do everything at once."
-Hobbes

Attachment: signature.asc
Description: OpenPGP digital signature



Relevant Pages

  • Re: TIP #187:Pure Tcl implementation
    ... This is a pure Tcl TIP187 implementation in order to let interested ... programmers to play/use it. ... The input lists must be of the same length, ... proc unknown args { ...
    (comp.lang.tcl)
  • Re: A little help on a proc
    ... Do you care if the loginname is invalid? ... > So the best process is to rerun the query? ... >> create proc foo as ...
    (microsoft.public.sqlserver.programming)