[swift-evolution] What about a VBA style with Statement?
Ted F.A. van Gaalen
tedvgiosdev at gmail.com
Wed Apr 13 17:13:48 CDT 2016
Well, method cascading might also be
an alternative to consider?
In Smalltalk this is possible like so:
print: “Hmmm, that was good!”
In Smalltalk, the semicolon closes the method cascading
In Dart, method cascading goes like this:
..print( “Hmmm, that was good!”)
cascading is indicated by a .. doubleDot, preceding the method names
Why not implement this in Swift?
in that case the semicolon would not be needed.
What to do with methods (functions) that return something?
(in Smalltalk, like in Swift?, if i remember correctly, ‘self’ is implicitly
returned in absence of a return value and can be ignored.
> On 13.04.2016 18:09, Radosław Pietruszewski wrote:
>> I’m -1, at least in the foreseeable future. I do agree that this is a
>> useful construct, but if I can do it in library code, paying only a small
>> price for this, I’d prefer Swift to grow better in places that a library
>> *can’t* fix.
> Well, there a lot of things that *your personal* library can fix for you.
> Should we stop improve the language and start to write just personal libs
> with improvements?
> This proposals about the feature that makes Swift better, more enjoyable to
> work with.
> Btw, this "with" method you suggest is not replacement for language
> construction - it allows compilation when struct instance constant (let s =
> SomeStruct()) is changed inside block. Do you like this? Do you want to
> produce such an non-safe code to your projects?
>> No — for now, it’s best to use a free function for now. And, like I
> No, not best, even not OK. Described above.
>> mentioned, universal conformances could allow this to be easily added to
>> all types — and so I’d focus on pushing *that* proposal.
> As I understand, such a method will have the same problem with un-safe
> behavior in case of constant.
More information about the swift-evolution