Channel is not recognised by VS Code plugin

2020-07-29 Thread Yardanico
For that to be recognized you need a .nim.cfg or a .nims file :) E.g. put a as1.nim.cfg file with contents: --threads:on Run and VSCode will correctly highlight everything.

Channel is not recognised by VS Code plugin

2020-07-29 Thread Serge
Thank you!

Channel is not recognised by VS Code plugin

2020-07-29 Thread Serge
I posted bug report [https://github.com/pragmagic/vscode-nim/issues/166](https://github.com/pragmagic/vscode-nim/issues/166)

some questions on generating dynamic library

2020-07-29 Thread snej
A “const” really only exists at compile time; it’s not something you can export. Try using “let” instead.

some questions on generating dynamic library

2020-07-29 Thread Yardanico
Also by the way, do you know [https://github.com/yglukhov/nimpy](https://github.com/yglukhov/nimpy) exists?

Is possible to declare var by using string as identifier

2020-07-29 Thread Yardanico
That's not really "using a string" though, that's using a Nim identifier

Intellij ( PhpStorm, PyCharm, RubyMine, Webstorm, Clion ) platform

2020-07-29 Thread Yardanico
Well, the most important thing for most editor plugins to add is code completion/go to definition. if IntelliJ IDEA (and other IDEs based on it) support LSP, then you could use nimlsp to add that functionality.

numpy like library for nim

2020-07-29 Thread YesDrX
Hi, I wrote a new project which is a ndarray/dataframe library in nim-lang only ([https://github.com/YesDrX/numnim)](https://github.com/YesDrX/numnim\)). If you are familiar with numpy, you know where I'm going. # DEPENDENCIES BLAS LAPACK nimblas nimlapack # IMPORT import ./src/numnim # EXAMP

some questions on generating dynamic library

2020-07-29 Thread elcritch
What I found is that Nim code can (sometimes) be run from other code without calling NimMain, however, it results in random breakage. Any code dealing with constants or other items requiring initialization will break (printing floats for example). So your DLL code may not need NimMain if it's ca

Is possible to declare var by using string as identifier

2020-07-29 Thread juancarlospaco
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L177-L180](https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L177-L180)

Is possible to declare var by using string as identifier

2020-07-29 Thread hugogranstrom
Here you go, I had to use even more macro magic but it works (for objects at least). I tried to write some descriptive comments to describe what happens but the summary is that we basically unrolls the loop in `createAllVar` at compiletime so we don't have the issues with scopes:

Is possible to declare var by using string as identifier

2020-07-29 Thread hugogranstrom
I think I've got a solution: we write a macro that iterates over the fields of it and creates all the assignments at compiletime. Will be gone for an hour or two though. Just one question, will `it` always be an object?

Intellij ( PhpStorm, PyCharm, RubyMine, Webstorm, Clion ) platform

2020-07-29 Thread xendi
Now there's also Nimatron [https://plugins.jetbrains.com/plugin/14520-nimatron](https://plugins.jetbrains.com/plugin/14520-nimatron)/ which I'm hoping will add project templates and such.

Is possible to declare var by using string as identifier

2020-07-29 Thread hugogranstrom
I see, the reason you get the undeclared identifier error is because of scopes. When you define a var in a for loop it can't be accessed from outside. This is a simplified example: for i in 0 .. 10: var x = 1 echo x # Error: undeclared identifier: 'x' R

How to ensure that all attributes of an object are explicitly set during creation?

2020-07-29 Thread spip
Why is this pragma not the default behaviour? It seems to me that's a better practice to ensure that all fields are initialized by the programmer than relying on the compiler initializing them with a default value. Or at least there could be a compiler define to ensure this default behaviour.

Is possible to declare var by using string as identifier

2020-07-29 Thread wearetherock
I'm trying to filter data with implicit lambda parameter, but still not lucky import macros type Person = object name: string age: int macro createVar(varName: string, value: untyped): untyped = let newVar = ident(varName.strVal)

Is possible to declare var by using string as identifier

2020-07-29 Thread juancarlospaco
template createVar(name, value) = var name {.inject.} = value createVar(variable, 100) Run :)

Combining the output of two worker threads on one channel: Is there a more Nim(-mick) way to do it ?

2020-07-29 Thread Serge
` import os import threadpool import threadpool import strformat var chan: Channel[string] open(chan) proc sayHello() = for i in 0..10: chan.send(fmt"Hello {i} !") sleep(5) chan.send("_hello") proc sayBye() = for i in 0..10: chan.send(fmt"Bye {i} !") sleep(5) chan.send("_bye") spawn sayHello()

Is possible to declare var by using string as identifier

2020-07-29 Thread Stefan_Salewski
You may also try [https://nim-lang.org/docs/manual.html#templates-identifier-construction](https://nim-lang.org/docs/manual.html#templates-identifier-construction)

Is possible to declare var by using string as identifier

2020-07-29 Thread hugogranstrom
I think you need to use a macro to convert the string to a identifier. This is something I hacked together that's pretty clean: import macros macro createVar(varName: string, value: untyped): untyped = let newVar = ident(varName.strVal) # create the new identifier fro

Does Nim implement something similar the the channel / select pattern in Go ?

2020-07-29 Thread Serge
Does Nim implement something similar the the channel / select pattern in Go ? It is useful for dealing with a plurality of incoming messages on many channels concurrently. select { case msg := <-messages: fmt.Println("received message", msg) case sig

Is possible to declare var by using string as identifier

2020-07-29 Thread wearetherock
template createVar(x, v: untyped): untyped = var x = v createVar("name", 100) Run I try above code, but got this error message. Error: identifier expected, but found '"name"' Run

is chan.tryRecv() not supposed to wait for the next item te be sent via the channel?

2020-07-29 Thread Serge
Thank you!

is chan.tryRecv() not supposed to wait for the next item te be sent via the channel?

2020-07-29 Thread Araq
You are looking for ordinary `recv`.

is chan.tryRecv() not supposed to wait for the next item te be sent via the channel?

2020-07-29 Thread Serge
In the code hereunder, if do not put a long enough delay in the loop which calls chan.tryRecv(), the main thread will fail to read from chan and exit, is that the expected behavior of threadpools in Nim? os import threadpool import strformat var chan: Channel[strin

GitHub Actions: workflow to cross compile and release to GitHubRelease

2020-07-29 Thread stisa
I've started using this action: name: Check and update tag on: push: branches: - master jobs: tag: if: github.actor == github.repository_owner runs-on: ubuntu-latest steps: - uses: actions/checko

cross platform symmetric and assymetric cryptography

2020-07-29 Thread federico3
I wrote the [https://github.com/FedericoCeratto/nim-libsodium](https://github.com/FedericoCeratto/nim-libsodium) [https://github.com/FedericoCeratto/nim-gnutls](https://github.com/FedericoCeratto/nim-gnutls) wrappers for the reasons listed so far: implementing cryptography from scratch is alwa

Are json nodes implicitly HasMaps in Nim?

2020-07-29 Thread Serge
Brilliant. Thanks!

Are json nodes implicitly HasMaps in Nim?

2020-07-29 Thread Vindaar
Take a look at the implementation of the JsonNode type here: [https://github.com/nim-lang/Nim/blob/devel/lib/pure/json.nim#L178-L194](https://github.com/nim-lang/Nim/blob/devel/lib/pure/json.nim#L178-L194) As you can see first of all, a JsonNode is a variant object. The JObject kind, which is th

Are json nodes implicitly HasMaps in Nim?

2020-07-29 Thread Serge
in JavaScript Json nodes are also maps... hashtables (more or less). Is it the same with Nim, i.e. is the lookup for keys in a Json node linear or O(n) ? let jsonNode = parseJson("""{"key": 3.14}""") doAssert jsonNode.kind == JObject doAssert jsonNode["key"].kind == JFl

some questions on generating dynamic library

2020-07-29 Thread oyster
I have some question, any hints? Thanks 1\. how to kill the `nimMain` in generated DLL, or in other way, how to do not export `nimMain` in DLL? 2\. Should I call NimMain? I have searched and found that Araq said "You need to also call NimMain at startup, generated by Nim"

Improving BSD support - NetBSD

2020-07-29 Thread euant
Yep, that seems to do the trick. I ran the following from the command line: > nim c -r tests/gc/gcleak2 C -d:release --gc:boehm --tlsEmulation:off Hint: used config file '/home/euant/src/Nim/config/nim.cfg' [Conf] Hint: used config file '/home/euant/src/Nim/config/config.nims

How to ensure that all attributes of an object are explicitly set during creation?

2020-07-29 Thread jibal
> Is there an alternative (and future-proof) way to add a pragma to an object? Nim's error messages can be confusing and vague, but this one is quite helpful: type pragmas follow the type name