Re: How check if expression has a type without triggering compilation failure

2017-04-04 Thread LeuGim
> template filter(expr: untyped) = > > > when compiles(expr): > when expr is seq[bool]: echo "bool" elif expr is seq[int]: echo "int" > else: echo "something else" > else: > echo "can't compile" > > filter(a + b) It seems code-highliting is broken.

Re: Amicable numbers in Nim and a few questions

2017-04-04 Thread petevine
I eventually settled for plain aliases: alias nim-gen='nim c -r -d:release --passC:-mcpu=cortex-a5 --passC:-mfpu=neon --passC:- ftree-vectorize --passC:-fprofile-generate --passL:-lgcov' alias nim-use='nim c -d:release --passC:-mcpu=cortex-a5 --passC:-mfpu=neon

Re: How to create, destroy, and recreate threads

2017-04-04 Thread bpr
@cdunn2001, it looks like it's running for me with the latest on Ubuntu 14.04 and 16.04; I haven't tried on OS X yet.

Re: Procedure which returns procedure

2017-04-04 Thread flyx
Your code does not work because you are using `func` as identifier, which is a reserved keyword. I demangled it a bit and renamed `func` to `fun`: type MyProc1 = proc() MyProc2 = proc(p: MyProc1) MyProc3 = proc(p: MyProc1): MyProc1 proc applyAllSync(funcs:

Re: How check if expression has a type without triggering compilation failure

2017-04-04 Thread cdome
I need something that not going to cause compilation error for the case when expr does not have a type template filter(expr: untyped) = when expr is seq[bool]: echo "bool" elif expr is seq[int]: echo "int" else: discard filter(a + b) #

Re: Procedure which returns procedure

2017-04-04 Thread dmitrys99
Well, initially it is not JS. I'm working on our internal compiler's Nim backend. Original function source (ML-like language): applyAllSync(funcs: [(() -> void) -> void], onAllDone: () -> void) -> void { fold(funcs, \onDoneNothing -> onDoneNothing,

Re: How check if expression has a type without triggering compilation failure

2017-04-04 Thread Arrrrrrrrr
type(expr) -> expr: template filter(expr: untyped) = when expr is seq[bool]: echo "bool" elif expr is seq[int]: echo "int" else: discard filter newSeq[int]() I don't know if this is useful for your usecase tho.

Re: Procedure which returns procedure

2017-04-04 Thread flyx
Your JS is horrible to read as it lacks type information (what is funcs, what is onAllDone, what is doBefore etc). I tried to interpret it but gave up. You should rather explain what you want to do than giving us this piece of code.

How check if expression has a type without triggering compilation failure

2017-04-04 Thread cdome
Hi Hackers, I need to apply different logic in template if the argument has a particular type or is untyped expression. Calling getType() in macro triggers compilation failure for untyped expression. Ideally, something like this. Any ideas are appreciated. template filter(expr :

Re: why is nim install weird?

2017-04-04 Thread Krux02
I can only support the workflow Araq suggested, I do the same. You can then add `~/projects/Nim/bin` to your path, or symlink the binaries from there to a folder that is already in your path. I have `~/bin` in my path and put the symlinks there. `make install` should not be done with any

Re: Procedure which returns procedure

2017-04-04 Thread dmitrys99
I have another question. There is a procedure proc fold*[T, S](arr: seq[T], init: S, op: proc(acc: S, v: T): S): S = for x in arr: init = op(init, x) return init How to implement in Nim this function (Javascript): function applyAllSync(funcs,

Re: why is nim install weird?

2017-04-04 Thread Araq
> The ./install.sh script puts things under standard subdirs for /usr/bin and > /usr/local/bin, but then does something different for other dirs. "Does something different" \-- Like what? But you shouldn't use `install.sh` anyway, manual messing with /usr/bin is bad, Linux got package managers

Re: why is nim install weird?

2017-04-04 Thread hcorion
A better installation and version management system similar to rustup is in development by @dom96 called choosenim. It seems like your on Linux? If so, perhaps your distro has a version of Nim in the repo? Perhaps some work could be done by creating a Flatpack or AppImage for easier

why is nim install weird?

2017-04-04 Thread bkerin
Ok so I've been wanting to try nim for a while and finally did. Right away I hit something I really dislike, and that is that nim has apparently decided to do it's own thing about installation, rather than working like ./configure --prefix=whatever. The ./install.sh script puts things under

Re: How to create, destroy, and recreate threads

2017-04-04 Thread cdunn2001
With that fix on `devel`, it no longer hangs on OSX, but it still seg-faults on Ubuntu.