osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

type hinting backward compatibility with python 3.0 to 3.4


On Sun, May 21, 2017 at 3:30 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> But since Python _does_ work with dynamic evaluation
>> (which consequently demands that these kinds of things be expressions
>> evaluated at compile time), it must by definition be possible to have
>> side effects.
>
>
> In most languages, type declarations are not expressions
> and aren't evaluated at all in the usual sense, so questions
> of evaluation order and side effects just don't apply.
>
> If we were designing a static typing system for Python from
> scratch, I would be strongly arguing that type hints shouldn't
> be expressions evaluated at run time, because it's such a
> poor fit for the intended use. Introspectable by all means,
> but evaluated by default, no.

How do you declare that a parameter must be an instance of some class?
Classes are themselves created at run time. Or would your typing
system require that all types be created in some declarable way?

ChrisA