[mercury-users] Quick Recursion Question
Charles Shuller
charles.shuller at gmail.com
Sat Apr 21 07:42:21 AEST 2012
I was reading some sample code in the Posix extension library and saw:
main_loop(Data, ListenFd, !IO) :-
await_conn(ListenFd, ConnFd, !IO),
handle_conn(Data, ConnFd, !IO),
main_loop(Data, ListenFd, !IO).
And the first thing I think of is that the stack will be consumed
without bounds as every recursion into main_loop consumes more memory.
Then I thought that perhaps Mercury predicates didn't work quite the
same way as a function in C.
So will the above simply consume ever more ram as every request calls
main_loop again?
If it does not, how come?
Thanks!
Charles
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list