[swift-evolution] Proposal: An assignment operator := that ensures nil before assignment.

Andrey Tarantsov andrey at tarantsov.com
Wed Mar 2 01:21:10 CST 2016


> Here’s a use case. Suppose you are filling out a dictionary in some
> non-trivial way. However, it should be the case that the value for
> each key is computed and assigned only once. And so you would use the
> := operator to ensure this: dictionary[k] := value

Awesome; like others have said, this is the sort of thing you should
start the thread with. It's still not specific enough, though, so in
that first email you should go deeper and explain:

1) how often does your code do something like that?

2) *why* do you do that? i.e. what's the higher-level problem you're
   solving by initializing a dictionary like that?

I've been writing software for over 15 years, with half of that on Apple
platforms, and I don't think I did an initialization like that more than
a few times (in fact, I'm not sure I *ever* did it).

So when you write:

> I think this := would be used so often that it should be part of the
> language/standard library I think this := would be used so often that
> it should be part of the language/standard library I think this :=
> would be used so often that it should be part of the
> language/standard library
I think this := would be used so often that it should be part of the
language/standard library I think this := would be used so often that it
should be part of the language/standard library
> I think this := would be used so often that it should be part of the
> language/standard library

it really feels like trolling. :-)

Please, in the future, provide snippets of real code from your apps (and
preferably more than one) when starting a discussion.

Needless to say, strong -1 for this particular proposal — even if we
replaced := with something more appropriate (even a method), I don't
believe the use case is common enough to warrant inclusion into the
standard library.

A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160302/e18cfc0c/attachment.html>


More information about the swift-evolution mailing list