Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread Tiberium
well, no, only "with" and "without": [https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8](https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8)

Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread Udiknedormin
@Tiberium Oh, that's wonderful! I like Was interface removed too (I'd really like to use it sometimes)?

Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread Tiberium
Udiknedormin: you can change "take" to "with", since "with" and "without" were removed from Nim keyword list in devel

Re: Code substitution with templates

2017-09-30 Thread Udiknedormin
@Araq In the opposite order, first declare variables, then a type with fields.

Re: Design by Contract in Nim

2017-09-30 Thread Udiknedormin
Update: It is now available via Nimble.

Re: Option type optimizations

2017-09-30 Thread Udiknedormin
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:

Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread Udiknedormin
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

Re: what's the different between lock and reentrant lock in Nim

2017-09-30 Thread mashingan
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.

Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread Tiberium
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

Traybar support ?

2017-09-30 Thread Aiesha_Nazarothi
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

Re: Python-like with, context managers, and the RAII pattern

2017-09-30 Thread wizzardx
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