2010/11/30 Robert Bradshaw <[email protected]>:
> On Sat, Nov 27, 2010 at 12:28 AM, Vitja Makarov <[email protected]> 
> wrote:
>> 2010/11/27 Vitja Makarov <[email protected]>:
>>> 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?
>>>
>>>>
>>>>> 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.
>>>>
>>>> Stefan
>>>
>>> Seems to work fine. No regressions.
>>>
>>> --
>>> vitja.
>>>
>>
>> I've attached patch to ticket #308, not sure right place for it.
>> Btw lambda at module scope gives +29 points in pyregr.
>>
>
> Wow, it's amazing how much can happen when you go away for a few days
> of vacation. Thanks!
>
> - Robert

Thank you!

Btw there is one more issue with lambdas, #605. Now it gives gcc
compilation error. It seems that we forget about this case.

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

Reply via email to