[swift-evolution] Proposal: Re-instate mandatory self for accessing instance properties and functions
dennis.s.lysenko at gmail.com
Mon Dec 14 17:57:01 CST 2015
My two cents: I don't think that "there will be more work for the
programmer" is necessarily a reason to not implement a feature. Granted, we
don't want to end up like Java 7 where I dreaded doing some things that
would be dead simple in Swift--but Swift already has a lot of
expressiveness and conciseness built in. Explicit self won't kill
'self' for ivar and method access brings a tiny bit of programmer overhead
(honestly, . is the easiest key to hit. You do it all the time, both in
plain english and in code) and prevents some issues that will nag at you
and waste days.
Java is almost hellish when it comes to conciseness but you don't hear
anyone saying "at least we have implicit 'this'!"
I'm sure there were people presenting that exact argument when
optionals/enforced nullability was first introduced into other languages:
"Ugh, now I have to null-check everything? What a pain!"
Although I am a strong believer in the programmer-facing aspects of a
language needing to be good, I think that this decision should come down to
the relative long-term pros/cons: use for refactoring, protecting against
mistakes, etc. One thing that programmers are notoriously bad at doing is
overcoming the immediate want to put less effort toward something, in order
to accept something that will be useful long-term. That is why so many
people don't unit test: can't see past the upfront cost to create
I accept that people will continue to say "I can't be bothered to type
'self.'", but I just wanted to get this out there. It's really not that big
a deal--unless you're talking about readability rather than five keystrokes
on a method access. Keystrokes aren't the bottleneck in effective
On Mon, Dec 14, 2015 at 6:05 PM Stephen Celis via swift-evolution <
swift-evolution at swift.org> wrote:
> On Mon, Dec 14, 2015 at 5:35 PM, Dan Loewenherz via swift-evolution <
> swift-evolution at swift.org> wrote:
>> 2. How can one reference a function with the same name as an instance
>> method in the class from which you’re referencing from? E.g., in the above
>> example, I believe that the “add” function is unreachable from within the
>> (please correct me if I’m wrong).
> FWIW, I like implicit self but have been bit by this several times before.
> You can use the current module's name to reference the free function, but
> the error messaging you'll face beforehand doesn't make it easy to get to
> that solution.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution