the stdlib supports &= in more contexts; refs #3524
This commit is contained in:
parent
ef36a9dc3d
commit
cc925d97f4
3 changed files with 10 additions and 0 deletions
|
|
@ -895,6 +895,10 @@ proc send*(socket: Socket, data: string,
|
||||||
if sent != data.len:
|
if sent != data.len:
|
||||||
raiseOSError(osLastError(), "Could not send all data.")
|
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].} =
|
proc trySend*(socket: Socket, data: string): bool {.tags: [WriteIOEffect].} =
|
||||||
## Safe alternative to ``send``. Does not raise an EOS when an error occurs,
|
## Safe alternative to ``send``. Does not raise an EOS when an error occurs,
|
||||||
## and instead returns ``false`` on failure.
|
## and instead returns ``false`` on failure.
|
||||||
|
|
|
||||||
|
|
@ -3286,6 +3286,10 @@ proc `/=`*[T: float|float32](x: var T, y: T) {.inline, noSideEffect.} =
|
||||||
x = x / y
|
x = x / y
|
||||||
|
|
||||||
proc `&=`* (x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
|
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.}
|
proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
|
||||||
## converts the AST of `x` into a string representation. This is very useful
|
## converts the AST of `x` into a string representation. This is very useful
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ Library Additions
|
||||||
|
|
||||||
- The rlocks module has been added providing reentrant lock synchronization
|
- The rlocks module has been added providing reentrant lock synchronization
|
||||||
primitive.
|
primitive.
|
||||||
|
- A generic "sink operator" written as ``&=`` has been added to the ``system`` and the ``net`` modules.
|
||||||
|
|
||||||
|
|
||||||
Compiler Additions
|
Compiler Additions
|
||||||
------------------
|
------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue