![]() But in fact, you CAN detect this at compile time pretty easily, and some static analyzers will emit warnings for C# or Java in cases like: Animal a = new Dog() This would be true even if you couldn't detect it at compile time. I say that "point of view" is irrelevant because there is no point of view, at compile time OR run time, where a is not a Dog. That's literally all of what a subtype is. I really cannot hammer home this point enough. That's how subtypes work, and if you don't understand that, you don't understand subtypes. Dog is a subtype of Animal means that every Dog is also an Animal, has always been an Animal, will always be an Animal. You can't convert a Dog to an Animal, because the Dog already is an Animal. It's more accurate to say, " a is an Animal AND a is a Dog". People will probably understand what you mean, but it shows you're not thinking about types correctly. It's not really correct to say that " a has type Animal AND a has type Dog". I'm also going to complain about your phrasing of "has type": type is an "is a" relationship, not a "has a" relationship. "Point of view" is completely irrelevant. So, what does it mean to you? Is it possible to unite these two use cases of the word weak?įrom a static point of view, the expression a has type Animal. I do not believe the precise constructs in a type system should be the decising factor, but the concept of identity of a type. This seems to be due to there not being tagged union types in that language. However, some also call the type systems of other languages such as Java weak. This classification would also make most statically typed languages strongly typed. Therefore, using a different definition for a type can supposedly make a language strongly typed. Types in C are little more than their sizes in bytes. In this context, strongly typed seems to mean 'not C'. ![]() I think we should at least limit ourselves to statically typed languages in this discussion. This is despite Wikipedia insisting that dynamic languages can still be strongly typed. Recently, for example, the Grain programming language website dubbed it as a strongly typed functional language instead of emphasizing it's a statically typed one. Typing strength seems to be one of the terms that people use because they assume they know the meaning.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |