Basic Async Questions

2023-08-22 Thread Isofruit
I think I just had somewhat of a lightbulb moment: Nim has `await` and `waitFor`, while JS only has `await` \- which is equivalent to nim's await. JS does not have an equivalent to `waitFor`. Is that because in JS basically **everything** gets executed within an event-loop? And you just don't

Explanation for SSL/TLS Error

2023-08-22 Thread jtv
I take it back, OpenSSL wasn't the issue, it was `-lc` (for `getaddrinfo` in particular) and `-ldl` (for `dlopen` itself). So calling either of these two functions in a static binary seems to result in the corresponding library being dlopened even if statically linked, at least according to the

Convert back cstring to string

2023-08-22 Thread mratsim
It would be easier with actual function signatures. The GC_ref / GC_unref might only work for --mm:refc, unsure about --mm:arc I would just use `$myCString` and worry about zero-copy if allocation becomes a bottleneck that shows up in profiling. As you are using a DB chances are that IO is the

How to update a nimble package?

2023-08-22 Thread AmjadBHD
What if you work with versions of Nim that use pkgs ?

Basic Async Questions

2023-08-22 Thread PMunch
Pretty much exactly, yes. It's mentioned in the docs [here](https://nim-lang.org/docs/asyncdispatch.html#handling-futures) and the [implementation](https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/asyncdispatch.nim#L2019) is pretty obvious.

Basic Async Questions

2023-08-22 Thread Isofruit
What's the difference to the prior approach and this? import std/asyncdispatch proc afterX(wait: int) {.async.} = await sleepAsync(wait) echo "Stuff Happened" waitFor afterX(400) Run Are they both basically the same with the waitFor just di

Convert back cstring to string

2023-08-22 Thread Araq
You can do it with address arithmetic, maybe. You need to know the offset (8?), subtract that from the `char*` pointer and cast it to `ptr StringDesc` (pointer) and then create a string from it, strings have a word sized length and then a payload pointer. Or something like that, I'm too lazy to

Basic Async Questions

2023-08-22 Thread mashingan
> What is AsyncFD in terms of meaning? (I'm aware it's a distinct int32, but > what does that mean?) FD is abbreviation of file descriptor, on Windows it's called Handle. FD/Handle is basically just and object and with AsyncFD meaning can be applied for asynchronous operation. On Windows it's t

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread choltreppe
I think most of you misunderstood my problem (thats my bad I didnt explain it very well). But I found a solution myself now. thanks anyways

Basic Async Questions

2023-08-22 Thread PMunch
Don't have time to reply with something more in-depth right now, but for the mental model waybe this article of mine will help: . You might've read that already though.

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread mashingan
> But I dont realy want to create a new thread every time. So is there a better > way of achieving this? (it may be linux specific) Make the proc is always running the background as a dedicated thread but lock it to save the cpu loop and only continue if the lock receiving signal. For example h

Sublime and Nim

2023-08-22 Thread janAkali
Don't quote me on that, but as I understand: you previously added '~/.nimble/bin' to your PATH in some config file for fish shell (e.g. '.fishrc'). This file is sourced (loaded) when you start a shell session or launch a gui program **from terminal**. So, when a program is started not from a te

Convert back cstring to string

2023-08-22 Thread griffith1deady
try use $myCString Run

Convert back cstring to string

2023-08-22 Thread mildred
Hi, I wanted to know if it was possible to convert back a cstring to a string. Specifically, I'm binding to sqlite for user functions and when the user function returns a string, it provides a cstring as result value and a destructor callback called when the string is no longer used by sqlite i

Sublime and Nim

2023-08-22 Thread Odysseus
Actually, it was that! Thank you very much!

Basic Async Questions

2023-08-22 Thread Isofruit
Regarding the answers: 2. Could you elaborate? In terms of event loop I just have the mental model of a queue that gets polled every N nanoseconds (or miliseconds). I don't have a mental model of where/how "dispatcher", "registering" and "deregistering" fit into that yet. 5. After some m

Sublime and Nim

2023-08-22 Thread Odysseus
Hello and thank you. But, there is something which I do not understand. Using the terminal I can compile and run nim from any directory; thus it is already in my PATH (also, I use the fish shell). So, I do not think that this is the problem, unless the default terminal of Sublime uses bash ... I

Happy Birthday Nim!

2023-08-22 Thread kragil
According to a recent thread, Nims birthday was today, 15 years ago! Happy birthday! It has come a long way. Great achievement everybody, especially Andreas and all the contributors! So in three years time, Nim will an adult (at least in Germany). What do people wish for Nims coming adulthood?

Basic Async Questions

2023-08-22 Thread PMunch
* AsyncFD is an async file descriptor. Doesn't make much sense in this case, but if you're awaiting a file read or a network request this parameter is used. * I believe this is documented somewhere in the async documentation, but essentially it decides whether this callback should be deregistered

Sublime and Nim

2023-08-22 Thread janAkali
You need to add Nim to your PATH globally (not in .bashrc/.zshrc). Add this line to the ~/.profile: export PATH="$HOME/.nimble/bin:$PATH Run then logout or reboot. That should work for Ubuntu/Debian/Arch-based distros. For OpenSUSE - instead, edit file '/etc/profile.

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread janAkali
Another option is to use the 'at' linux tool - > at, batch, atq, atrm - queue, examine, or delete jobs for later execution A couple fun examples allowed by extended POSIX.2 timespec: at now + 1 hour <<< "touch ~/file" at teatim

Explanation for SSL/TLS Error

2023-08-22 Thread jtv
IIRC, that doesn't work for openssl 3, it still dlopens in all cases. There are other things like `getaddrinfo` and dlopen itself where Nim seems to require the dynamic library even if statically linking. It should be much easier to force static linking, and actually not have dynamic dependenci

Explanation for SSL/TLS Error

2023-08-22 Thread mratsim
you need --dynliboverride to avoid dlopen and only use static lib Or use `-Wl,-Bstatic -lssl -Wl,-Bdynamic`

Basic Async Questions

2023-08-22 Thread Isofruit
After the [other forum post](https://forum.nim-lang.org/t/10427) wanting to efficiently execute a proc at a delayed time I figured I might as well start learning a bit more about async. I have a few rather beginner questions concerning async in nim. For now I just want to explore a bit based on

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread mildred
It looks like linux have timerfd :

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread mildred
libev and libevent both seem to have a timeout event it can handle. You can either use them, or look at how they done it and do it yourself:

Explanation for SSL/TLS Error

2023-08-22 Thread Isofruit
I don't think it'll massively help here, but on the off chance it does: I do use openssl with the smtp module for webdev in an alpine container, but only dynamically linked. I compile with ... --gcc.exe:"musl-gcc" --gcc.linkerexe:"musl-gcc" --define:ssl ...

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread Isofruit
I was looking into this myself a bit and stumbled into std/asyncdispatch . This sounds extremely like wanting to do the equivalent of a setTimeout in JS (and we do have equivalents in [std/dom](https://nim-lang.org/docs/dom.html#setTimeout%2Cproc%29%2Cint)). For nim on its own I only found `add

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread choltreppe
I want to execute a proc at some specified time, but I want to be able to change this time. So at the moment I just create a thread which sleeps the correct amount of time before it does its task, and if I want to change the time I cancel the thread and start a new one. But I dont realy want t

efficient way of running proc at a given time, that can be changed

2023-08-22 Thread PMunch
I guess you're looking for something like this? Of course there's also the alternative to use systemd timers to kick of an action at a given time, but if you want to do everything within your program then the library I linked is probably the way to go.

Explanation for SSL/TLS Error

2023-08-22 Thread jtv
One should generally prefer OpenSSL3 to 1.1 anyway, but I agree it's painful. It also seems to be the case that OpenSSL must be dynamically linked w/ Nim due to it being dlopen()'d even if it's statically linked. We ended up doing some trickery to redirect the dlopen() call ourselves.

Explanation for SSL/TLS Error

2023-08-22 Thread Calonger
Smtp no standard library no longer now nimble package might have bugs fixed ...

Sublime and Nim

2023-08-22 Thread Odysseus
Hello to all I have just installed NimPlus --as per github instructions-- within Sublime Text 4. At this point I have to say that I have installed nim using ChooseNim -in a Linux system (in fact, after a fresh installation. When I try to compile/run a source nim file (e.g., test.nim, which con

Explanation for SSL/TLS Error

2023-08-22 Thread Akito
Yes, makes sense, as in Nim getting confused. In all my trials, I had the following scenarios. I cannot list all, because I spent too much time trying to figure out the problem. 1. Only OpenSSL 1.1 2. Only LibreSSL 1.1 3. Only OpenSSL 3 4. Only LibreSSL 3 5. OpenSSL & LibreSSL 1.1 6.

[Advice] Ways to handle "dynamicity"

2023-08-22 Thread ElegantBeef
Did you miss the purpose of this conversation? The OP wanted to use Nim/Nimscript as a configuration language for their program. What you've done is made a odd compilation pipeline that does not configure a running program. To do that you'd need to do some form of IPC.

[Advice] Ways to handle "dynamicity"

2023-08-22 Thread alexeypetrushin
> Not to mention using nim r bleh.nim requires you to setup inter-process > communication, you cannot just call your host procedures in an environment. No. You have file structure my-app/ plugins/some-plugin.nim run-template.nim run.sh Run And the `r

Demo video of Figuro GUI progress

2023-08-22 Thread elcritch
I've been working on a new experimental GUI. It's not ready for release yet; however, this last weekend I made good progress on events and wanted to share the progress! It's been coming together in a pleasing way so far. You can see an example video here:

RosettaBoy - Gameboy emulator rosetta stone

2023-08-22 Thread javanflo
this is a very popular emulator it is suitable for all kinds of games, if you want to play go to https://romskostenlos.de";>romskostenloshttps://romskostenlos.de";>romskostenlos to play

How to update a nimble package?

2023-08-22 Thread Calonger
There is bug with pkgs and pkgs2 folder with Nim v 2 . 0 ... Installs to pkgs2 but import module go to pkgs . Delete pkgs folder reinstall packages .