> On Sep 15, 2017, at 4:50 AM, Brent Royal-Gordon <br...@architechies.com> 
> wrote:
> 
>> On Sep 12, 2017, at 12:48 PM, Adam Kemp via swift-evolution 
>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>> 
>> @IBAction func buttonDidClick(sender:AnyObject) {
>>     beginAsync {
>>         let image = await processImage(downloadImage(), resize: 
>> self.resizeSwitch.isOn)
>>         displayImage(image)
>>     }
>> }
> 
> Would it be possible to actually fix this? That is, make the code covered by 
> the `await` evaluate synchronous subexpressions first, such that the code 
> sample above is equivalent to this?
> 
>       @IBAction func buttonDidClick(sender:AnyObject) {
>           beginAsync {
>               let $temp1 = self.resizeSwitch.isOn
>               let $temp2 = await downloadImage()
>               let image = await processImage($temp2, resize: $temp1)
>               displayImage(image)
>           }
>       }

That violates the defined order of evaluation for function arguments. You could 
also write code in which the (async) first argument function call has side 
effects that alter the result of the second argument expression. I’m not saying 
that’s good code, but it’s possible, and the language defines the order of 
evaluation so that code like that will have a predictable behavior.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to