Re: Nimrad: Nim and Rapid Application Development

2019-11-14 Thread Usor
Thanks. Something akin to Delphi, Lazarus or C++ Builder, where there's WYSISWG visual application development, where code is automatically properly generated, and where you can add code (and edit) as needed, so that you more quickly and more intuitively develop an application.

Resolve ambiguous call to open

2019-11-14 Thread forcefaction
Hi, i'm using let m = memfiles.open("text.txt", mode = fmRead) Run and try to call let f open("another.txt") Run results in Error: ambiguous call; both io.open(filename: string, mode: FileMode, bufSize: int) [declared in

Re: Can I "prune" directories with walkDirRect?

2019-11-14 Thread sky_khan
walkDirRec does recursively search all files/dirs. If you dont want to enter some directories, I guess you need to implement your own recursive "walking" logic with walkDir, then you can have an "exclude_dirs : seq[string]" variable

Re: Collective book about Nim: Fibonacci's algorithm fixed

2019-11-14 Thread edu500ac
Great. In fact, I already found your macros in another thread of this forum. Very interesting work, by the way.

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
Because I'd simply want the user to run `nimble install` without having to provide additional flags when installing my package. This comes from the fact that the user can't use the custom flags that I provide in my nimble package before cloning the repository first. So, it's not possible to do

Help needed on script for compiling Nim programs

2019-11-14 Thread edu500ac
I am using a Makefile script for compiling Nim programs. However, RSDuck suggested the replacement of Makefile with nimscript. I confess that I didn't know anything about the very existence of nimscript, and I want to thank RSDuck for drawing my attention to it. However, in nimscript, I

Re: nim doc generates ugly output for const tables

2019-11-14 Thread juancarlospaco
I dont understand what you mean, but basically it is showing you what the `const` literally is. You can use `macro` to make a custom `nnkCommentStmt`. import macros macro docustom(): auto = newCommentStmtNode("This is my custom Doc") expandMacros: docustom()

nim doc generates ugly output for const tables

2019-11-14 Thread pmags
I'm finding that `nim doc` generates ugly output for tables declared as `const`, presumably because of the compile time expansion. To see what I mean, run `nim doc` on the following example and compare the the way the identical tables are displayed in the let and const sections:

Memory leak

2019-11-14 Thread stbalbach
I've been trying to find a memory leak. The program is processing data retrieved over the net, uploading results to another site, and runs for days at a time with multiple copies running at once. There is no database. After a few days, the memory usage increases to a point then the program

Re: Add custom flags to nimble install

2019-11-14 Thread SolitudeSF
why? if you need to apply configuration you should use nim.cfg or config.nims, not override default actions.

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
The only problem I'm finding now is that, considering that the general `nim.cfg` gets executed before `config.nims`, if I add the `-d:danger` flag to `config.nims`, it doesn't actually get applied to the resulting binary, as the behaviour for `-d:danger` is defined in `nim.cfg`. Is there a way

Add custom flags to nimble install

2019-11-14 Thread vitreo12
Hello everyone, Is there a way to add custom compiler flags (e.g. `-d:danger`) to the `nimble install` task? I know that I can use the `--passNim` flag on the nimble call, but I was wondering if this could be directly abstracted from the user in the nimble file of my package. I tried creating

Re: Resolve ambiguous call to open

2019-11-14 Thread forcefaction
That makes sense. Thank you!

Re: It seems a bit confusing to express the current class object with the first argument.

2019-11-14 Thread dawkot
import macros macro function(x) = var params: seq[NimNode] expectKind x, nnkCommand expectKind x[0], nnkPar expectKind x[0][0], nnkExprColonExpr params.add newIdentDefs(x[0][0][0], x[0][0][1]) expectKind x[1], nnkCommand

Re: Resolve ambiguous call to open

2019-11-14 Thread sky_khan
let f = system.open("another.txt")

Re: Can I "prune" directories with walkDirRect?

2019-11-14 Thread chalybeum
Thanks, I was hoping to avoid that. But it will be a good exercise. I am also thinking of I just call the existing find and read what I need from a temp file. Or could I get significantly faster with implementing it myself?

Re: nim doc generates ugly output for const tables

2019-11-14 Thread juancarlospaco
`const` are compile-time evaluated by definition.

Re: Help needed on script for compiling Nim programs

2019-11-14 Thread juancarlospaco
[https://nim-lang.org/docs/nims.html](https://nim-lang.org/docs/nims.html) [https://github.com/kaushalmodi/nim_config/blob/master/config.nims](https://github.com/kaushalmodi/nim_config/blob/master/config.nims) Check the links may have useful stuff. The syntax and all is the same, so is a little

Re: Add custom flags to nimble install

2019-11-14 Thread juancarlospaco
Use a `config.nims`.

Re: Can I "prune" directories with walkDirRect?

2019-11-14 Thread juancarlospaco
One of the overloads of walkdir takes a Posix Glob that can be recursive and filtering at the same time, kinda `"**/*.pyc"` or similar.

Re: nim doc generates ugly output for const tables

2019-11-14 Thread pmags
I understand what `const` does in terms of compiling a nim program, but I'm looking for a way to deal with the ugly output of nim doc itself. I guess the problem is that nim doc actually compiles each module rather than just parsing?

Re: Add custom flags to nimble install

2019-11-14 Thread SolitudeSF
this doesnt work

Re: Add custom flags to nimble install

2019-11-14 Thread SolitudeSF
what is the point of customTask that is not even defined locally, if you can just add -p:-d:danger?

Re: Memory leak

2019-11-14 Thread stbalbach
Unfortunately I have been unable to do that as mentioned in the post.

Re: Add custom flags to nimble install

2019-11-14 Thread juancarlospaco
$ cat hi.nim echo 42 $ cat hi.nims --define:danger $ nim c hi.nim Hint: used config file '/home/juan/.choosenim/toolchains/nim-1.0.2/config/nim.cfg' [Conf] Hint: used config file '/home/juan/code/temp/hi.nims' [Conf] Hint: [Link] Hint: operation

Re: nim doc generates ugly output for const tables

2019-11-14 Thread mratsim
you can use "when defined(nimdoc)" to do specific thing on nimdoc. In general, compile-time tables and compile-time object variants are ugly when printing due to how it's represented in the VM memory. Unfortunately I think this is a hard problem.

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
Unfortunately, your approach doesn't work because most of the flags that `-d:danger` activates/deactivates are set in `nim.cfg`. In fact, if you look at the binary size of your `hi.nim` file compiled with your method and with the standard `nim c -d:danger hi.nim`, you'll see that the latter one

Re: Memory leak

2019-11-14 Thread Stefan_Salewski
Same behaviour when compiled in debug mode, and with -d:release and -d:danger? Can you try another GC, maybe boehm?

Re: Memory leak

2019-11-14 Thread juancarlospaco
Try to extract a minimal code sample that reproduces the bug, and share it, no way to know without code.

Re: Nimrad: Nim and Rapid Application Development

2019-11-14 Thread juancarlospaco
I prefer a nice DSL over a "RAD" any day. (Used QtDesigner, end up doing UI manually because code kinda sux) So I think DSL are the way to go on Nim.

Prime factorization of Fermat numbers using BigNum/GMP

2019-11-14 Thread drkameleon
I've been trying to implement Pollard's Rho algorithm ([https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm](https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm)) in Nim, using the BigNum module (which in turn uses GMP). Up to the 6th Fermat number (18446744073709551617) it works fine.

Re: SQLite Extension mod_spatialite

2019-11-14 Thread benb
Ok thanks for response, I was thinking about distribution as well and keeping it simplw for end user. Anyhow I will just dig in and have a go and if I get stuck I'll come back more specific. Cheers!

Nimdoc: example of nimscript

2019-11-14 Thread edu500ac
The nim tutorial that the Della-Vos group is slowly writing is here: [https://github.com/FemtoEmacs/nimacros](https://github.com/FemtoEmacs/nimacros) The main novelties are: 1 -- Example of nimscript, suggested by RSDuck and coded by SolitudeSF 2 -- Translation of Fibonacci's Cuniculorum

Re: Memory leak

2019-11-14 Thread mratsim
Try another GC, I know that there are (were) some leaks on small memory allocations that were not returned to the OS. For full debugging, compile with `--debugger:native -d:useMalloc` and pass the program through Valgrind. That will replace all the GC calls by system malloc and Valgrind will

Splat operator

2019-11-14 Thread Stefan_Salewski
Is the solution of Mr Felsing still the best and only solution? [https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim](https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim) Is so, maybe we can tune it and add it to Nim std lib? Splat is

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
That's what I ended up doing, thanks.

Re: Splat operator

2019-11-14 Thread mratsim
I remember that unpackVarargs covered part of the splat needs. [https://nim-lang.org/docs/macros.html#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D](https://nim-lang.org/docs/macros.html#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D) It's in great need of documentation though.

htmlgen `html` macro doesn't allow lang attribute

2019-11-14 Thread benji
[https://github.com/nim-lang/Nim/blob/version-1-0/lib/pure/htmlgen.nim#L314](https://github.com/nim-lang/Nim/blob/version-1-0/lib/pure/htmlgen.nim#L314) Is this on purpose? I need it for auto-hyphenation.

Re: Announcement: Use Nim for programming on Bluetooth chips

2019-11-14 Thread mratsim
I don't know how you design your chips but if you are using Verilog, be sure to checkout this repo: [https://github.com/kaushalmodi/nim-systemverilog-dpic](https://github.com/kaushalmodi/nim-systemverilog-dpic) And awesome news!

Re: htmlgen `html` macro doesn't allow lang attribute

2019-11-14 Thread benji
Not sure if it's proper to have a 'lang' attribute on body tags, but that's a temporary fix.

nimgame.online - open-source nim javascript games (and references to the source)

2019-11-14 Thread JohnAD
I was going to put up one of my games online anyway, so I figured I'd make it more educational: this could be an online repository of javascript nim games with links to the corresponding source code. Details at [https://nimgame.online](https://nimgame.online) If nothing else, it has two of my

Re: Jester performance on FreeBSD is 1/10 of that on Linux

2019-11-14 Thread moigagoo
Could this be because Jester uses HttpBeast in Linux and builtin server on FreeBSD?

Re: Jester performance on FreeBSD is 1/10 of that on Linux

2019-11-14 Thread zulu
We need a reasonably fast multiplatform http server :/

async/await for embedded sysmtems

2019-11-14 Thread foldl
Hi all, I am investigating the possibility of async on embedded systems running a realtime OS. Since the realtime OS (such as FreeRTOS) supports task/semaphore, etc, it is possible to have async just like Windows/Linux. But how? 1\. asyncfutures depends on os. It is (nearly) _impossible_ to

Jester performance on FreeBSD is 1/10 of that on Linux

2019-11-14 Thread Hideki
I compared the performance of Jester on FreeBSD with that on Linux, then the result showed req/sec of Jester on FreeBSD is 1/10 of that on Linux. I changed kernel parameters of FreeBSD; kern.ipc.somaxconn=4096, net.inet.icmp.icmplim=4, but the result did not change much. Load tester(wrk)

Re: ``Table.take`` should be ``Table.pop`` -- discuss

2019-11-14 Thread cblake
@mratsim \- it's not just you. Formatting looks pretty garbled. @araq \- sensible to me to duplicate/alias rather than deprecate. Pretty low-cost.

Re: Nimdoc: example of nimscript

2019-11-14 Thread kaushalmodi
I have few NimScript tasks which you can see in my repo's README: [https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks](https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks) Those tasks are defined in the config.nims in that

Re: Memory leak

2019-11-14 Thread dom96
Are you using async await in your program? In any case, the best way I've found to diagnose memory leaks for long-running programs is by logging the memory usage of each object to something like prometheus. My [prometheus package](https://github.com/dom96/prometheus) can do that automatically

Problems with default GC (and practically any other GC), works fine with --gc:regions

2019-11-14 Thread drkameleon
As I've mentioned in a previous post, I've been working on an interpreter written in Nim ([https://github.com/arturo-lang/arturo)](https://github.com/arturo-lang/arturo\)). The lexer/parser part is handled by Flex/Bison, so I'm basically interfacing with C code (the code calls back my Nim

Re: It seems a bit confusing to express the current class object with the first argument.

2019-11-14 Thread mratsim
Nim main paradigm is structured programming, just like C. Meaning everything is a free-standing procedure. Assuming Nim was OOP-first we could have chosen the Python/C++ approach where "this"/"self" is completely implicit and you don't even see it declared or typed. Or sink into the Java

Re: ``monotimes`` for benchmarking?

2019-11-14 Thread mratsim
The monotimes module seems to be quite new, I wasn't aware of it. Looking into the implementation, yes it should work OK. Otherwise you can use [criterion](https://github.com/LemonBoy/criterion.nim) (it's archived but pretty much finished) or [roll your own with cpuTime / monotimes in a couple

GC_ref & GC_unref - and when to use them

2019-11-14 Thread drkameleon
I've sure read the documentation but I'm still unsure when these two commands are to be used.| I'm interfacing with flex/bison, meaning bison calls Nim routines (with the tokens,ids,etc found), I create the appropriate AST objects and then control goes back to Bison. For example, Bison calls:

Re: Prime factorization of Fermat numbers using BigNum/GMP

2019-11-14 Thread mratsim
The issue is probably not in you algorithm but in memory management. You are using out-of-place routines like `x = (x*x + 1) mod n`, that means an extra allocation at each loop. F(7) is 2^128 + 1 so it does take some space and for F(7) it seems like the GC cannot reclaim that memory. And you

Re: How to divide file in Chunks for multithreaded processing?

2019-11-14 Thread mratsim
You need to do 2 passes. The first pass will lex the files and store either in memory or on disk an array of the starting bytes of each line. Then you divide those lines by the number of cores and process them.

Announcement: Use Nim for programming on Bluetooth chips

2019-11-14 Thread foldl
Hi all, We are a startup in China, making Bluetooth Low Energy chips. We are happy to adopt Nim in parallel with C/C++ in our SDK([1]). There are many benefits to use Nim instead of C. * _Meta-programming_ > With metaprogramming, we can create advertising and GATT profile at compile >

Re: Prime factorization of Fermat numbers using BigNum/GMP

2019-11-14 Thread drkameleon
You're a star! So simple, but I was missing it. I did it with the in-place routines and it worked beautifully! No memory issues, and SUPER fast (relatively). Here's my updated code in case somebody needs it: proc pollardG*(n: var Int, m: Int) {.inline.} = discard

Re: Announcement: Use Nim for programming on Bluetooth chips

2019-11-14 Thread lxdong
It's very exciting to hear this anncouncement. We are Chinese Nim community aims to promote Nim practice globally.As PMunch mentioned, these kind of platforms using Nim are really rare by far, your production would be a great encourage for Nim. I have send you our QQ group number of community

Re: Announcement: Use Nim for programming on Bluetooth chips

2019-11-14 Thread PMunch
Very cool to see that you are supporting Nim! There aren't a whole lot of users on these kind of platforms using Nim yet, but as you mentioned there are some really good reasons to do it

Re: Prime factorization of Fermat numbers using BigNum/GMP

2019-11-14 Thread drkameleon
And... without the one million ugly comments: proc pollardG*(n: var Int, m: Int) {.inline.} = discard mul(n,n,n) discard add(n,n,1) discard `mod`(n,n,m) proc pollardRho*(n: Int): Int {.noSideEffect.} = var x = newInt(2) var y =

Re: GC_ref & GC_unref - and when to use them

2019-11-14 Thread PMunch
GC_ref and GC_unref are required when your Nim code needs to be responsible for keeping track of memory, but you might end up passing things in and out of Nim code. In general they aren't used a whole lot for regular C interop. The important thing to keep in mind here is who is

Re: A taxonomy of Nim packages

2019-11-14 Thread vpashkov
Thank you! I'm the maintainer of the awesome-nim and I'm so tired to maintain this repo. Awesome-nim is now deprecated in favor of Curated Packages.

Re: It seems a bit confusing to express the current class object with the first argument.

2019-11-14 Thread javinyang
Yes, I use multiple operating systems, I am fed up with the free-standing procedure of the c language, but I have to do this (although I can also write oop-like code, but it is a chicken rib in c). but in nim can reflect oop-like, such as the existence of inheritance. But for a lot of reasons,

Re: How to divide file in Chunks for multithreaded processing?

2019-11-14 Thread forcefaction
Hm, so you mean something along this? var linePtr: seq[pointer] var input = memfiles.open("file.txt", mode = fmRead) for line in memSlices(input): linePtr.add(line.data) Run and then i divide the length of linePtr by my core count. This gives me the

Re: How to divide file in Chunks for multithreaded processing?

2019-11-14 Thread mratsim
Good point, Once it's indexed, you can use Nim streams and setPosition: [https://nim-lang.org/docs/streams.html#setPosition%2CStream%2Cint](https://nim-lang.org/docs/streams.html#setPosition%2CStream%2Cint). So you would: 1. Single threaded index the file 2. Single threaded openFile to get