View unanswered posts | View active topics It is currently Mon Oct 20, 2014 7:45 pm






Reply to topic  [ 2 posts ] 
Recursion 
Author Message
Rookie

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
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: Sirius 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.