Errors with Option[T] on 1.4.8

2021-11-28 Thread codic12
works as a workaround, i guess. thanks! the reason I need it to compile on 1.4.8 is to package it for the AUR; choosenim on the AUR gets a bit messy.

Errors with Option[T] on 1.4.8

2021-11-28 Thread codic12
Sorry for not being able to create a minimal reproducible example for this, everything I've tried compiles fine. I have a decently sized project (<https://github.com/codic12/worm>) which builds just fine with Nim 1.6.0. However if I am using Nim 1.4.8, there are strange compila

Attempt to read from nil, Arc bug?

2021-06-25 Thread codic12
How would I signal them?

Attempt to read from nil, Arc bug?

2021-06-25 Thread codic12
`while true: discard` is a placeholder for an event loop that I'll add later on. I guess detach is not the right behavior. I want to spawn my threads, and at the end, terminate all of them (not wait on them). I guess I can use an array of threads, but how do I kill a thread?

Attempt to read from nil, Arc bug?

2021-06-24 Thread codic12
I don't really care where the thread is allocated as long as it works and I don't have to worry about it after I spawn it, which is what detach in C++ does. Is there a Nim equivalent?

Attempt to read from nil, Arc bug?

2021-06-24 Thread codic12
Oh yes I see the issue. I changed it to use an array of size 1 everywhere, the issue was the implicit null terminator. Thanks for pointing me to the right way!

Attempt to read from nil, Arc bug?

2021-06-23 Thread codic12
It does not for me, are you compiling with --gc:arc? Could you share the code that you modified?

Attempt to read from nil, Arc bug?

2021-06-23 Thread codic12
I see, so I should use the pthread api directly?

Attempt to read from nil, Arc bug?

2021-06-22 Thread codic12
The behavior I want is equivalent to the C++ detatching of threads; I come from Rust, where this happens automatically, so I didn't have to worry about that; how do I do that in Nim? Ideally I just want the threads to be killed when the application terminates. and why must the thread object be

Attempt to read from nil, Arc bug?

2021-06-22 Thread codic12
I missed this, thanks! It does still SIGSEGV though.

Attempt to read from nil, Arc bug?

2021-06-22 Thread codic12
I wrote this code a couple days ago and tested it with the default gc, it worked as expected: if I compile with gc = arc or gc = orc, though, I get a segfault: Got here No stack traceback available SIGSEGV: Illegal storage access. (Atte

Writing a kernel in Nim

2021-06-16 Thread codic12
Still trying on this, any help welcome!

An simple nrpl for nim

2021-06-11 Thread codic12
Actually it can't find nim in the path for me, it's installed with choosenim and in my user's path.

An simple nrpl for nim

2021-06-11 Thread codic12
Compiles with latest devel and works fine (used gc:orc). I can't use the FFI compilation though: /home/user/.choosenim/toolchains/nim-#devel/compiler/evalffi.nim(14, 11) Error: cannot open file: pkg/libffi Run

An simple nrpl for nim

2021-06-10 Thread codic12
Looks great! Doesn't compile for me though: /home/user/nims/nims.nim(513, 25) Error: attempting to call undeclared routine: 'spellSuggestMax=' Run

Safe signal handling

2021-06-09 Thread codic12
I implemented the self-pipe trick, it's really easy to do for future reference, just write a byte (something like an ascii period) and spawn a thread reading the pipe. Everything you need is in posix

Safe signal handling

2021-06-09 Thread codic12
Looks nice, any examples of using it to handle signals?

Safe signal handling

2021-06-09 Thread codic12
Alternatives: set an atomic variable and poll that (very cpu heavy but should be 100% safe), use kqueue on BSD and signalfd on Linux

Safe signal handling

2021-06-09 Thread codic12
The posix.onSignal function, as well as the raw sigaction, have a very limited list of functions you can call in the handler; in particular no heap allocation is a big one. Is there any way to achieve safe signal handling in Nim without these limitations? My application has a socket server runni

Nim JSON parsing is 30 times slower than Node.JS

2021-06-02 Thread codic12
Quick side note: deno isn't node although they both use v8.

Writing a kernel in Nim

2021-06-02 Thread codic12
Yeah, I dropped the `useMalloc` from the above attempt.

Writing a kernel in Nim

2021-06-01 Thread codic12
I encounter the same issue not using malloc but using standAloneHeap (with or without arc): nim cc --cc:clang --cpu:i386 --noLinking:on --nimcache:"." --passC:"-m32 -ffreestanding -fno-stack-protector" --os:any -d:StandAloneHeap=1047856 --gc:arc --noMain:on kernel.nim

Writing a kernel in Nim

2021-06-01 Thread codic12
This command: nim cc --cc:clang --cpu:i386 --noLinking:on --nimcache:"." --passC:"-m32 -ffreestanding -fno-stack-protector" --os:any -d:useMalloc -d:StandAloneHeap=1047856 --noMain:on kernel.nim Run still asks me to port the memory manager. also, what's that arbitrar

Writing a kernel in Nim

2021-05-31 Thread codic12
Where do I create those functions? Can I just create temporary stubs?

Writing a kernel in Nim

2021-05-31 Thread codic12
-os:any| wants me to port a memory manager, I'll look at the code of that JackOS

Writing a kernel in Nim

2021-05-31 Thread codic12
Thanks for the reply, how do I make Nim generate system.o? I just have stdlib_system.nim.c.o, which depends on quite a bit of libc stuff.

Writing a kernel in Nim

2021-05-31 Thread codic12
Nimkernel doesn't compile with the latest Nim, sadly; some message about appendString

Catching shell resizes (asynchronously?)

2021-05-30 Thread codic12
You can use a background thread but polling the size is the wrong approach, and will eat up lots of resources. Better to listen for SIGWINCH though I'm not quite sure how standardized it is

Writing a kernel in Nim

2021-05-30 Thread codic12
Nim's syntax looks like it would be great for writing a toy x86 kernel after the initial hurdles. I wrote a simple file, kernel.nim: proc kmain {.exportc.} = discard Run And compiled it like this (supposed to be linked later): nim cc --cc:clang --cpu:i3

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-03 Thread codic12
These look like good approaches. Thanks for the replies!

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-03 Thread codic12
I do not want to use the shell, but run it directly.

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-03 Thread codic12
I need to execute a child process while my main Nim code is running.

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-03 Thread codic12
I am fairly sure my code is not idiomatic, as it is directly using std/posix, with execl and fork; basically what you would do in C

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-02 Thread codic12
Already looked at that. I'm just curious which function to use to be the most idiomatic as for what I described.

Idiomatic way to run a process in the background and close it when appropriate?

2021-05-02 Thread codic12
I'd like to spawn a process and run it in the background. I'd also like it to be closed when and if the process finishes executing. I looked through osproc's functions, but I can't figure out what is the most idiomatic way to do this. Also, I'd like the call to block until it spawns the process,