Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-30 Thread evacchi
I've reported the issue [https://github.com/nim-lang/Nim/issues/5630](https://github.com/nim-lang/Nim/issues/5630)

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-28 Thread evacchi
that is correct. yet template foo(p: untyped): auto = (block: 1 ) let x = foo: discard won't compile, while this will let x = (block: 1 ) in fact, this compiles as well: template foo(p: untyped): auto

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-28 Thread mashingan
>From example, if you think that's returning something it's indeed returning >exactly `not (a == b)` but not returning a `bool` value. It's only be `bool` >after evaluated in runtime.

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-27 Thread evacchi
> Is it possible to return value from template which the last of argument is > untyped? pretty sure you can: [https://nim-lang.org/docs/manual.html#templates](https://nim-lang.org/docs/manual.html#templates)

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-25 Thread mashingan
Is it possible to return value from template which the last of argument is `untyped`? If possible, maybe some example would be nice I used template with last argument `untyped` for executing that argument (which consists of statements) but never use so that it would return something.

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread planhths
Maybe you should use a proc instead.

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread jlp765
By passing nil (ok, by setting the default to nil), you can get foo3() behaving as follows template foo(_: untyped): auto = echo "foo" 1 template foo2(_: varargs[untyped]): auto = echo "foo2" block: discard 2 template foo3(_:

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread mashingan
Hmm, that's true. I don't know the reason but judging from error, it's said wrong number of argument so need to change to `varargs` to accommodate zero arity. If it's like below, is it ok? template foo(_: untyped): auto = echo "foo" 1 template foo2(_:

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread evacchi
if I understand correcly what you mean I'd expect it to compile with: template foo(p: untyped): auto = (block: 1 ) but it won't

Re: cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread mashingan
I think if you substitutes the template directly into the assignment, it would be assigning a variable from multiple statements.

cannot assign result of a template with block argument unless surrounded by a block expression

2017-03-24 Thread evacchi
Hi, i'm trying to assign the result of a template, but apparently the compiler gets confused unless I surround the template with (block: ...) template foo(p: untyped): auto = 1 let x = (block: foo: discard) let y =