Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread ElegantBeef
I reimplemented the logic to something I could follow the best I could, and added a line to the data just for testing, and also added a test procedure to showcase "how" one may test this logic. By including `C, B, C` we've now added atleast some data to test our code, this can be expanded to inc

JS FFI - getting started

2021-05-25 Thread mantielero
Right now I provide the data as: var tabledata = @[ js{ id:1, name:"Oli Bob".cstring, age:"12".cstring, col:"red".cstring, dob:"".cstring }, js{ id:2, name:"Mary May".cstring, age:"1".cstring, col:"blue".cstring, dob:"14/05/1982".cstring }, js{ id:3, name:"Chri

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread masiarek2
hi @Zoom, I really appreciate your feedback. Yes, I want to learn programming - so any feedback is very much appreciated. I am looking for a mentor to guide me: what to learn in what sequence, do's and dont's, etc. It sounds my first assignment is to learn using new types in my small educational

Native integration of Nim and JavaScript/TypeScript

2021-05-25 Thread alexeypetrushin
I recently [converted some Nim ORM code to TypeScript](https://www.reddit.com/r/nim/comments/nkmlvo/nim_vs_typescriptjs_comparing_just_the_feel_of/) and was surprised how similar the source code looks like. If you ignore visual differences of OOP vs Multi-Dispatch, and think at how it actually w

How does no parenthesis function call syntax work?

2021-05-25 Thread moigagoo
Imho parenless syntax should only work with unnamed args or even one unnamed arg. Otherwise it looks straight up horrible (this Crystal code is hardly readable imho). Sure, theoretically it may be supported in Nim but if you actually want to call things like `myProc 1, true, length = 10`, then

Nim version 1.4.8 released

2021-05-25 Thread treeform
Thank you to everyone who contributed!

Open file > 2GB on raspi OS 32

2021-05-25 Thread RainbowAsteroids
Your issue is that you're trying to read the entire file into memory. Try using buffered reads like `io.readLine`, `io.readBuffer`, `io.readChars`, and `io.readChar`. var file = open("test.file") #echo readAll file # Tries to read all 10 GB of this file (I only have 8GB of ram

How does no parenthesis function call syntax work?

2021-05-25 Thread ElegantBeef
It "may" be a bug, but probably not. What happens is that is evaluated as `someProc(x) = 10`, which can be confirmed with: import std/macros dumptree: someProc x = 10 Run Which shows what is happening it's making it an assign of the return type of the proc

How does no parenthesis function call syntax work?

2021-05-25 Thread timothee
see the question is: how can we improve things here without introducing parser ambiguties?

Nim version 1.4.8 released

2021-05-25 Thread timothee
> Based on our testing, this shouldn't happen with v1.4.8.

How does no parenthesis function call syntax work?

2021-05-25 Thread RainbowAsteroids
I'm no Nim expert, but that seems like more of a bug than intentional behavior to me, because that last call compiles when there are parenthesis.

IRC freenode staff exodus

2021-05-25 Thread RainbowAsteroids
I would love to join a Matrix server if we have one. People are saying that Nim has a gitter server, but I don't know if that's the same thing.

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread Zoom
> Would you give me permission to move your code to GitHub: > > or, even better (post your code > directly to GitHub) - I am still learning GitHub... To be frank, I wrote my piece of code strictly as an educational vehicle and I don't really see the poi

How does no parenthesis function call syntax work?

2021-05-25 Thread gavr
I noticed that calling functions without parentheses with named arguments (Smalltalk like) behaves very strange, maybe it's a bug. For example, here is the code of Crystal and similar Nim. def some_method(x, y = 1, z = 2, w = 3) # do something... end some_method 1

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread konradmb
> Looks like a bug. You should report it on GitHub Issues. Yes, @masiarek2 is right. It's not a bug. In [Nim manual](https://nim-lang.org/docs/manual.html#overloading-resolution), you can read that "If multiple routines match equally well, the ambiguity is reported during semantic analysis." Si

Porting to Nim

2021-05-25 Thread asrp
So I'm mostly calling [pop](https://github.com/nim-lang/Nim/blob/version-1-4/lib/system.nim#L1824) which looks like it will `shrink` instead of just `setLen` in Nim V2 but I'm still on 1.4.6 so it should be good for now. I've been adding a `return DefaultValue` at the end of each function. Impl

Porting to Nim

2021-05-25 Thread asrp
Hmm, so unless I'm misunderstanding, that example reads all the tokens from the file and returns them all in a `seq` but I'm looking to only read one token at a time so that not all tokens are in memory at the same time. So if the file contents is one two 1234 )(*& three

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread masiarek2
hi Guys, Wow - I really appreciate your help! Would you give me permission to move your code to GitHub: This is a non-profit organization (STAR Voting) - so big THANK YOU! Test Case 'Use01' \- passed *

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread masiarek2
It sounds like this is by design- this is Nim’s way ... most of the time I love current behavior

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread ElegantBeef
It's just how the Nim overloading works, the most specific procedure is taken unless that is ambigous. A simple example to showcase this is: proc echo(a: int) = for x in 0..a: echo "hmm" echo 10 system.echo 10 # Force it to use the less specific `echo`

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread kaushalmodi
Looks like a bug. You should report it on GitHub Issues. I have seen compilation errors for ambiguous cases, but this one somehow does not show up

Porting to Nim

2021-05-25 Thread ElegantBeef
Seq's have a fixed growth rate and shrinking them using `setLen` shouldnt change the capacity. Macros have very good introspection, you can read the entire procedure body from one and even add to/remove parts of it. As procedures have a implict result, you can either make a macro to set the de

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread masiarek2
It seems that the method call is being ambiguous ... Any other examples? I am learning looming for other potential gotchas... import sequtils var x = repeat("ab", 3) echo x.type, ": ", x# seq[string]: @["ab", "ab", "ab"] echo("\n *** now import both sequtils and

Porting to Nim

2021-05-25 Thread asrp
Thanks. If its fairly easy to get speeds comparable to C then it'd be worth a shot. There were no allocations except at the very beginning in the C version. Though in the port I plan to use some allocations for strings. Does `seq` growing and shrinking a lot result in a lot of allocations? I'll

Porting to Nim

2021-05-25 Thread kaushalmodi
> And I only need it for "%s", which is to read the next whitespace delimited > token. Then strscans or npeg will do the job. > Does npeg work on strings or just files? Check out . `npeg` works on strings, and so it works on files too.

Porting to Nim

2021-05-25 Thread bpr
> the main reason for porting is ergonimic Love it!

JS FFI - getting started

2021-05-25 Thread mantielero
Ok. My error was that I need to convert all the strings to `cstrings` everywhere.

Porting to Nim

2021-05-25 Thread asrp
(Also replying to @kaushalmodi.) So I'm specifically looking to read from a file. And I only need it for `"%s"`, which is to read the next whitespace delimited token. If I use `readLine` then I need reposition the filehandler, which is what I've done (which seems a bit inefficient and ugly).

JS FFI - getting started

2021-05-25 Thread mantielero
Thanks. I found that I need to use `cstring` on the `tabulator` declaration. I am also defining the options as follows: var opts = newJsObject() opts.height = 205 opts.layout = "fitColumns".cstring #opts.columns = columns Run But I am stuck with the column

Export in JS backend

2021-05-25 Thread juancarlospaco

c2nim -- minor update

2021-05-25 Thread greenfork
I'm a big fanboy of c2nim, keep up the good work!

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread xigoi
Why not use a CSV parser?

Export in JS backend

2021-05-25 Thread xigoi
When complling to JavaScript, is there a way to add the `export` keyword to some functions in the resulting code, so it can be used as an ES6 module?

I have released a library that allows you to use MySQL, Postgres and Sqlite3 together.

2021-05-25 Thread sivchari
I have released a library that allows you to use MySQL, Postgres and Sqlite3 together. the library name is `db_wrapper`. There is an official database library for Nim, but it does not implement connection pooling. However, this library (db_wrapper) allows connection pooling to be set at connect

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread Zoom
Here's my stab at the problem. Hopefully, well-enough commented and not too buggy. It's way too imperative to my taste, but I didn't find enough functional primitives to elegantly process data _and_ have enough escape hatches to validate it at the same time. I also don't know exact specs of how

Porting to Nim

2021-05-25 Thread PMunch
Generally your binary will run about the same speed as C if properly optimised (remember to enable a release build with `-d:release`, if you run into issues with speed you probably have a lot of unnecessary allocations somewhere). c2nim is mostly used to create library wrappers, so it's not real

JS FFI - getting started

2021-05-25 Thread jyapayne
`table.setData` returns a `JsonObject`, so you have to capture that in a variable otherwise Karax will think that you want to use it as a `VNode` (even though you have it marked as discardable).

Fortran to Nim?

2021-05-25 Thread HJarausch
Are there some tools to aid converting a Fortran source code into Nim? Many thanks for some pointers, Helmut

Porting to Nim

2021-05-25 Thread kaushalmodi
> I don't know how to do certain things in Nim. Like fscanf(f, "%s", buffer). Check out [readLine](https://nim-lang.github.io/Nim/io.html#readLine%2CFile%2Cstring) If you haven't already, also check out [Nim for C programmers](https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers). I am n

Porting to Nim

2021-05-25 Thread miran
> Another thing that slows down porting is that I don't know how to do certain > things in Nim. Like `fscanf(f, "%s", buffer)`.

Porting to Nim

2021-05-25 Thread asrp
I'm strongly considering porting a project to Nim. It is a single 1.7k lines C file (not C++). I've ported the core over with some refactors to see how working with Nim is since the main reason for porting is ergonimic. **Now I 'd like to get an idea of how fast the binary will run, but without

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread leorize
Please run `nimsuggest --version`

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread leorize
> I had to remove the plugin anyway because the semantic highlighting was > terribly slow. If you ever try the plugin again, can you try adding this to your init.vim? let g:nim_highlight_wait = v:true Run The main thing it does is to only update highlighting after you

c2nim -- minor update

2021-05-25 Thread mantielero
> How does it mesh with nimterop? I haven't succedded playing with it, but nimterop can use `c2nim` through [c2nimport](https://nimterop.github.io/nimterop/cimport.html#c2nImport.m%2C%2Cstring%2Cstring%2Cstring%2Cstring).

Nim segfault when used via CFFI in Python

2021-05-25 Thread Clonk
I don't know why it segfault, but if you want to use Python ad Nim together you really should use Nimpy and Nimporter.

Accessing object in seq of parent type

2021-05-25 Thread paulpraveen23
thanks for code.

CPU Benchmark test via Nim-compilation

2021-05-25 Thread inv2004
M1 looks pretty impressive now

Nim version 1.4.8 released

2021-05-25 Thread AMoura
Great news. Can you add download link for ARM and others in the website ?

How to read GeoLite2 mmdb files?

2021-05-25 Thread mrhdias
Thank you @z_! Great, I'll take a look.

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread xigoi
I had the same problem on my phone, but not on my laptop. Also, I had to remove the plugin anyway because the semantic highlighting was terribly slow.

Nim version 1.4.8 released

2021-05-25 Thread miran
**Release highlights:** * Just like our `devel` branch, v1.4.8 is built using `csources_v1`, which means you can use it on **Apple M1** chips. * Version 1.4.6 triggered some false positives with several antivirus softwares. Based on our testing, this shouldn't happen with v1.4.8. * Now you

Accessing object in seq of parent type

2021-05-25 Thread konradmb
> it's not the way to do it. Yes, I know. The correct way would be this: type TokenKind = enum tkDigit, tkNumber Token* = ref object of RootRef case kind: TokenKind of tkDigit: valueInt: uint

Accessing object in seq of parent type

2021-05-25 Thread konradmb
> Nim does not store type information at runtime, except for inheritable > objects. So how `method` would work without it?

Nim segfault when used via CFFI in Python

2021-05-25 Thread f3k
When compiled as executable the code works fine, called via FFI in Python a segfault is raised, what do I miss ? **hcj.nim:** `` import json proc nim_add(num1: int, num2: int): int {.exportc, cdecl, dynlib.} = return num1 + num2 proc validate(num1: int): int {.exportc, cdecl, dynlib.} =

How to escape colon in the '&' macro in strformat ?

2021-05-25 Thread miran
> 1.6 doesn't build for me via choosenim There is no 1.6 yet. You can use `devel` for the latest Nim.

Accessing object in seq of parent type

2021-05-25 Thread konradmb
Yes, I've mentioned it before, thanks for code.

Accessing object in seq of parent type

2021-05-25 Thread ynfle
My guess is because the objects are inheritable

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread ynfle
What version is your nim compiler? `nim -v`

How to read GeoLite2 mmdb files?

2021-05-25 Thread z_____________
There's my [nim-mmdb](https://github.com/z-/nim-mmdb) which is a pure Nim implementation and is reasonably feature-complete as far as I know; see [here](https://github.com/z-/nim-mmdb/blob/9a4138d94dc044a82a97902c412f0f590e92054d/src/mmdb.nim#L437) for example usage. (C

Why union type for proc argument fails to compile?

2021-05-25 Thread alexeypetrushin
Thanks for suggestions, I eventually refactored the code to avoid need for such cases. For the first example the `{.nimcall.}` compiles but it doesn't capture the scope variables. And for the second example the explicitly specifying type for proc feels too verbose. Would it be worth to add tho