Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Tail call recursion in Java?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Tue Nov 15, 2016 12:04 am    Post subject: Tail call recursion in Java? Reply with quote

is there a point for doing tail call recursion in java, on the assumption that you do not use any advanced features or something else similar such as scala?

for example if i were to write a tail call recursive function in C, it would run in a way such that unused stacks from previous calls are cleared. however, because there is no tail call optimization in JVM, doing so is pointless and may even incur more performance penalties than an iterative function or a non-tail recursive function due to the extra argument passing the result to the next call.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Nov 15, 2016 7:41 pm    Post subject: Reply with quote

If you think the code is easier to understand with recursion over a loop, then use it.
There's no point to avoid it, unless you have a specific fear of a stack overflow.
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Tue Nov 15, 2016 9:31 pm    Post subject: Reply with quote

Zanzer wrote:
If you think the code is easier to understand with recursion over a loop, then use it.
There's no point to avoid it, unless you have a specific fear of a stack overflow.


ok thanks. yea, i guess i would prefer iteration since it was able to calculate a larger input without overflow.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites