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

Setting the recursion limit in Tcl code?

10 views
Skip to first unread message

Stephen Trier

unread,
Feb 14, 2002, 2:36:45 PM2/14/02
to
Fellow Tcl'ers,

Is Tcl_SetRecusrsionLimit exposed as a Tcl command? Hopefully, I've
overlooked it in the docs. There are times when it would be convenient
to override the default, if I know I won't overflow the underlying C
stack.

Stephen


--
Stephen Trier
Technical Development Lab
Cleveland FES Center
s...@po.cwru.edu

Jeffrey Hobbs

unread,
Feb 15, 2002, 12:42:42 AM2/15/02
to
Stephen Trier wrote:
...

> Is Tcl_SetRecusrsionLimit exposed as a Tcl command? Hopefully, I've
> overlooked it in the docs. There are times when it would be convenient
> to override the default, if I know I won't overflow the underlying C
> stack.

Unfortunately it's only a C API with no Tcl interface ...
obviously it would be easy to wrap, but this is just something
that never did get exposed. I don't think a TIP would get
much objection, if you tied it to some tcl::recursionLimit
command or something.

--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions

Arjen Markus

unread,
Feb 15, 2002, 2:44:55 AM2/15/02
to

Well, if your code permits, there is a way to do "tail recursion" ;-)
See: <http://mini.net/tcl/1348.html>

Then you bypass the need for stacking procs on top of each other!

Regards,

Arjen

miguel sofer

unread,
Feb 15, 2002, 8:18:00 AM2/15/02
to
Jeffrey Hobbs wrote:
>
> Stephen Trier wrote:
> ...
> > Is Tcl_SetRecusrsionLimit exposed as a Tcl command? Hopefully, I've
> > overlooked it in the docs. There are times when it would be convenient
> > to override the default, if I know I won't overflow the underlying C
> > stack.
>
> Unfortunately it's only a C API with no Tcl interface ...
> obviously it would be easy to wrap, but this is just something
> that never did get exposed. I don't think a TIP would get
> much objection, if you tied it to some tcl::recursionLimit
> command or something.

As the limit is defined per interpreter, I'd rather propose that as a
subcommand to [interp]. The tcl-wide variant (tcl::recursionLimit) would
be suitable for the default value used at interp creation.

OTOH, there are some dangers in this, at least on unix where
TclpCheckStackSpace() is not implemented [FR #450795]: too large a
recursion limit will blow the stack. We have cooked up a trial
implementation (with Andreas Kupries) that could probably be finished up
in no time.

Stephen: would you like to TIP that? Maybe [FR #219353] could/should
also be made part of the TIP? Let me know, I'll gladly work on an
implementation.

My 2 argentine pesos (currently more than 2 cents, maybe not for long
...)

Miguel

[FR #450795]:
http://sourceforge.net/tracker/?func=detail&aid=450795&group_id=10894&atid=360894
[FR #219353]:
http://sourceforge.net/tracker/?func=detail&aid=219353&group_id=10894&atid=360894

Stephen Trier

unread,
Feb 15, 2002, 3:02:17 PM2/15/02
to
Yes, I will write a TIP for it. I'd be happy to implement it.
I'll take a look at the command limit feature request as well.
0 new messages