mth/yeti — pull request #14 by chrisichris (2014-10-13 10:39:01+00:00)
Title: enable with sections ie (with {x = 1}) is sugar for do x: x with {x = 1}...

It would be good if 'with' could be used partially like an operator. So that

(with {foo = 1})

is sugar for

do x: x with {foo = 1} done

The main reason to add this sugar ist to use with as an update operation for default values instead of the extend sematics of the 'normal' with.

If you have a structure with default values ie

default = {value1 = 1,value2 = true};

and want to update it to change value1 put make a typing mistake ie

default with { valu1 = 2}; //gives {value1 = 1, value2 = true, valu=2} instead of the intended {value1 = 2, value2 = true}

So that the compiler can check that it is better to:

do x: x with {valu1=2} done default //this would give a compile error

and even shorter and IMO consisten with the "opertor-style" of with would be:

(with {valu1=2}) default

This patch seems to bring that - hopefully.

Thanks