Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl_LimitTypeSet

6 views
Skip to first unread message

Nicolas Castagne

unread,
Jul 11, 2007, 12:29:34 PM7/11/07
to
Hi folks,


I have problems with the limit system (eg : Tcl_LimitTypeSet) in the Tcl
lib.


When using a time limit, ie calling :
Tcl_LimitAddHandler( ...
Tcl_Time timeLimit;
timeLimit.usec = 0;
timeLimit.sec = 1;
Tcl_LimitSetTime( interp , &timeLimit);
Tcl_LimitTypeSet( interp , TCL_LIMIT_TIME );
and updating the limit appropriately in the callback,

then the limit's callback is called very often, no matter how long the
limit was set.


Convesely, when using a command limit, ie calling :
Tcl_LimitAddHandler( ... TCL_LIMIT_COMMAND ...
Tcl_LimitSetCommands ( interp , 1);
Tcl_LimitTypeSet( interp , TCL_LIMIT_COMMAND );
and updating the limit appropriately in the callback,

then the limit's callback is called only when non-nested commands are
interpreted.

For example, if the script has an infinite loop, the limit's callback is
NEVER called.


I am using the latest tcl 8.5a6 on Linux.

Am doing something wrong ?

Or is there a problem with limit handling in Tcl 8.5 ?

I did not find a bug in the bug tracker...


Best-
Nicolas

Mark Janssen

unread,
Jul 19, 2007, 4:20:27 AM7/19/07
to

Regarding the first part of your question, at the Tcl level, a time
limit is set using the seconds since the epoch. Although the
Tcl_LimitSetTime man page is not exactly clear on this, I suspect the
same applies for the C-API.
So to set a time limit 10 seconds in the future you will actually need
to set the seconds as the result of:

expr {[clock seconds]+10}

Doing this at the C level is left as an exercise for the reader ;-)
(BTW I assume that by "then the limit's callback is called very often"
you mean it is called directly for the interpreter.)

Regarding the nested loop limit not firing, this could be related to
http://sourceforge.net/tracker/index.php?func=detail&aid=1752146&group_id=10894&atid=110894
which is fixed. Could you try again with the latest Tcl CVS HEAD?

Mark

0 new messages