| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@ilevkivskyi I know you're intent on maintaining the distinction between types and classes, so I think here "class" is the correct choice, no? EDIT: Actually, never mind. I was too focused on how they simulate instantiation. I think there's just something about the name NewType that's bugging me. From an introspection POV, an instance of a class with def __call__(self, x): return x would be easier to detect than a plain function while still avoiding the instantiation overhead. |
Sorry, something went wrong.
|
@JukkaL, what do you think of this design? |
Sorry, something went wrong.
I am intentionally a bit "general" here, see my comment from the issue: Concerning your two other points, the idea here is to be really minimal, to allow minimum overhead. In particular your idea with many base classes is almost equivalent to Intersection, that might be implemented later (there is an issue on this). |
Sorry, something went wrong.
|
Note, see my comment/concern I posted to the corresponding issue. I don't
think this is ripe yet...
|
Sorry, something went wrong.
| NewType helper function | ||
| ----------------------- | ||
|
|
||
| There are also situations, where a programmer might want to avoid logical |
There was a problem hiding this comment.
No comma.
Sorry, something went wrong.
|
|
||
| * Generic, used to create user-defined generic classes | ||
|
|
||
| * Type, used to annotate class objects |
There was a problem hiding this comment.
This and the next one I'll apply right now. They're unrelated to this issue.
Sorry, something went wrong.
There was a problem hiding this comment.
OK, sure, I just posted a link to this PR to python-dev asking for comments.
Sorry, something went wrong.
|
A few things:
|
Sorry, something went wrong.
Good point. I added this in new commit
Here I am not sure. Maybe ad-hoc types? EDIT: replaced by the correct quote |
Sorry, something went wrong.
|
Let's think some more about the name, it feels important. Even if the
function is called NewType.
…--Guido (mobile)
|
Sorry, something went wrong.
|
Appointed types — because they are only nominally distinct. |
Sorry, something went wrong.
|
Sorry, something went wrong.
|
LambdaType |
Sorry, something went wrong.
|
TypeDef |
Sorry, something went wrong.
|
I like @lgautier's NamedType a lot: to me, it expresses "this is otherwise the same type, but it has a different name (and therefore its own meaning)". Also, like he says, it meshes nicely with namedtuple (and typing.NamedTuple). How I would read it:
If NamedType does not make it, what about ValueType?
How I would read it:
NamedType works better, though. |
Sorry, something went wrong.
|
I could not follow anything from the Scala ValueType description (no news The explanation "it is the same type with a different name" feels wrong -- I will check with Jukka but unless he has strong objections I am going for On Wed, Jun 1, 2016 at 1:42 AM, Sietse Brouwer notifications@github.com
--Guido van Rossum (python.org/~guido) |
Sorry, something went wrong.
|
I'm going to abandon the "English description" discussion, and merge this as-is. The new function will be called NewType() and in the discussion we'll use "unique type" (like in this PR). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Simple minded implementation of NewType (see #189 and python/mypy#1284 (comment)) plus some tests and a short discussion in the PEP.
Also I added Type and ContextManager to the list of types provided by typing.py.