Ptr byte to cstring?

2023-12-22 Thread JiyaHana
This is another way you can try. var buffer: ptr byte var length: uint32 doAssert FreeImage_AcquireMemory(outmem, addr buffer, addr length).bool let cs = buffer[0 .. length - 1].cstring

Enhancing Nim vtable implementation vs subtype checking

2023-12-22 Thread Araq
How to handle cycles: Lie (a little) about the type: type Foo = ref object barImpl*: RootRef # Bar Run Other module: type Bar = ref object of RootObj f: Foo template bar(f: Foo): Bar = Bar(f.barImpl)

Ptr byte to cstring?

2023-12-22 Thread jrfondren
C strings are zero-terminated, and FreeImage_AcquireMemory isn't filling the buffer with non-zero bytes for `len()` to count. Even if it did, the assertion would fail as a C string can't have a length equal to the memory backing it without `len()` reading out of bounds. Consider:

Ptr byte to cstring?

2023-12-22 Thread Nlits
I am working with the [freeimage](https://nimble.directory/pkg/freeimage) nim library/wrapper, and have this code: proc compressJpeg(imgData: string): string = ## Use freeimage to compress the jpeg files # Open image var mem = FreeImage_OpenMemory(cast[ptr

Enhancing Nim vtable implementation vs subtype checking

2023-12-22 Thread ringabout
> would it be possible to remove the vtables limitation of having to declare > the method in the same module as the type Like the former implementation, the vtable implementation generates dispatchers only in the main module codegen in order to collect all the possible method defintions among

`nph` opinonated formatter v0.2

2023-12-22 Thread auxym
Any reason why Nim 2.0.2 is not supported?

Binaries does not correctly display dependencies

2023-12-22 Thread enthus1ast
I use 'strace' quite often to really see what a binary loads from disk.

Binaries does not correctly display dependencies

2023-12-22 Thread Yardanico
And to add a bit, there's an option for x11 specifically to link directly against the system libraries, see \- just pass `-d:use_pkg_config` when compiling your program.

Capture atomics in closure

2023-12-22 Thread bobbersen
Thanks for pointing that out, it's a really helpful example for me. I just started getting into weave and laser recently and I'm pretty sure I would sooner or later stumble over a similar problem. I'm planning on implementing some algorithms using weave to compare performance of various

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread zevv
Of course there is still CPS, where the overhead of a continuation is only tens of bytes, no stacks need to be allocated and no support from the OS is needed to switch contexts. CPS has been used to build coroutines, actors, fibers and more, and easily scales to thousands or millions of

Binaries does not correctly display dependencies

2023-12-22 Thread Araq
IMHO your tools don't correct display dependencies, full stop. Libraries can be loaded dynamically, it's a feature of the OS, widely used by Python, Lua, Ruby, Perl, ...

Enhancing Nim vtable implementation vs subtype checking

2023-12-22 Thread rockcavera
I meant the following: transitioning a project using current methods to using methods with vtables may not be an easy thing to do, as there is the limitation of having to declare the methods in the same type module. In my case, a project where I have a lot of method calls, I wanted to test the

Binaries does not correctly display dependencies

2023-12-22 Thread Yardanico
That's because when you use dynlib, it loads libraries dynamically with dlopen and doesn't link against them, you can manually link against the libraries you use so they'll appear in ldd.

Wishlist: Ideal UI library for Nim

2023-12-22 Thread CardealRusso
https://github.com/yglukhov/nimx

Binaries does not correctly display dependencies

2023-12-22 Thread CardealRusso
I think that absolutely everything I've compiled with nim to date has had this problem. But for example I used: linux-vdso.so.1 (0x7fff3433) libdl.so.2 => /lib/libdl.so.2 (0x7fe4c5e7d000) libpthread.so.0 =>

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread jrfondren
The Rust link is not abandoning coroutines, but about switching from Memory Footprint mitigation strategy 2.1.3 to 2.1.2. The Go link is similarly about switching from mitigation 2.1.3 to a Go-only mitigation that relies on some useful Go properties. Stackful coroutines are prominent in Lua and

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread mratsim
`std/coro` actually does stackful coroutines, i.e. fibers. A fiber needs to create it's own stack and switch to it. Nim threads use 2MB stacks, not sure what's the stack size of `std/coro` but it also needs to be sizeable. See also "Fibers under the magnifying glass":

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread mratsim
Also every major language has abandoned fibers / green-threads / stackful coroutines for their standard library. * Go: * Java in 0.1 * Rust:

Wishlist: Ideal UI library for Nim

2023-12-22 Thread AntonioFS
Hello. And of course this is a very relevantly important thread, which is why, from my limited knowledge of Nim so far, I encourage Nim specialists to get involved in the search for a GUI solution that adapts to the language as soon as possible, as a standard to be improved from the beginning,

Parallelism in Nim: trying to call proc with my argument

2023-12-22 Thread mratsim
> About edit: i experimented with for loops. We measure time for running > without threading and with that. Just for that cause i used CpuTime() :) If you have 8 threads and each spend a second to do something, the CPU time is 8s. What you're interested in is the wall time / elapsed time, use

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread zevv
The part I was referring to in particular is the `wait()` function that causes in a nil deref when called from a non-fiber context.

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread PMunch
Not surprising, it's a higher level construct. But this might also be part of the "it's broken" thing Zevv mentioned.

부산출장업소❎라인※AG775​​​​​​​❎부산조건만남

2023-12-22 Thread rigsirvow
[img][https://pbs.twimg.com/media/F3qHaOIXAAEtq2O?format=jpg=360x360[/img]](https://pbs.twimg.com/media/F3qHaOIXAAEtq2O?format=jpg=360x360\[/img\]) 부산출장업소❎라인※AG775​​​❎부산조건만남⛑️부산실제만남⛑️부산매너만남⛑️부산출장안마​​​❎라인※AG775​​​❎부산싱글맘⛑️부산간단

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-22 Thread aiac

Parallelism in Nim: trying to call proc with my argument

2023-12-22 Thread Duboak
About edit: i experimented with for loops. We measure time for running without threading and with that. Just for that cause i used CpuTime() :)

Parallelism in Nim: trying to call proc with my argument

2023-12-22 Thread Duboak
FML. You absolutely right about type in Thread. Big tnx! I skipped it for my example xd Hello Ivan! Your number: 0 Hello Maxim! Your number: 1 Hello Maikl! Your number: 2 Hello Alex! Your number: 3 1.267 Run

Parallelism in Nim: trying to call proc with my argument

2023-12-22 Thread PMunch
Well the error message is complaining that you're trying to run a `Thread[int]` with a `proc (_: Student)` and a value of type `Student`. The generic type of the thread needs to match the argument. Apart from that I believe the `threads` variable has to be global.

Parallelism in Nim: trying to call proc with my argument

2023-12-22 Thread Duboak
Hello! I have this experimental code: import strformat import os import times type Student* = object name: string num: int proc sayHi(student: Student) {.thread, nimcall.} = echo fmt"Hello {student.name}!