Which tools do you use to code in Nim?

2023-09-21 Thread didlybom
VSCode with nimsaem’s plugin. I wish it worked better though :/ As for libraries, Arraymancer is the one I probably use the most. It’s awesome!

Which tools do you use to code in Nim?

2023-09-21 Thread sls1005
I use `nano` and `nim` on a terminal, usually [Termux](https://github.com/termux/termux-app). Sometimes I use another text editor in graphic interface. I also use a script (made by myself) to get the generated C code.

Which tools do you use to code in Nim?

2023-09-21 Thread PMunch
choosenim + nim + nimble + vim + nimlsp That's my basic setup, I also have the zah/nim plugin for Vim to give me syntax highlighting. As for libraries it highly depends on what I'm doing. However the simplicity of termstyles means that I often include it. And of course Futhark has become more

Which tools do you use to code in Nim?

2023-09-21 Thread ingo
Sublime Text + LSP + nimlsp But most important: Firefox

Which tools do you use to code in Nim?

2023-09-21 Thread janAkali
My OpenSUSE (linux) setup: * [st-terminal](https://st.suckless.org) * [neovim](https://github.com/neovim/neovim) \- text editor + plugins: * 'lukas-reineke/indent-blankline.nvim' \- highlighting of indentation levels * 'alaviss/nim.nvim' \- smart syntax highlighting + tab completion

The secret of Nim

2023-09-21 Thread HiPhish
I am glad I am not the only one who sees it o_O

Which tools do you use to code in Nim?

2023-09-21 Thread AmjadBHD
Sublime Text + LSP + nimlsp.

peekChar() on stdin

2023-09-21 Thread adrianwjw
Very new to Nim, so apologies if this is a stupid question. Consider the following code: import std/streams var s = stdin.newFileStream() echo "peek: ", s.peekChar() echo "read: ", s.readChar() Run Assuming I input `1` to stdin, I expect the output to

How to add nim intellisense to a imported JavaScript object?

2023-09-21 Thread geotre
maybe import std/jsffi type ModuleElements = distinct JsObject proc createModuleElements(width, height: int): ModuleElements {.importjs: "new ModuleElements({width: #, height: #})".} proc loadElem(m: ModuleElements, a: cstring) {.importjs: "#.LoadElem(#)".}

Which tools do you use to code in Nim?

2023-09-21 Thread brainproxy
[Emacs](https://www.gnu.org/software/emacs/) \+ [nim-mode](https://github.com/nim-lang/nim-mode) \+ [lsp-mode](https://github.com/emacs-lsp/lsp-mode) \+ [nimlangserver](https://github.com/nim-lang/langserver). On MS Windows: same as above, used in conjunction with MSYS2's [CLANG64](https://www

Which tools do you use to code in Nim?

2023-09-21 Thread giaco
Hi! This is an exploratory thread to find out which development environment(s) Nim users have found to be playing well together, as this may help me and possibly other users to try something outside the comfort-zone. I'm asking this as I'm still working with the first one on the road: choosenim

concepts and openArray

2023-09-21 Thread shirleyquirk
since slicing and concatenation change the array type you can split up your concepts: import std/enumerate type SliceableStream[T] {.explain.} = concept s s[Natural..Natural] is BaseStream[T] BaseStream[T] {.explain.} = concept s s[Natural] is T

Mindset Nim

2023-09-21 Thread didlybom
The problem is that inim fails for anything beyond the simplest examples and it is quite slow. It is great that it exists, and it is nice for learning, but it is far from what you can get in languages like Python, Matlab or Julia.

Mindset Nim

2023-09-21 Thread termer
I'm surprised I don't see any mention of the INim REPL. You can `nimble insta inim` and have a functional CLI REPL for testing small code snippets. I use it a lot when I want to test the behavior of a single line, and I used it quite a bit when I was first learning. It's not something that can m

The secret of Nim

2023-09-21 Thread termer
I saw it too, before I even read the replies to this post. I've seen deliberate imagery just like that before in psytrance visuals, so this isn't just a "dirty mind" thing lol

Nim version 2.0.0 is here

2023-09-21 Thread Isofruit
If the package is postgres/mysql/sqlite related then there's a risk of it only working on one version. However, for the majority of packages I encounter, work on or use I can't say I noticed a difference.

How to add nim intellisense to a imported JavaScript object?

2023-09-21 Thread Millymox
I am seeking assistance to enhance the IntelliSense capabilities in my codebase, My code snippet is as follows: proc createModuleElements(width, height: int): JsObject {.importjs: "new ModuleElements({width: #, height: #})".}\ Run The createModuleElements procedure in

Using Result library

2023-09-21 Thread shirleyquirk
i've been working with a Result clone written on top of std::expected, and, while i miss pretty much everything else about nim-result, ive grown to enjoy being able to return a bare T from a function returning Result[T,E] #include #include using err_t = std::string; te

How to Properly Wait for a JS Async Event in Nim?

2023-09-21 Thread Millymox
Thank you this works perfectly

Need help writing a helper function?

2023-09-21 Thread wwang1990
Glad to know all of those, Thank you.

Mapster - Because life is too short to map A to B

2023-09-21 Thread Isofruit
Heyho everybody, mapster essentially got bumped to version 1.2. The notable new feature includes: * added in-place mapping (aka merging 2 objects) - [Docs for the new feature](https://philippmdoerner.github.io/mapster/inplaceMapExamples.html) * Made validation rules for mapping with object v

Mindset Nim

2023-09-21 Thread bsljth
Is `nim secret` a REPL?

Using Result library

2023-09-21 Thread Tanguy
You are missing the `ok` in the success path: proc getValue(node: ValuesNode, key: Bytes32) : Result[Bytes32, string] = if node.values[key[^1]] == nil: err("Value not found") else: ok(cast[Bytes32](node.values[key[^1]])) Run (took the liberty

Using Result library

2023-09-21 Thread ingo
there is std/options where you return some(result in Bytes32) or none(Bytes32) but no string. That than should be a separate message to logger or stderr or ...

for loop iteration variables

2023-09-21 Thread enthus1ast
interesting

Need help writing a helper function?

2023-09-21 Thread Isofruit
Ah, you're trying to apply a python workflow to a compiled language like nim. Basically ideally you'd want to have runtime introspection like go into a repl and get a list of all methods defined for a type. This is sadly not quite possible given how nim works in general, due to being a more low

Using Result library

2023-09-21 Thread 4n0n4me
I think it is unlikely to find other solutions (there are indeed other means to do it, but I think all of them work in similar ways as the Results lib), since Nim is a very strong typed language. You can also use `throw newException(...)` to throw exceptions, but I guess it is not what you want.

Need help writing a helper function?

2023-09-21 Thread 4n0n4me
Actually I think there are not really such solutions. However, if you use Editor support, for example the VSCode extension by nimseam, you can type `"string".` and see all methods available in the Editor completement. As far as I know, this is powered by the tool nimsuggest under the hook.

Nim version 2.0.0 is here

2023-09-21 Thread Araq
Compatible enough as it's possible to write code that works with both versions.

Mindset Nim

2023-09-21 Thread Vindaar
If it was trivial to do and/or I knew exactly how to do it, I would have written one by now, heh (I have multiple toy REPLs, but they all have certain problems). For an example of a REPL of a compiled language - C++ - you can check out cling: It effectively uses the

Nim version 2.0.0 is here

2023-09-21 Thread HiPhish
How is backward compatibility with Nim 1.x source code? If one wanted to package Nim 2 for a GNU/Linux distro, should there be a separate `nim2` package (which might conflict with the `nim` package) or is it fine to treat Nim 2.0 as a straight upgrade?

Need help writing a helper function?

2023-09-21 Thread wwang1990
Thanks for the suggestions, I am honoured to hear from you. I will try to familiarise myself with the std documentation.

Mindset Nim

2023-09-21 Thread Vindaar
I need to look into that at some point!

Need help writing a helper function?

2023-09-21 Thread Araq
Just browse the official documentation and focus on these modules for `seq`: system.nim, sequtils.nim, algorithm.nim Or come up with the **verb** you need to use, why do you care if e.g. `deduplicate` exists for `seq` when you don't need to deduplicate seq entries...

Mindset Nim

2023-09-21 Thread Araq
Depending on how you build the VM it actually supports calling into native code. There is also a callback mechanism for extensibility not unlike how Python does it.

Need help writing a helper function?

2023-09-21 Thread wwang1990
The reason for this is that scanning through the std documentation seems to take too much time. I just want to set up some basic data and move on from the data, find the associated function, select the possible function, then see the function docstring and examples.

Need help writing a helper function?

2023-09-21 Thread wwang1990
Thank you! I use python and julia as my main language. In python, I find the following snippet very helpful. from rich import inspect as ri alist = [1, 2, 3] ri(alist, help=True, methods=True) Run As for nim, I want to know which function will act on alis

Mindset Nim

2023-09-21 Thread jmgomez
Yes, I assumed everyone was on the same page. This is not the C/C++ backend. But it doesnt mean you can call those functions, you could: * Compile the compiler with `importc` support * Statically bind wrappers-hooks (like the compiler does) * Dynamically bind wrappers (like NUE does) For

Mindset Nim

2023-09-21 Thread Isofruit
Conceptually, how would a REPL for the C backend even work? It would have to work with C imo since otherwise the output of the REPL wouldn't be representative of what you could expect if you compiled it yourself. Doesn't that make the inim approach the only feasible one (You actually treat it a

Need help writing a helper function?

2023-09-21 Thread Isofruit
I'm perfectly happy to help here, but given that you seem to want to rely on AI tooling from the jump I would prefer if I could give you an explanation that actually helps with your understanding of the language. Could you rephrase what you hope to achieve, how you interpret the currently gener

for loop iteration variables

2023-09-21 Thread jhgalino
Thanks! The capture macro did it.

Mindset Nim

2023-09-21 Thread Vindaar
When people talk about a Nim REPL they usually mean a REPL for the C/C++ backend. The Nim VM can only evaluate pure Nim code, so anything that ends up calling some wrapped C code / shared library doesn't work. In practice that means the Nim VM cannot be used for anything non trivial. (There's al

for loop iteration variables

2023-09-21 Thread janAkali
Note the note under the 'closureScope': > Note: This template may not work in some cases, use capture instead. See [capture](https://forum.nim-lang.org/postActivity.xml#capture) template in [std](https://forum.nim-lang.org/postActivity.xml#std) And here's a working code snippet: i

for loop iteration variables

2023-09-21 Thread enthus1ast
You need to use "closureScope"

Pure Nim FFT library

2023-09-21 Thread ingo
Just playing with fftr I noticed two things, When going back from the frequency domain to signal, I have to divide the real part of the result by the length of the signal. Is it the convention that I do that, or should the library? It seems that depending on the length of the signal, the `ifft`

High level TUI framework (or wrapper of)

2023-09-21 Thread enthus1ast
Please look into it @void09 when i have some muse, I would first make illwill accept unicode. The table widget was contributed to the illwillWidgets and I've not used it in a project.

for loop iteration variables

2023-09-21 Thread jhgalino
I converted a golang code snippet from to nim. var prints: seq[proc ()] = @[] for i in 1..3: prints.add(proc () = echo i) for print in prints: print() Run This code currently prints `3, 3, 3`. How do I modi

Need help writing a helper function?

2023-09-21 Thread wwang1990
Hi there. I am just starting to learn nim, and I am asking the GPT-3.5-turbo to write a function for me (see the following). I am impressed with the result, although it does not compile. What is the correct way to write this function? 01:user: when I write code in nimlang, how to find the functi

Mindset Nim

2023-09-21 Thread alexeypetrushin
@jmgomez UE example with cube looks nice! Maybe I'm missing something, isn't the Nim VM same as REPL, like it is shown in this UE example? If not - what's the difference of NimVM from say `JS.eval`?

Pure Nim FFT library

2023-09-21 Thread ingo
> # false for forward FFT, true for inverse (TODO flip it? separate names?) i.m.h.o separate names: fft, ifft

Pure Nim FFT library

2023-09-21 Thread arnetheduck
Now 2x faster ;) > small issue in your example. fixed, thanks > friendly license "Add MIT license" button clicked to appease those that find this .. important.