Source   Edit  

This module implements the with macro for easy function chaining. See and for details leading to this particular design.

Since: version 1.2.


macro with(arg: typed; calls: varargs[untyped]): untyped
This macro provides chaining of function calls. It does so by patching every call in calls to use arg as the first argument.
Caution: This evaluates arg multiple times!


var x = "yay"
with x:
  add "abc"
  add "efg"
doAssert x == "yayabcefg"

var a = 44
with a:
  += 4
  -= 5
doAssert a == 43
Source   Edit