On Wed, Feb 11, 2015 at 10:21 AM, Jonathan S. Shapiro <[email protected]>
wrote:

> On Wednesday, February 11, 2015, Keean Schupke <[email protected]> wrote:
>
>> def add_x x = lambda y = x + y
>> x : 'a -> ('a -> 'a)
>>
>> def add_one = add_x 1
>>
>> I don't see the problem. "add_one" is a stack allocated object in the top
>> level context.
>>
>
> Umm... The stack in this context is gone by the time we enter main. I'm
> not quite sure what you are imagining, but I'm sure it will be 
> educational.[image:
> 😄]
>
> Given dynamic libraries and multiple application entry points (as opposed
> to just main), putting top-level allocations on the stack is tricky.
>
> I do agree that in this case the closure object can be allocated as a
> global, though.
>

There's a simpler reason why not all closures can be stack allocated.
Sometimes we want a heap allocated list of them, referenced by unrelated
parts of the code, such as for callbacks in an event queue.

Geoffrey
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to