Enabling compression on socket send/receive.

2024-08-15 Thread void09
I tried to get a proc as field in my client object, so i can swap it at runtime without having if else everywhere. I have these definitions: proc sendProcU(nntp: NNTP | AsyncNNTP, data: string) {.multisync.} = await nntp.sock.send(data) NNTPClientBase*[SocketType]

Created my first binding! I am impressed!

2024-08-15 Thread PMunch
Nice! Bindings in Nim are very easy once you get the hang of it. Now for bonus points write a header file and generate the wrapper automatically with Futhark!

Created my first binding! I am impressed!

2024-08-15 Thread Hallicon
I just created my first bindings on Nim, I like how this works at a basic level; if anyone wants to try it out without having to go through a lengthy tutorial: //hello.c #include const char* hello_world() { return "Hello, World!"; } Run

Notifying the dispatcher from a different (foreign) thread

2024-08-15 Thread elcritch
Yeah polling isn’t bad if you’re not doing a bunch of them. You can do notifications using the stdlib async by creating a custom `AsyncEvent`. You need to manually register it to the dispatcher with `addEvent`. It adds a callback that the dispatcher will run when the event is triggered. Then o

Notifying the dispatcher from a different (foreign) thread

2024-08-15 Thread elcritch
Note that you should put your `ctx` object into a `SharedPtr` from the threading lib or similar. Otherwise if the `mycoro` async gets cancelled and GC’ed your other thread will be using freed memory. It’s not fun tracking those down.

why Nim shows different behavior on int overflow?

2024-08-15 Thread Araq
The manual covers the language, not the library. When you open the manual there is link that says "Standard library". There is only so much you do for readers who don't read. ;-) Back to your question: Unsigned integers in Nim have wrap around semantics on overflow because unsigned was introduc

why Nim shows different behavior on int overflow?

2024-08-15 Thread 221V
ok, I am talking there is no table with min-max values in :) that will be useful - more user-friendly - for people who switch from high-level languages :) FYI I just begin to touch primitive examples in C and Nim after years and years work with php-js-er

Notifying the dispatcher from a different (foreign) thread

2024-08-15 Thread Araq
I don't really know but my rule of thumb is "polling is the only thing that actually composes".

why Nim shows different behavior on int overflow?

2024-08-15 Thread Araq
I search the index for "max", eventually I get to: which leads me to: "high(int) is Nim's way of writing INT_MAX or MAX_INT." Then I use a fraction of my brain's activity and try out `echo high(

why Nim shows different behavior on int overflow?

2024-08-15 Thread 221V
other moment -- there are no in any nim tutorial ranges table for type like for C here for example, uint64 not googled nothing, nothing found with crtl + f onto manuals and book ("Computer Programming with the Nim Programming Langu

Notifying the dispatcher from a different (foreign) thread

2024-08-15 Thread darkestpigeon
I have some imported C function that looks like `proc doStuff(..., callback: proc(pointer) {.cdecl.}, ctx: pointer)`. It does stuff, and on completion calls the callback with ctx. I know that the callback will be called from another thread. I'd like to wait for completion in a coroutine. Right n

why Nim shows different behavior on int overflow?

2024-08-15 Thread 221V
hello! why Nim shows different behavior on int overflow? var prod: uint64 = 1 echo "Product numbers 1-25:" for num2 in 1'u64 .. 25'u64 : prod = prod * num2 echo prod Run returns Product numbers 1-25: 7034535277573963776