Re: progress while binding libxl

2017-10-21 Thread alfrednewman
Hello @oyster Ssorry to ask, but how is the process going with the libxl binding ? I need to work with a project where reading and writing Excel files will be an important prerequisite ... figuring that there is not yet a component in Nim to get the job done, I will have to perform the

Re: procs where you forget to return a value

2017-10-21 Thread jackmott
Thanks Dom, done.

Re: procs where you forget to return a value

2017-10-21 Thread dom96
Please report this as an issue on GitHub.

Re: Which FUSE library shall I use?

2017-10-21 Thread dom96
I would say zielmicha's library. It seems to be more recently maintained, and he's more active in the Nim community. That said I haven't used either of these so I could be very wrong.

Re: How to store procs of different arguments and return values

2017-10-21 Thread Arrrrrrrrr
You can if you add {.nimcall.} pragma: cast[(proc(x: int): int {.nimcall.})](p) I think it doesn't work because, without this pragma, compiler thinks this is a closure, and closures have a greater size than normal proc pointers, that's the reason why the casting is not

Re: How to store procs of different arguments and return values

2017-10-21 Thread dawkot
Well then, why can't I specify proc's type instead of relying on type()? proc myProc(x: int): int = x + 1 let f: proc(x: int): int = myProc let p: pointer = cast[pointer](myProc) let casted = cast[proc(x: int): int](p) #expression cannot be cast to proc(x:

Re: How to store procs of different arguments and return values

2017-10-21 Thread Arrrrrrrrr
[Run code](https://glot.io/snippets/eur6yblvzq): proc print(i: int) = echo i proc plus(a, b: int): int = a + b let procs = [cast[pointer](print), cast[pointer](plus)] cast[type(print)](procs[0])(1) echo cast[type(plus)](procs[1])(1, 2)

Re: project organization question

2017-10-21 Thread stisa
You can also use nimscript to create the dir ( eg `mkdir "tests"`), or do some nice things like build all tests in a dir, eg import ospaths task tests, "Runs tests": withdir "tests": for file in listfiles("."): if splitfile(file).ext == ".nim":

How to store procs of different arguments and return values

2017-10-21 Thread dawkot
Since cast doesn't seem to work on procs, what are the alternatives?

Re: project organization question

2017-10-21 Thread jackmott
I think I found the answers I need here: [https://github.com/nim-lang/nimble#project-structure](https://github.com/nim-lang/nimble#project-structure) In case anyone else finds this with a search, this worked: # Package version = "0.1.0" author= "Jack

Re: Arrays, openarrays, and sequences

2017-10-21 Thread jackmott
awesome, yes this is perfect!

project organization question

2017-10-21 Thread jackmott
>From looking at other nim repos, it looks like the accepted pattern if you are >making a library is to have a src directory under your pojects root directory >with the library code. Then an example directory under the root for example >code. How do you set this up so that you can conveniently

Re: What's happening with destructors?

2017-10-21 Thread adrianv
@rayman22201 what I have seen is, that each proc that has a var of a type which is handled by a destructor needs a hidden try finally block (currently even if the var is not used). This can be a big overhead for small routines. The c target needs setjump/longjump which is a big overhead. The

Re: What's happening with destructors?

2017-10-21 Thread monster
@Araq I wanted to "show my appreciation" for this new development, but BoutySource doesn't let me leave a comment. I'm "skunkiferous" there; I think "monster" was already taken...

Re: procs where you forget to return a value

2017-10-21 Thread leledumbo
I agree that a simple code like this: proc p: int = echo "test" var x = p() echo x should issue a warning (like in Pascal). Error is fine, too (like in Java), since it's very seldom an intention to do so.

Re: procs where you forget to return a value

2017-10-21 Thread Arrrrrrrrr
In my experience, this is an issue you run into when lacking experience using nim. Then it stop giving you problems. Could be a good idea to warn under these circunstances.

Re: Arrays, openarrays, and sequences

2017-10-21 Thread Arrrrrrrrr
> do the array get copied when you call the function No. > accept a sequence OR an array, in an efficient manner openArray is the way.

Re: Problem using

2017-10-21 Thread jzakiya
The `cnt +=` operation in parallel is ripe for creating a `reduction` like option for Nim that's in `OpenMP`. [https://stackoverflow.com/questions/13290245/reduction-with-openmp#13290673](https://stackoverflow.com/questions/13290245/reduction-with-openmp#13290673)

procs where you forget to return a value

2017-10-21 Thread jackmott
I spent about an hour tonight tracking down a weird bug where it turned out I had a proc with a return value, but I forgot to return a value. This compiled fine, but ran wrong. I assume what happened is that the implicit return value was returned, with the default value for the type. Should it

Re: Problem using

2017-10-21 Thread jzakiya
OK, I had to clean it up a little to make it work, but here is the code that gets it to compile. var cnt: array[rescnt, uint] parallel: for i in 0..rescnt-1: cnt[i] = spawn segcount(i*KB, Kn) sync() for i in 0..rescnt-1: primecnt +=

Re: What's happening with destructors?

2017-10-21 Thread rayman22201
@araq, I missed the live stream, but watched the recording on youtube. Thank you for taking the time to do the presentation! Very awesome. > The really hard part is replacing the existing runtime with one with a > different performance profile ("yay, deterministic freeing, yay more >

Re: Fastest way to count number of lines

2017-10-21 Thread alfrednewman
Hi, thanks for the help of all of you. Yes, I'm pre-calculating things. In the data orchestration process I'm involved in, I can usually estimate the time of a rendering based on the number of rows I'm processing. It is a linear process and the processing time is typically not much affected as

Arrays, openarrays, and sequences

2017-10-21 Thread jackmott
A couple of quick questions: If I have a function that accepts an array as input via an openarray, do the array get copied when you call the function, or no? Is it possible to write a function using generics, or otherwise, that can accept a sequence OR an array, in an efficient manner?

Re: Fastest way to count number of lines

2017-10-21 Thread cblake
Yeah..Depending on what he's doing, same-file dynamic estimation might also work. Good point, @jlp765. On my system the 5.4 MB of `/usr/share/nim/**.nim` gets counted in about 4 milliseconds - over 1.3 GB/sec, probably faster than all but the most powerhouse nvme/disk array IO. This is why I

Re: Problem using

2017-10-21 Thread jlp765
try var cnt = array[rescnt, int] parallel: for i in 0..rescnt-1: cnt[i] = spawn segcount(i*KB, Kn) sync() for i in 0..rescnt-1: primecnt += cnt[i].uint

Re: Fastest way to count number of lines

2017-10-21 Thread jlp765
How giant is a "giant text file"? On my machine a 75M file takes roughly 0.12 sec to count the lines (it is dummy data, so not very random). If GigaBytes in size, then close enough might be good enough I didn't see @cblake mention it, but you could count the bytes to read 100 lines of a big