Help neede with IUP in Nim

2020-12-18 Thread jlp765
Not able to load a DLL is often because: * the DLL is located in a directory that is not in the PATH setting (prove/disprove by copying the iup DLL to the same location of your exe file) * the DLL name is wrong, (like `iup24d.dll` rather than `iup24.dll`, so rename your DLL file) * it is a

One line comprehension equivalence

2020-12-18 Thread buster_blue
I just confirmed this. On stable I got: `Error: expression 'x' is of type 'int' and has to be used (or discarded)`, but when I used choosenim to switch to devel (which was super easy btw) it worked exactly like I thought it would. The results of the operation in parens get collected into a list,

Domain Name System (DNS) protocol and client for Nim

2020-12-18 Thread rockcavera
I've been working on these two packages for some time and finally managed to finish them in a satisfactory and well-documented way. [dnsprotocol](https://github.com/rockcavera/nim-dnsprotocol) \- dns protocol [ndns](https://github.com/rockcavera/nim-ndns) \- dns client The need for these two pa

Is this a supported usecase: update global variables from a dynamic library?

2020-12-18 Thread tommo
"main" and "extension" modules will have their own "As" global var. You need to pass the context of "main" to "extension".

One line comprehension equivalence

2020-12-18 Thread juancarlospaco
Maybe useful

One line comprehension equivalence

2020-12-18 Thread juancarlospaco

One line comprehension equivalence

2020-12-18 Thread b3liever
works with devel without an outer block.

One line comprehension equivalence

2020-12-18 Thread cblake
This also works: import std/sugar template collected(make, iteration): untyped = block: collect(make): iteration echo collected(newSeq, (for i in 1..11: i)) Run

One line comprehension equivalence

2020-12-18 Thread inventormatt
if you really want to get it all on one line you can also do this import sugar echo (block: collect(newSeq):( for i in 1..11: i)) Run

One line comprehension equivalence

2020-12-18 Thread lqdev
Seems like for some reason `collect` doesn't really support being used as an argument directly, but you can circumvent that using a `block`: import std/sugar echo(block: collect(newSeq): for i in 1..11: i) Run

One line comprehension equivalence

2020-12-18 Thread buster_blue
I've been dabbling in this language while I learn Python to compare the 2 languages and see how they're similar and different to use. In Python, you can write code like (just as an example): print([i for i in range(1, 11)]) Run to output a list of 1-10. I know that N

Nim interact with Windows .NET Frameworks

2020-12-18 Thread kcvinu
Wow !!! That's great. I would love to work with Nim with CLR because VB .Net is my favorite.

Advent of Nim 2020 megathread

2020-12-18 Thread Araq
I have no idea what you're doing, but you use `multiReplace`, so you get my upvote.

NodeJS for Nim

2020-12-18 Thread leorize
This should be a good example of how to use npm with nim.

NodeJS for Nim

2020-12-18 Thread leorize
Hopefully you find this useful: It's a node wrapping macro I made for wrapping Github Actions' toolkit, see how to use here:

Advent of Nim 2020 megathread

2020-12-18 Thread e
Sharing an audacious hack from the FORTRAN I compiler described on [this Wikipedia page](https://en.wikipedia.org/wiki/Operator-precedence_parser#Alternative_methods) Prepare the input as follows, and the part 1 no-precedence solution works with the specified precedence: proc repa

jjson or json for Karax?

2020-12-18 Thread Hlaaftana
Standard library modules are mostly implemented in pure Nim (and some are wrappers for C libraries, meaning you can't import them at all). If you import the stdlib json, it's like you are reimplementing JSON in JavaScript. Same goes for tables, JS already has a `Map` type, it's better to wrap th

Advent of Nim 2020 megathread

2020-12-18 Thread ElegantBeef
After seeing that ruby solution I realized I had to do something similar using Nimscripter, so I present my super slow method, abusing operator precedence to solve it in 25 LOC import strutils, nimscripted exportCode: proc `/+`(a, b: int): int = a + b proc `&*`(a, b

Is this a supported usecase: update global variables from a dynamic library?

2020-12-18 Thread gcao
Hi, Is this a supported usecase: update global variables from a dynamic library? I understand in this simplified example, I can probably pass in As to add(). However in more complex applications, if the global variable can not be passed in, is there an alternative way to make this work? types.

Advent of Nim 2020 megathread

2020-12-18 Thread fxn
Finally, solved Part 2 with the `nre` module including subexpressions within parens, listing [here](https://gist.github.com/fxn/335f5736f9578cb2358ed6b488330844).

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-18 Thread mratsim
I think Ada guarantees for embedded in particular with Spark are about ensuring that no inputs or transitions in your state machines will produced undefined or unwanted behavior (no way to switch off autopilot for example, or locked door with no manual override). This is something I also would

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-18 Thread federico3
> I don't think that it's has ever been really successful regarding adoption > (Ada being a prime example of that). Ada is very popular in safety-critical environments, especially aeronautics. FOSDEM has a dedicated developer room with a growing community. Personally, I wish Nim could have simi

jjson or json for Karax?

2020-12-18 Thread sdmcallister
Thank you.

jjson or json for Karax?

2020-12-18 Thread Araq
The Karax specific libraries (jjson, jstrutils, jwebsockets, jdict) are usually better for performance and code size.

Help neede with IUP in Nim

2020-12-18 Thread hotcore
Tried that, but gives error: could not load: iup(|30|27|26|25|24|).dll Error: execution of an external program failed: name-of-my-program> But still, many thanks for trying to help! I appreciate that very much!

jjson or json for Karax?

2020-12-18 Thread sdmcallister
I was just wondering if there is currently a preference for using jjson or the std ib json for karax apps? Are there any situations that might favour one over the other? I'm inclined to stick with the stdlib json but was curious what others are doing. Thanks.

Nim interact with Windows .NET Frameworks

2020-12-18 Thread Aiesha_Nazarothi
Hm. check as well. You may get some idea about further integration (as in, seamless filed access) and event handlers.

Advent of Nim 2020 megathread

2020-12-18 Thread TinBryn
That's much nicer than what I came up with, I was just using `parseExpr` and evaluated the resulting `NimNode` manually.

Advent of Nim 2020 megathread

2020-12-18 Thread jackhftang
Yes, nim macro is Turing complete. Macro solution for part 1. import macros import sequtils import strutils proc `-`(a,b: int): int = a * b macro eval(s: static[string]): untyped = let ns = s.splitLines.mapIt(parseExpr(it.replace("*", "-"))) resu

Advent of Nim 2020 megathread

2020-12-18 Thread TinBryn
I'm wondering could we do similar with macros in Nim, swap the operators, parse into NimNode and swap the operation nodes back.

Advent of Nim 2020 megathread

2020-12-18 Thread fxn
Except for extracting subexpressions between parens, I solved part 2 of today's (18) problem with regexps for a little evilness. However, the hacking pinnacle has been achieved by [this solution in Ruby](https://twitter.com/jhawthorn/status/1339804747394510850).