exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
15.01k stars 517 forks source link

Forward references #480

Closed matthew-parrott closed 8 months ago

matthew-parrott commented 1 year ago

Hi there -- does Codon support forward references as defined in PEP 484:

https://peps.python.org/pep-0484/#forward-references

I have some code which looks like this:

class A:
    child: 'A' = None

But, I get the error: error: expected type expression

matthew-parrott commented 1 year ago

It looks like this works:

class A:
    child: A = None

Which, I'm happy there's a way to do this. But, that means the code won't work in Python and I was hoping (maybe unrealistically so) that I could run the same code (within reason; it has 0 dependencies outside the standard library) in both environments.

inumanag commented 8 months ago

This is duplicate of #482 ; Self should be the canonical way to cover both grounds.