(Apologies if this has been discussed before.)
The requirement to use Self.
for static members when using them in instance members seems unnecessary and in my opinion only adds noise.
The older-school OOP languages allowed direct reference to static members without the additional qualifiers (Pascal, C++ and Java come to mind, but I'm sure there are more).
For example, every time I need some private constant within a class or struct, I hate the Self.
so much that end up moving the constant outside of my class/struct to reduce the noise in the code, i.e.:
private let Height = 44.0
struct MyButton: View {
var body: some View {
// ...
.frame(height: Height)
}
}
which itself isn't very nice since Height
is supposed to be used only inside MyButton
. Wouldn't it be great if I could define it inside MyButton
as static let
and use directly?
Philosophically speaking, it is not the caller's concern whether something is static or instance-tied; I think it's why the earlier language designers allowed static calls without qualifiers.
Does anyone feel the same way about Self.
?