Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] The Caml morale crasher #1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] The Caml morale crasher #1
On Thu, 2005-09-08 at 14:55 +0200, yoann padioleau wrote:
> > * Damien Guichard:
> > 
> > > When annoucing an OCaml project on a public forum i have been
> > > advised to renunce lambdas because it would impede translation to "a
> > > less obscure, more popular language".
> > 
> > Most languages offer strictly downward closures.  Even GCC's C
> > implementation has them. 8-)
> 
> Again I think I will disagree on the choice of your words :)
> GCC has nested functions. I think that we can't call that a closure; a closure is something
> that close his environment and store it somewhere. There is no such thing in GCC I think.

My understanding is:

Gcc has first class closures like this stack picture:

closure:
	CALL FUNC
	stack frame here

FUNC:
	POP FP // FP points at the stack frame

Closure's are created by pushing the function
address plus a "CALL" opcode on to the stack,
the SP is then a pointer to the closure.

Execute permission is required for the stack.
Memory management of the thunks, also called
trampolines, is completely automatic.

The closures are valid if, and only if, they're
on the call stack, Damiens 'downward closures':
this means you can pass them as arguments but
not return them, like pointers to any other
local variable in C.

-- 
John Skaller <skaller at users dot sourceforge dot net>