[Python-Dev] Adding NewType() to PEP 484

Guido van Rossum guido at python.org
Sat May 28 00:26:29 EDT 2016


On Fri, May 27, 2016 at 6:59 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>
>> TypeAlias? Because A is an alias for int?
>
>
> That suggests it's just another name for the same type,
> but it's not. It's a distinct type as far as the static
> type checker is concerned.

We discussed this over dinner at PyCon, some ideas we came up with:

- Dependent types, harking back to a similar concept in Ada
(https://en.wikibooks.org/wiki/Ada_Programming/Type_System#Derived_types)
which in that language is also spelled with "new".

- New type

- Distinguished Type

- Distinguished Subtype

- Distinguished Type Alias

- Distinguished Alias

- BoatyMcBoatType

The nice thing about "distinguished" is that it's a relatively rare
word so it is easy to remember or look up.

Personally I'm still in favor of Derived type (but I'm more into
ancient programming languages than most folks here). I could also live
with Distinguished Type.

The problem with Alias is that these types are *not* aliases (at least
not to the type checker, which is where we need the terminology -- so
we can talk about what the type checker does to these).

> Fake types? Virtual types? Pseudo-types?

I'm not keen on any of these.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list