any way to extra version info from .nimble file?

2020-12-08 Thread saem
nimble dump Better yet: nimble dump --json

Advent of Nim 2020 megathread

2020-12-08 Thread pietroppeter
There is now a detailed postmortem on the outage of day 1: [https://www.reddit.com/r/adventofcode/comments/k9lt09/postmortem_2_scaling_adventures/?utm_source=share&utm_medium=ios_app&utm_name=iossmf](https://www.reddit.com/r/adventofcode/comments/k9lt09/postmortem_2_scaling_adventures/?utm_source=

any way to extra version info from .nimble file?

2020-12-08 Thread jiyinyiyong
Searched and only got this question a year ago / . I noticed we have information in `.nimble` file, can I reuse that information in my code? Or any other alternative?

Obtain type from proc definition

2020-12-08 Thread xigoi
Also check out this stdlib module:

cpp2nim.py - c++ bindings

2020-12-08 Thread timothee
Clang is IMO indeed the correct way to go, it's guaranteed to understand C and C++ unlike treesitter used in nimterop which has difficulty with C++ as used in the wild in large projects. I'd be very intersted in seeing this project translated in nim from python, but still using (lib)clang as th

cpp2nim.py - c++ bindings

2020-12-08 Thread mantielero
I made a quick a (very) dirty piece of code that might be useful to others. It is in python and it uses clang. It seems to handle big projects like OpenCascade (more than 8000 header files) or OpenSceneGraph (215 header files). It creates lots of files but it doesn't mean it works. They might be

Obtain type from proc definition

2020-12-08 Thread inventormatt
yes I found a way to do it . type Handler[T:tuple] = proc(event:tuple): tuple Run

Obtain type from proc definition

2020-12-08 Thread giannigianni
Hi inventormatt, your macro works like a charm! Thank you. About the handler type, my goal is to say: "a procedure (with one parameter that is a tuple) returning a tuple" type Handler = proc(event: tuple): tuple Run

Obtain type from proc definition

2020-12-08 Thread inventormatt
maybe something like this is what you are looking for . I wasn't sure how to get your original handler type to work so it is just an open proc right now but everything else whould work

pop for a set - is there something prettier?

2020-12-08 Thread timothee
`pop` could be added to `std/setutils` (refs , as i argued here having a dedicated sets module instead of system allows growing it without bloating the rest.

Statically Check If An Object Is A Subtype Of Another Object

2020-12-08 Thread timothee
> isa isn't a very motivating example sure, but I was at least referring to title of the thread `Statically Check If An Object Is A Subtype Of Another Object`, for which `is` is enough. Instead of common ancestor, a more interesting primitive (on which common ancestor can be built too) is `pare

when (compiles do: import a): is very broken

2020-12-08 Thread timothee
> A builtin canImport looks much more useful. Actually the one I'd like to implement is `whichModule` () which subsumes `canImport`. const path = whichModule("exitprocs") Run (from which `canImport` is easy to implement,

Obtain type from proc definition

2020-12-08 Thread giannigianni
Hi, i'll try to explain my problem with an example import json import macros type Handler = proc(event: any): any # this type must remain "generic" (not sure if any is the most appropriate) MyEvent = tuple # the name and the fields of the tu

C++ wrap - doubbt on & symbol

2020-12-08 Thread mantielero
Thanks a lot snej

C++ wrap - doubbt on & symbol

2020-12-08 Thread snej
“ref” specifically means a reference/pointer to a tracked (GC'd) heap object. That's not what “&” means in C++. If a C++ parameter is a const reference, that’s equivalent to Nim's regular parameter passing of objects. (Primitives are passed by value; I don’t know if there’s a way to pass one by

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread Stefan_Salewski
I told you already that it may be timing issues. Unfortunately I do know nothing about odbc. I just tested if I can import it, but I can not. And nimble search odbc seems to find it not. Timing issues can occur when threading or async is active. Debugging is generally testing for things for whi

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread protium
> You do access r[i][0] and similar elements without any checks if that > elements exists. In theory, yes, though since I control the schema in the db, I know that the elements are there, even if that's a little sloppy. But either way, what about this point would cause this to be fine when comp

Help with Karax getVNodeById

2020-12-08 Thread sdmcallister
Thank you. Is there any workaround for now?

Help with Karax getVNodeById

2020-12-08 Thread Araq
Use `n.dom.value` instead of `n.text`. But I just added a `getInputText` API mirroring the `setInputText` API.

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread Stefan_Salewski
name: r[i][0].strVal, exportable: r.data(1, i).boolVal, filename: r[i][2].strVal Run You do access r[i][0] and similar elements without any checks if that elements exists. Generally debugging starts there is case of errors, and if I remem

My Gintro program is crashing

2020-12-08 Thread Stefan_Salewski
Unfortunately I don't get a crash. At least not with latest Nim devel, and 64 bit Linux and gintro #head. I compiled with default refc and with arc GC and played some minutes with it. I was hoping that the reason for a crash may be the try/except or the fact that you put the last 3 statements i

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread protium
As @moigagoo requested, I am posting the whole program. It's pretty straightforward. As the first nim programming I have tried, I am happy that it works at all (even if only in a debugging build). import odbc, csv, threadpool setMaxPoolSize(8) type DataFile = objec

pop for a set - is there something prettier?

2020-12-08 Thread Araq
I've said it before but many limitations of sets are the result of lacking a good `bitops` module when I wrote the set implementation. A `pop` for bitsets is definitely not beyond our limits. However, we need to hesitate to add things that are only useful for code competitions. `unicode.reverse`

Help with Karax getVNodeById

2020-12-08 Thread Araq
It's a regression caused by commit 02038d40c1679c8286f145e72643651524319b89

C++ wrap - doubbt on & symbol

2020-12-08 Thread mantielero
I keep on playing with C++ bindings. For the following C++ constructor: ++ gp_Pnt(const gp_XYZ& Coord); Run I was wondering about the **&** symbol. If I understand well, this means that **Coord** would be passed by reference. Am I right? I have doubts about how i

pop for a set - is there something prettier?

2020-12-08 Thread HJarausch
Thanks for all these comments. If I have a set _S_ I can say for e in S : echo e Run Does Nim construct an iterator of S like _items(S)_ [which doesn't work] ? If yes, how is it called - one could assign via let and call it once to an element of a set.

Advent of Nim 2020 megathread

2020-12-08 Thread fxn
Did that anyway, feels cleaner. The top-level code does toSeq(stdin.lines).map(parseInstruction) Run This is the [iterated solution for part 2 (day 8)](https://gist.github.com/fxn/bbd90877bcd27581ee5f7720495c3c3f). Anything else to improve please just tell me!

Advent of Nim 2020 megathread

2020-12-08 Thread fxn
Awesome @mratsim, that's a great explanation and I understand better what was going on. In the original version of the code, then, I guess I could define a function that parses individual lines just fine, and wrap the calls in an external loop, rather than doing everything inside.

Why ORC is the new sliced bread?

2020-12-08 Thread mratsim
Technically openarray are slices and first-class openarray are the new sliced bread but I'll keep my French baguette.

Help with Karax getVNodeById

2020-12-08 Thread b3liever
Funny, I was just playing with karax/examples/toychat.nim ...and get null as well :p

Advent of Nim 2020 megathread

2020-12-08 Thread mratsim
@fxn > In my solutions today, I read the instructions this way: > > type > Instruction = tuple[code: string, arg: int] > proc readInstructions: seq[Instruction] = > > > for line in stdin.lines: > > > var > code: string arg: int > if scanf(line, "$w $i", code, arg): > resul

Why ORC is the new sliced bread?

2020-12-08 Thread miran
New article by @Araq:

Help with Karax getVNodeById

2020-12-08 Thread sdmcallister
I am hoping someone can explain to me why the `inputField` variable seems to always returns null. I also tried gettAttributeById but that returns blank. I'm just playing around trying to understand Karax. Thank you. import karax / [kbase, vdom,kdom, karax, kajax, karaxdsl] impor

Advent of Nim 2020 megathread

2020-12-08 Thread lscrd
> What a pity, I like the conciseness of scanf for this use case because the > pattern visually matches the input and performs parseInt for you, all in one > shot. Yes, you are right and I hesitated to use `scanf` for this reason. I thought about using `scanf` then `parseEnum`, as in your last

In macros, is there a way to know if a symbol as global?

2020-12-08 Thread mratsim
Haha, I knew I remember having seen liftLocals but I couldn't remember the name or thread.

Advent of Nim 2020 megathread

2020-12-08 Thread jrfondren
The warning is on the result.add, not on scanf. You can also fix it by explicitly moving `code`: proc readInstructions: seq[Instruction] = for line in "8".lines: var code: string arg: int if scanf(line, "$w $i", code, arg): result.a

Advent of Nim 2020 megathread

2020-12-08 Thread fxn
Ah, I understood it was on `add`, but did not know about `move`. Thanks!

Advent of Nim 2020 megathread

2020-12-08 Thread fxn
So, with the introduction of opcodes as enum I side-kicked the issue, current version is: proc readInstructions: seq[Instruction] = for line in stdin.lines: var opcode: string arg: int if scanf(line, "$w $i", opcode, arg): result.ad

Advent of Nim 2020 megathread

2020-12-08 Thread fxn
What a pity, I like the conciseness of `scanf` for this use case because the pattern visually matches the input and performs `parseInt` for you, all in one shot. Good point about an enum for opcodes.

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread Stefan_Salewski
> With a regular build, it runs. Of course we may wonder why a program can run well in debug mode but crash when compiled with -d:release. One reason for your database application can be timing issues. "index out of bounds, the container is empty" message may indicate that your Nim code in rel

Advent of Nim 2020 megathread

2020-12-08 Thread lscrd
This is a warning and I don’t think you can do anything to prevent it. But in this case, the copy is not really a problem. You can replace `scanf` and the following statement by these two statements: let fields = line.split(' ') result.add((fields[0], parseInt(fields[1]))

when (compiles do: import a): is very broken

2020-12-08 Thread Araq
> Because you have a good memory and we talked exactly about that construct > about 6 weeks ago Good point. I thought it was because your unique style of choosing titles. Anyhow, iirc os.fileExists is available at compile-time but then you still need to duplicate the compiler's logic for querin

when (compiles do: import a): is very broken

2020-12-08 Thread Stefan_Salewski
Because you have a good memory and we talked exactly about that construct about 6 weeks ago: Or maybe it is because I forget to frame the title with the words "Let us praise Nimrod, the greatest language ever!". But seriously, so I assume there is no o

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-08 Thread jrfondren
Consider this program named bug1.nim: import os, strutils let n = [1, 2] echo n[paramStr(1).parseInt] Run And some runs of it (hiding some options that only make the output less noisy): $ nim r bug1 4 bug1.nim(3) bug1 fatal.nim

My Gintro program is crashing

2020-12-08 Thread Stefan_Salewski
> in an idiomatic GTK program I would add callbacks to the widgets, however I > would have to implement 7 different callbacks for the 7 different widgets > that I am reading data from. Unfortunately that is true. This is the reason I suggested to you to try one of the immediate mode GUIs, for t