[swift-evolution] "with" operator a la O'Caml?
erica at ericasadun.com
Tue Dec 20 12:59:51 CST 2016
Cascading falls under a separate proposal. There's an intermediate form which stagnated here: https://gist.github.com/erica/6794d48d917e2084d6ed <https://gist.github.com/erica/6794d48d917e2084d6ed>
As Xiaodi Wu pointed out, you can introduce an implementation of `with` that uses reflection but that would be deferred to a later date when reflection itself gets updated.
> On Dec 20, 2016, at 7:44 AM, Martin Waitz <tali at admingilde.org> wrote:
> Am 2016-12-19 20:44, schrieb Erica Sadun via swift-evolution:
> I don't like where this is heading.
> If you want to introduce method cascading, then have a look at Dart.
> E.g. the example from the pull request could be something like this:
> let questionLabel = UILabel()
> ..textAlignment = .Center
> ..font = UIFont(name: "DnealianManuscript", size: 72)
> ..text = questionText
> The expression could still work on a mutable struct/class which later becomes
> immutable by using the `let` assignment.
> The other example which silently creates a new instance is even worse.
> If you want to do something like this, then please do it more explicitly.
> let fewerFoos = foos.clone()
> ..remove(at: i)
> Anyway, all of this is simply syntactic sugar and should wait...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution