View unanswered posts | View active topics It is currently Sun Sep 20, 2020 11:28 pm

Reply to topic  [ 2 posts ] 
Author Message

Joined: Tue Mar 06, 2007 10:46 pm
Posts: 1
Post Recursion
It seems that recursive calls on the NXT cause my programs to crash.

Is recursion implemented in robot C?
If not is it likely to be included in a future version?

Tue Mar 06, 2007 10:49 pm

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
RobotC on the NXT currently supports five levesl of subroutine calls. Next version will support 10 levels of nesting. This is limited by the size of the internal task stack.

Recursion is supported up to the previous limits. With one caveat. Procedure parameters and local variables are currently static variables. This means there is only one copy of these so that if you call a function recursively and the function has either parameters or local variables you'll get strange results. [Byt the way, use of static procedure variables is common in C compilers for small microprocessors. This method is also used in the NXC system.]

A future vesion will migrate to stack storage for procedure parameters and local variables.

Thu Mar 08, 2007 9:55 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.