Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Does Caml have slow arithmetics ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-08 (09:51)
From: Andreas Rossberg <rossberg@p...>
Subject: Re: [Caml-list] Does Caml have slow arithmetics ?
David Brown wrote:
> In some functional languages (Scheme, specifically), tail recursion is
> required to be implemented iteratively.  It is a common enough idiom,
> and easy enough to implement, that it is generally done in functional
> languages.  In fact, gcc does it in C, with enough optimization.

The latter is, to a certain extent, a myth.

First, you have to distinguish between simple tail *recursion*, and the 
much more general concept of tail *call*. I believe Scheme requires to 
fully optimize the latter, and so it is done by all decent FPL 
implementations. GCC does not do that, already falling short of mutually 
recursive functions, IIRC.

Second, a C compiler can only optimize tail recursion under limited 
circumstances, because generally the C language semantics prevent it 
(once more due to pointers, particularly C allowing - and its libraries 
relying on - taking the address of local variables). Last time I heard 
of it, it was said that GCC is having a hard time doing anything 
practically usefull at all.

- Andreas

Andreas Rossberg,

Let's get rid of those possible thingies!  -- TB

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: