Dag Sverre Seljebotn wrote:
> Greg Ewing wrote:
>> Dag Sverre Seljebotn wrote:
>>> It
>>> now takes two parameters, "decref" and "free_temp", which both defaults
>>> to True, and which can be toggled.
>> Rather than a free_temp parameter, I'd be more inclined
>> to have an owns_temp flag on the node, set according to
>> whether the node allocated the temp itself or it was
>> supplied by the parent (currently done via an optional
>> parameter to allocate_temps(), which would become a
>> parameter to generate_evaluation_code()).
>
> I didn't supply enough context. It was meant for situations like this:
>
> self.arg.generate_evaluate_code(code)
> ...
> code.putln("if (...) {")
> ...
> self.arg.generate_disposal_code(code)
> ...
> code.putln("} else {")
> ...
> self.arg.generate_disposal_code(code)
> ...
> code.putln("}")
>
> Here, one can't free the temp in the first generate_disposal_code
> (because then the else-block could reuse and overwrite the temp etc.).
> As mentioned this is now solved by considering temp freeing as a
> seperate but parallell step to disposal. To make the example up-to-date,
> simply add at the end, but NOT inside the C if-blocks,
<snip>
> That's one reason I long-term believe in more transforms even for the
> stuff that nodes do today -- if code branches like the above were always
> done using nodes rather than code.putln, temp allocation would both be
> much simpler conceptually and more optimal theoretically.
>
Actually, this is not true. Pushing if-tests like the above to tree
nodes would amount simply to moving the generate_disposal_code to the
end of the C if-test.
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev