diff options
-rw-r--r-- | lib/pure/net.nim | 4 | ||||
-rw-r--r-- | lib/system.nim | 4 | ||||
-rw-r--r-- | web/news.txt | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim index dbb78c4de..b9764edd3 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -895,6 +895,10 @@ proc send*(socket: Socket, data: string, if sent != data.len: raiseOSError(osLastError(), "Could not send all data.") +template `&=`*(socket: Socket; data: typed) = + ## an alias for 'send'. + send(socket, data) + proc trySend*(socket: Socket, data: string): bool {.tags: [WriteIOEffect].} = ## Safe alternative to ``send``. Does not raise an EOS when an error occurs, ## and instead returns ``false`` on failure. diff --git a/lib/system.nim b/lib/system.nim index b2525c336..f3ef770fc 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3286,6 +3286,10 @@ proc `/=`*[T: float|float32](x: var T, y: T) {.inline, noSideEffect.} = x = x / y proc `&=`* (x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.} +template `&=`*(x, y: typed) = add(x, y) +template `&=`*(f: File, x: typed) = write(f, x) + ## generic 'sink' operator for Nim. For files an alias for ``write``. + ## If not specialized further an alias for ``add``. proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.} ## converts the AST of `x` into a string representation. This is very useful diff --git a/web/news.txt b/web/news.txt index 46a1c5162..e818ed66e 100644 --- a/web/news.txt +++ b/web/news.txt @@ -27,6 +27,8 @@ Library Additions - The rlocks module has been added providing reentrant lock synchronization primitive. +- A generic "sink operator" written as ``&=`` has been added to the ``system`` and the ``net`` modules. + Compiler Additions ------------------ |