Re: Subtle memory management error found

2017-09-15 Thread jzakiya
**1)** In **nextp_init** in the line below, **i** can start from eithre '0' or '1'. for i in 0|1..

Re: Subtle memory management error found

2017-09-15 Thread mratsim
The only operator with this gotcha is < right? Maybe it would be best to just deprecate it. Is there unary >? By the way, Nim manual has a part with the discouraged syntax [here](https://nim-lang.org/docs/manual.html#generics-generic-concepts-and-type-binding-rules) proc

Re: Subtle memory management error found

2017-09-15 Thread Araq
He, good catch. In general we advocate to use `..<` instead of `.. <`. I see no alternative to "unary operators bind tighter than binary operators".

Re: Subtle memory management error found

2017-09-15 Thread Jehan
As it turns out, it was a somewhat subtle bug in the code. The compiler is fine. Change the following code: proc segsieve(Kn: int) = # for Kn resgroups in segment for b in 0 ..

Re: Subtle memory management error found

2017-09-15 Thread Stefan_Salewski
> Can you show me how to do that? When you are using the Nim compiler from the command line, then in the current working directory a subdirectory with name nimcache is created. For example "nim c test.nim" creates "nimcache/test.c". You can inspect that intermediate C code. When you have clang

Re: Subtle memory management error found

2017-09-15 Thread Jehan
> The inexorable conclusion is there is a fundamental bug in the structure of > the language which causes this error to occur. Are you sure about this? I found at least one difference between the C++ and the Nim implementation (the first loop in `next_pinit` starts with 1 in C++ and and with 0

Re: Subtle memory management error found

2017-09-15 Thread jzakiya
Actually I'm not a C/C++ programmer, I'm (mostly now) a Ruby programmer who is functional in C++, and haven't really done anything in C of any note. I've been looking to see how to view the C/C++ that Nim is generating but I don't know how to do that. Can you show me how to do that? Remember,

Re: Subtle memory management error found

2017-09-15 Thread Stefan_Salewski
> The inexorable conclusion Does your code really only works when uint is used? Because most of us try to avoid using uint, so uint is not that much tested. Have you tried without optimization or different C compiler backend? Have you tried compiling to C++ instead of C? (nim cpp test.nim)? I

Re: Containers of generic types

2017-09-15 Thread Jehan
You can do pretty traditional OOP in Nim if you want to (except for proper abstract methods). Here's an example: # main.nim # Free Public License 1.0.0 # # Permission to use, copy, modify, and/or distribute this software for # any purpose with or without fee is

Re: Too many global variables in a generated js-code

2017-09-15 Thread Araq
Yeah ok, you can only compile a single Nim program to JS. But that program can consist of as many Nim modules as necessary.

Re: Too many global variables in a generated js-code

2017-09-15 Thread Tiberium
@alexsad - don't try to compare JS code compiled by Nim with hand-written JS. It's almost the same if you compare hand-written C++ with C++ code compiled by Nim

Re: Too many global variables in a generated js-code

2017-09-15 Thread Araq
I've heard assembler is very unsafe and low level -- is asm generation possible to avoid with GCC?

Too many global variables in a generated js-code

2017-09-15 Thread alexsad
After compilation to js and run it in the browser I see in developer tools that window object has many variables. You can also detect them in [https://nim-lang.org/docs/theindex.html](https://nim-lang.org/docs/theindex.html) [I've heard global variables are

Re: Containers of generic types

2017-09-15 Thread gokr
In other words, the "problem" is that in order for you to be able to stuff a bunch of items into a "bag", shake the bag, and then pull one out of it - and **still knowing the type of what you pulled out** \- requires storing type information together with each item. Nim, as many statically

Re: Subtle memory management error found

2017-09-15 Thread mratsim
I see that you are using the pairs iterator followed by a if condition in the Nim code. Can you check without? so that it's more in line with the C++ code? for j, prime in primes: # for each prime r1..sqrt(N) if nextp[row + j] < uint(Kn): # if 1st mult resgroup