[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua language extension for complex number and vector values
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 4 Apr 2011 10:53:10 -0300
> But do I understand it correctly that all complex values inside that
> function would be created as temporary values?
Yes.
> If so, what are the requirements for writing such "pure" functions?
> Is the following sufficient?
> - does not write to global variables
> - does not call non-pure functions
> - does not create non-temporary objects with references to temporary
> objects
> - does not yield
Yes. You can even use local variables to hold intermediate results, as
long as you do not store them elsewhere.
> This is the part I don't understand. Garbage collection of the temporary
> array
> will happen at some distant future time. How can "complex" ensure that
> temporary values will not be reused before that, or that when the table is
> collected it will not damage those values? Or is that not important?
The table will be alive at least until the function returns, so I don't see
a problem there. Also, it's an anonymous function and so is not stored
anywhere unless the function does, which it's not supposed to.
> That's why I want to understand the details.
I haven't implemented any of this. Of course, it's the details that matter
in the end...