Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-31 Thread Greg Parker via swift-evolution
> On May 27, 2016, at 5:19 PM, Brent Royal-Gordon via swift-evolution > wrote: > >>> - A plain `with` whose closure parameter is not mutable and which is marked >>> `@discardableResult`. >> >> I would like to see this version restricted to AnyObject. It has

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-28 Thread Matthew Johnson via swift-evolution
> On May 28, 2016, at 9:29 PM, Brent Royal-Gordon > wrote: > >>> You are trying to call `mutating` methods on an *immutable* value, the >>> return value of `withCopy`. Normally, the compiler would reject that. >> >> You are right, there would need to be an exception

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-28 Thread Brent Royal-Gordon via swift-evolution
>> You are trying to call `mutating` methods on an *immutable* value, the >> return value of `withCopy`. Normally, the compiler would reject that. > > You are right, there would need to be an exception for method cascades. That > might be a reasonable exception to make because we already know

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-28 Thread Matthew Johnson via swift-evolution
> On May 27, 2016, at 7:19 PM, Brent Royal-Gordon > wrote: > >>> - A plain `with` whose closure parameter is not mutable and which is marked >>> `@discardableResult`. >> >> I would like to see this version restricted to AnyObject. It has extremely >> limited utility

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-27 Thread Patrick Smith via swift-evolution
Just some alternate naming suggestions for with() and withVar(), as the naming guidelines suggest -ed/-ing: withVar altered() // Changes a value copy / reference and returns it mutated() // Or this, but uses value-specific term ‘mutate’ with inspect() // Works with an immutable copy, has

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-27 Thread Matthew Johnson via swift-evolution
> On May 27, 2016, at 5:12 PM, Brent Royal-Gordon via swift-evolution > wrote: > >>> Just mentioning it as to end up... with the proper name for this new >>> function. >> >> Naming can always be bikeshedded. > > One possibility is to split `with` in two: I much

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-27 Thread Alejandro Martinez via swift-evolution
Hi, I really like the proposal as it's in the last draft. And the examples are really good, specially the one that is similar to the Ruby tap. I've been using the Then extension for a while and makes the initialization much nicer. I also use a set of extensions that allow me to print

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-27 Thread Brent Royal-Gordon via swift-evolution
>> Just mentioning it as to end up... with the proper name for this new >> function. > > Naming can always be bikeshedded. One possibility is to split `with` in two: - A plain `with` whose closure parameter is not mutable and which is marked `@discardableResult`. - A `withVar` whose

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-27 Thread Erica Sadun via swift-evolution
On May 25, 2016, at 5:34 PM, Dany St-Amant wrote: > Le 25 mai 2016 à 14:28, Erica Sadun via swift-evolution > > a écrit : > >> Over the past couple of days, the Twitters have discovered some work I'd >> done on

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Dany St-Amant via swift-evolution
> Le 25 mai 2016 à 14:28, Erica Sadun via swift-evolution > a écrit : > > Over the past couple of days, the Twitters have discovered some work I'd done > on closure-based setup. > It's clear that a demand is out there and strong for this kind of behavior, > even

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Matthew Johnson via swift-evolution
> On May 25, 2016, at 4:31 PM, Erica Sadun wrote: > > >> On May 25, 2016, at 3:29 PM, Matthew Johnson > > wrote: >> On May 25, 2016, at 3:56 PM, Erica Sadun > >

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Erica Sadun via swift-evolution
> On May 25, 2016, at 3:29 PM, Matthew Johnson wrote: > On May 25, 2016, at 3:56 PM, Erica Sadun > wrote: >> I wouldn't be pushing if I thought it wouldn't be useful after cascading. If >> no other reason, it offers a

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On May 25, 2016, at 3:56 PM, Erica Sadun wrote: > >> On May 25, 2016, at 2:55 PM, Matthew Johnson wrote: >> >> >>> On May 25, 2016, at 3:48 PM, Jacob Bandes-Storch via swift-evolution >>> wrote:

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Brent Royal-Gordon via swift-evolution
> I'm unfamiliar with `tap` but it looks > similar to method cascading, which is on hold for Swift 4. I *am* familiar with `tap`. It's basically `with(_:update:)`, but as a method and not `inout`, which usually doesn't matter for Ruby since everything is an object in that language. Typically,

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Erica Sadun via swift-evolution
On May 25, 2016, at 2:55 PM, Matthew Johnson wrote: > > >> On May 25, 2016, at 3:48 PM, Jacob Bandes-Storch via swift-evolution >> > wrote: >> >> I like this pretty well, and I think "with()" makes sense as a

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Matthew Johnson via swift-evolution
> On May 25, 2016, at 3:48 PM, Jacob Bandes-Storch via swift-evolution > wrote: > > I like this pretty well, and I think "with()" makes sense as a peer of > "withUnsafePointer()", "withExtendedLifetime()", etc. > > I'd also be okay with waiting for a comprehensive

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Jacob Bandes-Storch via swift-evolution
I like this pretty well, and I think "with()" makes sense as a peer of "withUnsafePointer()", "withExtendedLifetime()", etc. I'd also be okay with waiting for a comprehensive method-cascading solution. I don't find this issue particularly urgent, because it's pretty easily solvable with an

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Erica Sadun via swift-evolution
> On May 25, 2016, at 1:00 PM, Adriano Ferreira wrote: > > Hi all, > > I really like this idea and appreciate the effort. However, I’d rather have a > method similar to Ruby Object#tap and > not a free function. > > Well, since

Re: [swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Adriano Ferreira via swift-evolution
Hi all, I really like this idea and appreciate the effort. However, I’d rather have a method similar to Ruby Object#tap and not a free function. Well, since there’s no "Object class" in Swift, the way I see it is through a protocol, much like the Then

[swift-evolution] [Pitch] Circling back to `with`

2016-05-25 Thread Erica Sadun via swift-evolution
Over the past couple of days, the Twitters have discovered some work I'd done on closure-based setup. It's clear that a demand is out there and strong for this kind of behavior, even without implicit `self` as part of the mix or cascading. In that light, I've put together the following: