Earlier quoted context omitted.
Because mixing types in an array is stupid enough that I thought it might just not be valid.
Mixing types in an array/list is not remotely stupid. How exactly would you suggest expressing the lack of a value in a series of numbers without None/null? There's your mixed types. Don't let weird dogma get in the way of practicality.
Codon: A high-performance Python-like compiler using LLVM
181–184 of 184 posts
That's an Optional[int]. It's not "mixed types", it's a union type.
Re: Codon: A high-performance Python-like compiler using LLVM
#182Since Codon performs static type checking ahead of time, a few of Python's dynamic features are disallowed. For example, monkey patching classes at runtime (although Codon supports a form of this at compile time) or adding objects of different types to a collection. This seems like a very different language from Python if it won't let you do: [1, 'a string']
With type hints you would model this as a Union type, i.e., Union[int, str]. This is perfectly legal with mypy and other Python type checkers.
Re: Codon: A high-performance Python-like compiler using LLVM
#183Re: Codon: A high-performance Python-like compiler using LLVM
#184Earlier quoted context omitted.
Mixing types in an array/list is not remotely stupid. How exactly would you suggest expressing the lack of a value in a series of numbers without None/null? There's your mixed types. Don't let weird dogma get in the way of practicality.
That's an Optional[int]. It's not "mixed types", it's a union type.
That is merely a detail of how the typing module has decided to set up convenient aliases. Treated by the language (and likely compilers) as different types.