[swift-evolution] What about a VBA style with Statement?

Erica Sadun erica at ericasadun.com
Thu Apr 14 18:47:40 CDT 2016


> On Apr 14, 2016, at 12:30 PM, Andrey Tarantsov <andrey at tarantsov.com> wrote:
> 
>>> I also like the idea of a dedicated method-cascading operator, like what Dart has.  It eliminates the need for a programmer to explicitly remember to 'return self' at the end of a chainable method.  Not sure how well it'd integrate with SE-0047 (@discardableResult) though.
>> 
>> Method cascades draft: https://gist.github.com/erica/6794d48d917e2084d6ed <https://gist.github.com/erica/6794d48d917e2084d6ed>
>> 
>> deferred to after 3.0
> 
> I really think this settles the discussion, because methods cascades are *the* way to implement this kind of thing. (And for the record, I would prefer a SmallTalk/Dart-like syntax to a "with" statement.)

It's been quite a while since the original discussion and I'm going to go all Brent R-G on the answer, which is I've come to prefer the Dart solution for cascading, think `with` is better suited for mutating copies of struct constants (Immutable setters <http://ericasadun.com/2016/03/24/immutable-setters/>, may not be language-inclusion suitable), and think binding self in closures is yet a third issue.

Brent, concur?

-- E

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


More information about the swift-evolution mailing list