www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Does D support tail recursion?

reply Jerry <Jerry_member pathlink.com> writes:
Hi, 
In some ML languages like Ocaml the compiler detects tail-recursions and
automatically changes it to a while loop before assembling into machine code.
Does D have this tail-recursion-optimization too?

-Jerry
Aug 08 2005
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
"Jerry" <Jerry_member pathlink.com> wrote in message 
news:dd8dro$7l9$1 digitaldaemon.com...
 Hi,
 In some ML languages like Ocaml the compiler detects tail-recursions and
 automatically changes it to a while loop before assembling into machine 
 code.
 Does D have this tail-recursion-optimization too?

 -Jerry
D the language doesn't say if a given compiler should or shouldn't detect tail recursion. The dmd compiler doesn't. I think the gdc compiler does - but I haven't actually checked.
Aug 08 2005