Actually, Brent’s solution is quite satisfactory.
It is slightly more heavy on the syntax, but I couldn't agree more that
changing the language should be about more than mere syntactic sugars. Swift is
already quite furnished in that department ;)
Thanks for your time.
Best,
Dimitri
PS: I do
Ughh, my bad, let me withdraw this idea:
func saveAndRestore(_ variable: inout T, _ tmpVal: T, body: ()
-> R) -> R {
let savedVal = variable
variable = tmpVal
defer { variable = savedVal }
return body()
}
var contextVal: Int = 0saveAndRestore(, 1) {
print(contextVal)
}
2017-07-03 11:23 GMT+09:00 rintaro ishizaki via swift-evolution <
swift-evolution@swift.org>:
>
>
> 2017-06-28 21:33 GMT+09:00 Dimitri Racordon via swift-evolution <
> swift-evolution@swift.org>:
>
>> Hello community!
>>
>> I’d like to pitch an idea for a user-friendly way for functions to pull
2017-06-28 21:33 GMT+09:00 Dimitri Racordon via swift-evolution <
swift-evolution@swift.org>:
> Hello community!
>
> I’d like to pitch an idea for a user-friendly way for functions to pull
> values from an arbitrary environment. Let me introduce the concept with a
> motivational example before I
> On Jun 28, 2017, at 5:33 AM, Dimitri Racordon via swift-evolution
> wrote:
>
> Using our contextual variables, one could rewrite our motivational example as
> follows:
>
> class Interpreter: Visitor {
> func visit(_ node: BinExpr) {
> let lhs, rhs :
Hello community!
I’d like to pitch an idea for a user-friendly way for functions to pull values
from an arbitrary environment. Let me introduce the concept with a motivational
example before I dig into dirty syntax and semantics. Note that I intentionally
removed many pieces of code from my