Re: What's wrong with this simple macro?

2017-11-20 Thread Udiknedormin
@dawkot To put it simply, what Araq says is: in the first case, the macro operates directly on procA at compile time so it behaves as expected but in the second case, it actually operates on p argument (which has no implementation as it's not an actual procedure, therefore its implementation is

Re: Macros: How to parse a string and get the type of the expression?

2017-11-20 Thread Udiknedormin
@Jehan The fact that an arbitrary string is ambiguous without a context is probably the reason a context is passed as a separate parameter in Rust macros, I guess. I sometimes miss that possibility in Nim, it would makes tricks unnecessary and macros would be less of magic, I guess.

Re: Can I somehow show context-specific information in an {.error.} ?

2017-11-20 Thread stisa
Mmh there is an error proc in macros that I _think_ does that: [https://nim-lang.org/docs/macros.html#error,string,NimNode](https://nim-lang.org/docs/macros.html#error,string,NimNode)

Re: Can I tell Nim to NOT use *reference* for a var parameter?

2017-11-20 Thread monster
@Araq Here is a minimal example. This is compiled with "vcc". It compiles to C, but not to C++. type VolatilePtr*[T] = distinct ptr T proc toVolatilePtr*[T](t: var T): VolatilePtr[T] = cast[VolatilePtr[T]](addr t) # Pretend we're actually checking it's

Re: Can I somehow show context-specific information in an {.error.} ?

2017-11-20 Thread monster
@stisa Actually, I meant "when sizeof(T) == 1" rather than "if sizeof(T) == 1" (now corrected). But the problem is, that in the real code I want to support multiple paramter sizes, and get a compile time error if the size is unexpected. The example you gave me compiles, but fails at runtime.

Re: nim-lang ui not working with vcc on windows

2017-11-20 Thread frogEye
I have the solution. It was a silly mistake. I had placed libui library at the wrong place. Thanks for the response.

Re: Can I somehow show context-specific information in an {.error.} ?

2017-11-20 Thread stisa
You can use asserts: let b: byte = 42'u8 let c = 42'u16 proc test*[T](t: T): bool = assert(sizeof(T) == 1, "invalid parameter size: " & $sizeof(T)) result = true echo test(b) echo test(c)

Can I somehow show context-specific information in an {.error.} ?

2017-11-20 Thread monster
I'm trying to debug a compilation problem: the generic parameter of a proc doesn't seem to match my expectation, so I'd like to write something like this: let b: byte = 42'u8 proc test*[T](t: T): bool = if sizeof(T) == 1: result = true # ... else:

Re: Arraymancer - A n-dimensional array / tensor library

2017-11-20 Thread Udiknedormin
@mratsim Would you mind if I make a reference to your lib in my bachelor thesis about optimization?

Re: nim-lang ui not working with vcc on windows

2017-11-20 Thread frogEye
To which folder did u copy the libui.h file? I have cloned the libui from git completely into my repository and it exists in the UI folder.