well, no, only "with" and "without":
[https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8](https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8)
@Tiberium Oh, that's wonderful! I like Was interface removed too (I'd really
like to use it sometimes)?
Udiknedormin: you can change "take" to "with", since "with" and "without" were
removed from Nim keyword list in devel
@Araq In the opposite order, first declare variables, then a type with fields.
Update: It is now available via Nimble.
I like the idea. It would be nice if it was also specialized for ref not nil
and ptr not nil where nil would map to none. Just like in Rust.
In fact, it would be cool if functional style was generally more common in Nim.
Like standard library widely utilizing option where possible. Also:
As for now, template + getAst seems preferred over quote. Please note it
provides you template hygiene, meaning the symbols are generated, thus your
private variable will actually be private (as it will be treated as a new
_symbol_ rather than an identifier).
import macros
Thank you.
I've read several articles about re-entrant lock, but those articles almost all
discussed in Java as examples.
When I thought whether those were applicable in Nim too and I found two
different modules of lock and with almost same APIs.
It's very easy with "quote do":
import macros
proc my_enter(x: int): int =
echo "my_enter was called"
return x
proc my_exit(x: int) =
echo "my_exit was called"
macro take(args, body: untyped): untyped =
# Value of an argument
While porting my service stuff to Nim I stumbled upon intersting problem: while
there are plenty of GUI binding available at _nimble_, it seems like there are
almost to none support for simple traybar applications, controlled by context
menu and showing balloons.
...And yet I need to port
Thanks!
So if I understand it correctly, this macro usage in your snippet:
take 3 as f:
echo f
Gets expanded to this:
var f = 3
echo f
How can we change the same macro, so that it desugars over to this instead?
var x = 3
var f
11 matches
Mail list logo