Re: Advent of Code 2018 megathread

2018-12-03 Thread Julien
Hi, I am new in this forum and as a Nim user. I'll post my solutions here: [https://github.com/JulienRobitaille/AoC2018](https://github.com/JulienRobitaille/AoC2018) I use this year advent of code as an opportunity to learn Nim :)

Re: Cross-compiling from Linux to Windows using the -d:mingw flag

2018-12-03 Thread shashlick
If you use devel, this is now straightforward. [https://nim-lang.github.io/Nim/nimc.html#cross-compilation-for-windows](https://nim-lang.github.io/Nim/nimc.html#cross-compilation-for-windows)

Evaluation order

2018-12-03 Thread juanv
echo len"a" + 1 # Ok, parses as len("a") + 1 echo ord'a' + 1 # Error, parses as ord('a' + 1) Run I think the second line must be parsed as the first one

Re: Cross-compiling from Linux to Windows using the -d:mingw flag

2018-12-03 Thread DanielSokil
This has worked for me: $ sudo apt-get install mingw-w64 $ nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc c src/uitest.nim

Re: Advent of Code 2018 megathread

2018-12-03 Thread king3vbo
I recently picked up Nim In Action and have been reading through it, so here's a perfect way to get some practice in. I'm in PST so my place on the private leaderboard is pretty abysmal so far. repo:

Re: How to lookup the IPV6 addr of a domain name?

2018-12-03 Thread moerm
The getAddrInfo call doesn't return the full struct (only to 0xfff1). Moreover the first couple of bytes are _not_ part of the IPv6 address and the first address byte is the 5th byte after 0x50 (0x20, 0x1, ...). Frankly, I don't think it worth putting more work into the current solution. If

Re: How to lookup the IPV6 addr of a domain name?

2018-12-03 Thread Libman
I am confused by lots of things, including that the same constants like AF_INET6 are present with different values in `lib/nativesockets.nim` vs `lib/posix/posix_linux_amd64_consts.nim`. The edited above code now uses posix's AF_INET6 value (10.cint) cast to nativesockets Domain enum for

Auto-dereferencing doesn't seem to work?

2018-12-03 Thread mp035
Hi All, I'm writing a small app, and using the JSON module I have a section of code like this: var json_response = parseJson(response.body) echo $json_response["settings"]{"pollingRate"}[].kind Run Which works. But, this doesn't: var json_response

Re: How JSON object Syntax relates to table and array syntax?

2018-12-03 Thread mp035
Thanks for the clarification.

Re: toSeq(countTable.values) doesn't work

2018-12-03 Thread Araq
sequtils.toSeq(...) Run should work even with `nre`, or do `import nre except toSeq`

How do I get the process ID of the current program?

2018-12-03 Thread timothee
https://github.com/nim-lang/Nim/pull/9846

Re: toSeq(countTable.values) doesn't work

2018-12-03 Thread filip
You are right and I'm a fool for not providing the whole code. In my original code I imported `nre` and the following can be seen in the documentation for that library: : If you love sequtils.toSeq we have bad news for you. This library doesn't work with it due to documented

Re: Explaination on GC-safety warning of Nim compiler

2018-12-03 Thread nepeckman
I'm far from a Nim expert, but I think GC safety is determined by access of global variables. Does this section of the manual reference anything useful? [https://nim-lang.org/docs/manual.html#threads-gc-safety](https://nim-lang.org/docs/manual.html#threads-gc-safety)

Re: toSeq(countTable.values) doesn't work

2018-12-03 Thread nepeckman
This file compiles and executes as expected for me: import tables, sequtils var counter = initCountTable[char]() echo toSeq(counter.values) Run Not sure why it isn't working for you. What version of the Nim compiler are you using?

toSeq(countTable.values) doesn't work

2018-12-03 Thread filip
This works: var counter = initCountTable[char]() for v in counter.values: echo v Run Documentationation says `toSeq()` "transforms any iterator into a sequence" so I would except this to work: var counter = initCountTable[char]() echo

Re: Advent of Code 2018 megathread

2018-12-03 Thread preempalver
Did day 3. Things I've missed in nim: "difference" for OrderedSet, or a method to convert back to a HashSet so I can apply difference. Ended up just declaring the set as HashSet; OrderedSet was useful to visualize, but not necessary. Better tutorial for regular expressions. Ended up with

Explaination on GC-safety warning of Nim compiler

2018-12-03 Thread liwt31
Hello, I'm new to Nim and I'm learning it by making some little apps, reading _Nim in Action_ and so on. During my exploration I found that with higher verbosity level the compiler complains my code on GC-safety with a warning like `Warning: not GC-safe: 'foo()' [GcUnsafe]`. I've tried to look

Compile time vs run time

2018-12-03 Thread allenvarna
Runtime and compile time are programming terms that refer to different stages of software program development. Compile-time is the instance where the code you entered is converted to executable while run-time is the instance where the executable is running. The terms "runtime" and "compile

Re: CountTable.inc() causes Error: unhandled exception: index out of bounds [IndexError]

2018-12-03 Thread mratsim
Unfortunately this is the doc generator that works like this. But you can raise a feature request to give more visibility: [https://github.com/nim-lang/Nim/issues](https://github.com/nim-lang/Nim/issues) (or change the title of this thread so that people can see the new subject at a glance).

Re: How JSON object Syntax relates to table and array syntax?

2018-12-03 Thread mratsim
You're almost spot on. The limitation is that the types must be known at compile-time. The value can be set at runtime.

Re: Heterogen lists

2018-12-03 Thread andrea
Great if that works for you! In any case, the constraint on types comes from the fact that the only way to construct an HCons is with the cons function (because the h and t fields are private) and the only two exported overloads only allow valid constructions

Re: CountTable.inc() causes Error: unhandled exception: index out of bounds [IndexError]

2018-12-03 Thread jimbo1qaz
Thanks for the table-clear hint... i swear i'll finish my Advent of Code someday... > Global example code can be done before the type definitions Procs and methods > are already below there type definitions In

walkDir doesn't raises OSError Exception

2018-12-03 Thread timesurfer
I'm trying to figure out how to handle error if there are issues with directory permission and user is not able to walk into. as per os.walkDir I think it should raise OSError exception iterator walkDir(dir: string; relative = false): tuple[kind: PathComponent, path: string]