3 ms·
Len works on any Sized. Upper only works on strings. There are lots of Sized, there's only one string.
by joshuamorton 7y ago
Len works on any Sized. Upper only works on strings. There are lots of Sized, there's only one string.
- divs1210 7y agoI believe that was a reply to your question: > Interesting, what inconsistency?
- joshuamorton 7y agoAnd my point is that there isn't an obvious inconsistency there. Sized is an interface, exposed via a function. String is a type, which has methods. Now yes, you can make an argument that everything is an interface ("upper-able"). But bleh, and this avoided problems like "is it .length or .length() or .size or .size()" as happened in some other languages.
- lkrubner 7y agoThis appears to be 2 different languages: "".upper() vs len("") The first appears to be an object oriented language such as Ruby or Javascript. The second appears to be some language with plenty of static or built-in functions, such as PHP or C. This is clearly inconsistent under any definition of inconsistent.
- joshuamorton 7y agoSo which would you prefer: upper([1,2]) (so `upper` is a static builtin) or being unclear on whether its "".len or "".length or "".size or "".size() Like I said, there is consistency: interfaces are given top level things (builtin functions, operators, language features/keywords), while object methods don't. To give a recent anecdote, Rust's `x.await`, which is more "consistent", but everyone is complaining because in most languages async interfaces are exposed via something like `await x` instead of an attribute/method-y thing.