Vitja Makarov, 27.11.2010 09:17:
> 2010/11/27 Stefan Behnel<[email protected]>:
>> Hi,
>>
>> please start a new thread when switching to a new topic.
>>
>> Vitja Makarov, 27.11.2010 08:24:
>>> I'm now trying to make "module scope lambda" work.
>>> That's almost done.
>>>
>>> I see that needs_assignment_synthesis() should be forced to create
>>> PyMethodDef struct.
>>
>> I would be happier if we could get rid of PyMethodDef in the long term, but
>> it's clearly easier to keep it for now.
>>
>>
>>> Now I do it this way:
>>> def needs_assignment_synthesis(self, ...):
>>> .....
>>>                if self.name == '<lambda>':
>>> .....
>>>
>>> Seems like a dirty hack.
>>
>> Yes. Instead, use a new flag "is_lambda" on the entry.
>
> This check is performed in DefNode so I prefer to call it
> force_assignment_synthesis it could be used later for module level
> functions.
>
> Or do you mean that "is_lambda" should be set after
> declare_lambda_function() and then checked in DefNode?

Yes. As I said, the difference is small, so a flag and a couple of checks 
in the right places will do.


>>> Also lambda function is defined in module methods table as
>>> __pyx_lambda_funcdef4lala_lambda1,
>>> Is it safe not to add lambda cname to pyfunc_entries in
>>> Scope.declare_lambda_function()?
>>
>> I don't know, you can try. In any case, it needs to do everything that a
>> normal Python function does, except for adding its Python name to the
>> defining scope. That's a rather small distinction.
>
> Seems to work fine. No regressions.

Ok. IIRC, lambda functions are already kept in a different list. I wonder 
if that was a good idea. Maybe a flag right on the DefNode would have been 
a better way to do it.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to