On 01/25/2011 10:23 AM, Stefan Behnel wrote:
> Robert Bradshaw, 25.01.2011 10:00:
>    
>> On Mon, Jan 24, 2011 at 11:33 PM, Stefan Behnel wrote:
>>      
>>> Vitja Makarov, 25.01.2011 08:15:
>>>        
>>>> I want to write simple code to find unbound variables.
>>>>          
>> I'm assuming you mean unassigned (as opposed to unbound in, e.g., a closure)?
>> [...]
>> It probably wouldn't be too hard to walk the tree to discover this
>> kind of information, recording on each NameNode as one goes along what
>> its possible states are.
>>      
> A general "NameNode dependency walk" of the tree could give us *loads* of
> information, also for better type inference. Knowing that a Python variable
> is definitely not None from a given point on, or that it has a specific
> type at one point and a different type at another would be really cool.
>
> Basically, we could build a dependency tree for each NameNode (at its
> specific point in the tree, not just through its symtab Entry) that
> references its assignment RHSs, but including a representation of relevant
> branches in the code.
>
> But I also agree that loops are evil. :-/
>    

A related problems is use of uninitialized local variables. I recently 
had problems with that, and gcc warnings are less than perfect in this area.

I think we ideally should raise a compiler error if it can be proven 
that a variable is uninitialized. I'm even in favour of following Java 
and raise an error (or at least a warning) if it can't be proven that it 
is initialized; such code is usually poorly written anyway and it really 
doesn't hurt to initialize the variable to 0.

Dag Sverre
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to