How to write the Nim version of a C function pointer and pass it as argument to C function

2024-06-11 Thread TKD
Great. This works! Thank you.

How to write the Nim version of a C function pointer and pass it as argument to C function

2024-06-11 Thread demotomohiro
If pointer type points to an array, `ptr UncheckedArray[cdouble]` (or `ptr array[3, cdouble]` if array size is fixed) is better than `ptr cdouble`. Example runnable code: import std/strformat {.emit:""" typedef void (*fptr_f) (double, double *, double *, void *); vo

How to write the Nim version of a C function pointer and pass it as argument to C function

2024-06-11 Thread TKD
Given the following C function from a library I want to link to: typedef void (*fptr_f) (double, double *, double *, void *); void foo(_fptr_f f, double *y, void *_data); Run I have written the following Nim equivalent: type fptr_f = proc(t: cdouble,

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
@mratsim thanks for the in-depth informations ! @Araq > I'm willing to help. ;-) I'm willing being helped ;-)

Introducing an async library inspired by Go in Nim

2024-06-11 Thread mratsim
@Alogani > Indeed moving a started coroutine can be (is certainly?) unsafe, because it > can contains GC memory, which will be hard to track. You can't move a started coroutine without preemption. You need the coroutine cooperation, i.e. it should have suspension points where its state it saved

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
It is not exactly the problem of the stack, but the memory inside it. Let me illustrate with a multithreaded NimGo version : #[ Please note that the usage of Coroutine here is useless and serves as a demonstration. In this example, the number of pending coroutines is limited

What Araq thinks about HappyX?

2024-06-11 Thread moigagoo
I'm loving this trend :-) Let's start a monthly "What Araq thinks about X" blog series?

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
## Maybe in another thread now ? echo myString #-> this is unsafe! echo repr(myRef) #-> this is unsafe! Run This is now safe, the heap is shared in 2.0. There is also a switch `mm:atomicArc` that makes the refcounting itself threadsafe (which your example

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
> Go's GC has certainly a very different policy about how it tracks coroutines' > stacks, and bringing that to Nim could mean a change in a way GC is tracked, > which is clearly just not worth it. I don't know the internals to make > affirmations. With ARC these things became a non-issue as ARC

What Araq thinks about HappyX?

2024-06-11 Thread Araq
I have not yet read this codebase, sorry. But I know people who are not affiliated to the project and are about to use it in production. PS: Stop using regexes for parsing.

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
> By the way: let line = myfile.readLine() is either a very bad example or very > good ! Because if myfile is a regular file, the 1:N dispatcher will be > blocked. It wasn't meant to hint at Posix's non-existing async file support. It was a general example (Windows does not have a problem with

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
@mratsim Your article about multithreading floavors is great, I had read it multiple times last months, your knowledge about taskpools is far beyond mine. But I think my use of terms were confusing. When I talked about M:N difficulties, I was talking in the context of making use of stackful cor

What Araq thinks about HappyX?

2024-06-11 Thread Qtless
I would like to know what the creator of Nim thinks about [HappyX](https://github.com/HapticX/happyx)

Which IDE to use in 2024?

2024-06-11 Thread IgnisTempestas
[Maybe by Nim 2.2](https://github.com/nim-lang/RFCs/issues/543), though is not explicit. I wish I was clever enough to work on Nim itself, to help speed this up...

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
@araq I understand you want to avoid the distinction between `goThread` and `goAsync`. There are more than legimate reasons for that. It would be simpler, less confusing for the user. I'm certainly wrong because making that distinction like I propose will certainly have no benefit for the user,

Introducing an async library inspired by Go in Nim

2024-06-11 Thread mratsim
> However, I think the M:N task is very difficult and might not be achievable > without some other sacrifices on the actual project (speed ? Compile time ? > drastic change in API usage ? safety ? ). But I really don't know. I have done so many threadpools now, I can do them with closed eyes. H

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
> I hope my explanations wasn't too confusing and might convince you. Thank you but we're talking past each other. `goThread` and `goAsync` is exactly the distinction that I seek to avoid entirely. I want a single `spawn` construct. And usually I will not use `spawn` for IO at all but when I wri

Introducing an async library inspired by Go in Nim

2024-06-11 Thread alexeypetrushin
As far as I understand, the whole point of Go is to avoid async :). Async good for making performant IO and networking, for writing simple APIs etc. But bad when you need to write someting running reliably and predictably and complicated. For that you need something like Erlang or Go. Not Async.

https://www.facebook.com/NaturesLeafCBDGummies/

2024-06-11 Thread erinjboone
✅ Product Review: — Natures Leaf CBD Gummies ✅ Composition: — Natural Organic Compound ✅ Availability: — Online ✅ Side-Effects: — NA ✅ Rating: — ⭐ ✅ Availability: In Stock #1 Product in the CA CLICK HERE FOR MORE INFO 👍 Natures Leaf CBD Gummies are an effective health-boosting formula that h

SEO For Locksmith Company

2024-06-11 Thread dabaran
Locksmith SEO Services | SEO for Locksmith Websites | [SEO For Locksmith Company](https://www.dabaran.com/industries/seo-for-locksmith); Locksmiths that rank first in their region get most of the business. That’s why SEO for locksmith services are essential. Hire a company that can provide exper

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
I don't think the M:N model will be highly different from the 1:N model regarding channel and it's use. I surely propose some kind of channel for the implementation detail of goThread, but in fact, it would be more complex than that. to avoid tryRecv loop. In fact, to implement Coroutine-aware

Herbal Harmony CBD Gummies

2024-06-11 Thread nivifiz
https://www.facebook.com/Official.Herbal.Harmony.CBD.Gummies/

Please help, learning NIM to speed up Python programs, but strange results

2024-06-11 Thread epoz
Thanks for the comments all, very valuable. My use case is reading a large file that does not fit in memory, (circa 45GB compressed) so it has to be streaming. After reading the file, I then want to do some basic splitting of the lines, and then hash each part with xxhash. And @cblake thanks fo

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Clonk
There is also [std::execution](https://github.com/NVIDIA/stdexec) made by Nvidia; they submitted as a std cpp

https://www.facebook.com/Official.Herbal.Harmony.CBD.Gummies/

2024-06-11 Thread Killerbee026
Herbal Harmony CBD Gummies sweetheart and safe for all. The creators ensure that it has no sprinkle of gelatin, fillers, or basically anything that wrecks with the advancement of the thing. What's more, not among those averag

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
How I understand it (but maybe some people will correct me): I will use the term "Task" to represent any code subroutines, whether that subroutine is a stackful Coroutines or a thread. In the M:N model: * **Design 1** : the user creates and execute a Task and execute a Task. The runtime deci

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
I don't understand your solution. There are dependencies between `CpuTask` and `IoTask`. Sure I could use channels for communication but then I'm left with blocking `recv` calls or some polling on `tryRecv` calls. That hardly solves anything.

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Araq
> The real use case of M:N would be IMHO to make NimGo handles millions of I/O > at the same time, without the help of threads, it is just not possible, the > I/O loop is not free. It is not for performance (though it hopefully is an **enabler** for performance) but for convenience. > But I th

Introducing an async library inspired by Go in Nim

2024-06-11 Thread Alogani
Blocking is less problematic is non concurrent workflow than parallel one. But still can happen. What is your problem with my simple solution of having `goThread proc() = doCpuStuff()` ? Won't that use both parrallelism and concurrency simply ?