Re: Nim extension libs for python

2019-12-05 Thread hugogranstrom
I haven't tried this one out but it might be worth a look [https://github.com/Pebaz/nimporter](https://github.com/Pebaz/nimporter)

Re: Nim extension libs for python

2019-12-05 Thread sflennik
I’ve been thinking about this problem for a while too. I copied Jonesmartinze three options here and numbered them for easier reference. 1\. create a source distribution of .py and .c files. The end user builds this so it matches their system architecture/OS. 2\. and/or create platform specifi

Re: Sublime Text 3 support

2019-12-05 Thread Hendrik
Awesome thanks e!

Re: {.gcsafe.}, What does {.threadvar.} do to make a function gcsafe?

2019-12-05 Thread mp035
Thank you @mratsim. I did a lot of research and found an old github issue discussing implementing threads in asynchttpserver. Araq closed it without action noting that httpbeast is available, which is esentially a multithreaded server. Do you think I should file an issue requesting the removal o

Re: Most efficient way to implement a stack using Nim?

2019-12-05 Thread treeform
I agree on newSeqOfCap, reallocations can be expensive.

Re: Most efficient way to implement a stack using Nim?

2019-12-05 Thread sschwarzer
If you know roughly how large the stack seq can get, you may want to try [https://nim-lang.org/docs/system.html#newSeqOfCap%2CNatural](https://nim-lang.org/docs/system.html#newSeqOfCap%2CNatural) to avoid or reduce reallocations. In a small benchmark I wrote some time ago, using `newSeqOfCap` to

Re: Most efficient way to implement a stack using Nim?

2019-12-05 Thread zevv
I use seqs as stacks extensively in one of my projects, and I found these are generally ok _unless_ you need to unwind your stack frames more then one item at a time: I believe `setLen()` can invoke the GC and cause performance degradation. Instead, I use a seq for storage but keep my own top va

Re: Help with set

2019-12-05 Thread Araq
There is an RFC to improve the type inference for array/set/etc constructors fwiw. But for now use `x = {1'i16..9, 15, 45..78}` and write more Nim code. A single quirk does not make a summer.

Re: Help with set

2019-12-05 Thread SolitudeSF
what

Re: Help with set

2019-12-05 Thread SolitudeSF
what

Re: Nim tutorial -- Kaushal Modi's notes

2019-12-05 Thread edu500ac
Hi, carterza. Vernon's intention was to close the page. Then Kaushal Modi asked us to bring it back, and offered the notes as his contribution. Even so, I wrote him an email asking whether the Della-Vos group could use his notes. You can check his answer at the github repository, under the tab a

Re: Help with set

2019-12-05 Thread DIzer
there is NO REAL NEED in auto reffering up to the point - since type of x well known BEFORE... just range cheking and obvious type conversion...

Re: Help with set

2019-12-05 Thread DIzer
my good let us finish with words - jiggling :) If i wrote down type CharSet = set[int16] * that I MEAN to do so ... :)

Re: Help with set

2019-12-05 Thread DIzer
OK, thank you for help. Let us think about the issue as the compiler's uncleverness in autoreferring... - shortly it could do such thing but not obliged to do... Yet of course I knew as make working set... but also i want "to feel" the lang better... once more thank you.

Re: Help with set

2019-12-05 Thread Stefan_Salewski
> 2\. why You have to accept that compilers may not see x = {1..9, 15, 45..78} as one entity, but as an assignment, where the right side is evaluated first and then assigned to the var on the left. And {1..9, 15, 45..78}is evaluated as a set of integers, which is not compatible to a set of int1

Re: Help with set

2019-12-05 Thread kaushalmodi
> there is not need in auto inferring, since type of x well-known before, and > it can not be changed implicitly by Nim rules. It's the job of the compiler to ensure that the type of the value on right hand side matches with the type on left hand side. I cannot rely on the user always doing the

Re: Help with set

2019-12-05 Thread kaushalmodi
> why does it work with char?

Re: Help with set

2019-12-05 Thread DIzer
If so... 1\. there is not need in auto inferring, since type of x well-known before, and it can not be changed implicitly by Nim rules. 2\. why does it work with char?

Re: Help with set

2019-12-05 Thread kaushalmodi
Nim is a compiled language. So at the time of compilation, it checks if the value assigned to a variable fits the type of the variable in the declaration. Nim auto-infers the type looking at the **right hand side** of an assignment. So .. type CharSet = set[int16]

Re: Help with set

2019-12-05 Thread mratsim
1..9 is int not int16. Nim doesn't do auto conversion of integer literals if they are in an object, array, slice (with the `..`) so you need to specify the type of the first item of the collection like @kaushalmodi said.

Re: Help with set

2019-12-05 Thread DIzer
You do not understand me - It is , endeed, since , I DEFINE EXPLICITLY it by clause type CharSet = set[int16]

Re: Help with set

2019-12-05 Thread DIzer
It is non uniform uproach.. Technically there is no difference between int16 and char types, since i explicitly define type CharSet = set[int16]

Re: Help with set

2019-12-05 Thread DIzer
OK It looks much as a compiler error. 'cos type CharSet = set[int16] It is just a set type definition - and it works for every acceptible type var x: CharSet It is just a variable declaration - nothon unusial x = {1..9, 15, 45..78} It is a set constructor - it does not work with anyth

Re: Help with set

2019-12-05 Thread kaushalmodi
Specifying the type only for the first literal also works.. [https://play.nim-lang.org/#ix=23CE](https://play.nim-lang.org/#ix=23CE).

Re: Help with set

2019-12-05 Thread Vindaar
The error message for the second case isn't as clear as it could be, if you don't know what to look for maybe. It says: Error: type mismatch: got but expected 'CharSet = set[int16]' Run See the (int) after the range ...? That tells you the type it gets is actually

Help with set

2019-12-05 Thread DIzer
Hello everybody From manual: type CharSet = set[char] var x: CharSet x = {'a'..'z', '0'..'9'} it works! but : type CharSet = set[int16] var x: CharSet x = {1..9, 15, 45..78} is not. What is wrong?

Re: Pimp up this sub

2019-12-05 Thread SolitudeSF
this is a bot [https://www.reddit.com/r/nim/comments/dwv3ms/pimp_up_this_sub](https://www.reddit.com/r/nim/comments/dwv3ms/pimp_up_this_sub)/

Re: UI showcase ideas

2019-12-05 Thread mratsim
Obviously in almost 2020, you should tag your demo with either AI or Blockchain. How about visualizing the training of a neural network? This is a demo that run in the browser but everything visual is Javascript which AFAIK is easy to embed in QML: [https://github.com/Vindaar/NeuralNetworkLiveD

Re: Most efficient way to implement a stack using Nim?

2019-12-05 Thread mratsim
Assuming that: * it's used in a hot-loop and so that the data of both array and seq are hot in the CPU cache * both are properly dimensioned and don't need realloc * your indexes and stack length are using int32 or int64 to avoid slower int8/int16 operations that also needs to zero the upp

Re: Pimp up this sub

2019-12-05 Thread mratsim
You can directly add some PR in the forum repo: [https://github.com/nim-lang/nimforum](https://github.com/nim-lang/nimforum), I'm not too sure if it has a theming system or if it's currently hardcoded though.

Re: UI showcase ideas

2019-12-05 Thread juancarlospaco
* Examples of QML file open dialog and QML folder open dialog. * Examples of a main window with Statusbar, Menubar, Toolbar. * Does `Qt.labs.calendar`, `Qt.labs.platform` and QML Particles work ?. Examples for each if they work. For showcase already commented above.

Re: UI showcase ideas

2019-12-05 Thread Araq
> Abu idea for a possibile usefull app? Yet another to do list? I would like to see a c2nim frontend: You have two editors, one for inserting Nim code, the other one read-only showing c2nim's results.

Most efficient way to implement a stack using Nim?

2019-12-05 Thread drkameleon
OK, so I've been playing and benchmarking ideas of how to implement an (uint64) stack in Nim. (seq-based, array-based, and timing push'es and pop's) How would you approach this? (my main concern is speed)

Pimp up this sub

2019-12-05 Thread jadenfrancis
Hi, I've concluded from asking questions around in the Nim communities that Nim is a great language with mostly just a PR issue. As I'm learning and adopting the language, I want to spend time closing this gap in the hope that more will have the opportunity to appreciate this language. With tha