Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pointers that also carry the underlying type information.


I don’t remember what the CPython implementation looks like, but even if the information is there, it’s not really exposed to end users. “type(foo)” doesn’t return the type of the name “foo”, but of the object that “foo” points to.


I meant that it's a pointer that is aware of the type of object it's pointing to by virtue of all objects knowing their own type. Same difference I guess.

Unlike void pointers or Object references in Java you can't "forget" an object's type.


Ah, I think I see what you mean. I still think it's more accurate to say that names are just pointers that don't have any typing info themselves (or if they do, it's an implementation detail that doesn't actually get surfaced and isn't a part of the language definition). In Python it doesn't quite make sense to talk about the type of a "name" or "variable" or "pointer" because, because it points to an object, and that's where the canonical type info actually lives.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: