3 ms·
Well, how are you defining type? Are you defining type by the collection of methods a value or term of that type would have? That doesn't seem like the best de
by drdeca 8y ago
Well, how are you defining type?
Are you defining type by the collection of methods a value or term of that type would have? That doesn't seem like the best definition to me, but ok.
I would think that a good definition would probably involve something like, a type is the thing which restricts what terms or values can be in what places in what expressions/statements.
As others have said, a function could very well require that its argument be a list which isn't of length 0.
The way you phrased the question sounds like you are thinking of the methods as being contained in the value or something like that. Things don't need to work that way.
You could just treat "calling a method" of an object like a different notation for calling a function with that object being the first argument.
(Which, if the method required the list to be non-empty, would just be a compile time type error if it couldn't be determined that the list would be non-empty.)