Rust interop/FFI experiments?

2024-05-09 Thread mratsim
My cryptographic library accelerates Rust: * In particular this: Implements the traits:

Single parameter version of varargs

2024-05-09 Thread dsrw
This works: proc toRange(a: HSlice[int, int]): HSlice[int,int] = a proc toRange(a: int): HSlice[int,int] = a..a proc toIntSeq(a: HSlice[int, int] | int): seq[int] = let r = a.toRange for v in r: result.add(v) echo toIntSeq(20) echo to

Nim in university context?

2024-05-09 Thread hamidrb80
> And as a bonus LLMs are pretty bad at Nim, so I guess cheating would be > harder. LOL I use Nim for my homeworks, my profs were impressed that such language exist. I had presentation about it but I couldn't convince them to use Nim for teaching. [they use C++ & Python for that purpose ]

K-nth smallest element - Library

2024-05-09 Thread Hobbyman
Please elaborate...

Using threads with gui Nigui

2024-05-09 Thread Trustable
Hi. When I run your test program (under Linux), the messages don't appear all at once. One small suggestion for improvement: The application is not very response, because recv() waits until something is received. You can use tryRecv() in combination with app.sleep() instead. > > import n

Puzzling compiler crash

2024-05-09 Thread lou15b
An additional piece of information. I passed the equivalent source code to the `dumpCompiledCode` macro instead of the output from `refObjectDestructor`: dumpCompiledCode: proc `=destroy`(x: typeof(Marker()[])) = `=destroy`(x.tref) Run The result was

Single parameter version of varargs

2024-05-09 Thread thedistantforest
Yep cool it seems to work. It also works with auto proc toIntSeq(a: auto): seq[int] = let a = a.toRange Run Though it would be nice to see the actual type on the function signature that like how `varargs[type, ...]` shows

Puzzling compiler crash

2024-05-09 Thread lou15b
AST generated by the `refObjectDestructor` macro (obtained by inserting `echo treerepr(result)` at the end of the macro): ProcDef AccQuoted Ident "=" Ident "destroy" Empty Empty FormalParams Empty IdentDefs Ident "x"

K-nth smallest element - Library

2024-05-09 Thread felipecruz
Library with the (some of) best known strategies for the K-nht smallest element in an array/sequence. Might come handy for other algorithms that require median finding such as a KD-tree and others. The only strategy so far is the implementation of [Quickselect with random pivot](https://en.wik

Single parameter version of varargs

2024-05-09 Thread SolitudeSF
just make it generic? proc toIntSeq[T](a: T): seq[int] = let a = a.toRange Run

forward declare and extend object (I know it does not work)

2024-05-09 Thread ingo
Forward declaring an object won't work, I know, but it describes kind of what I want. In the code below I (at some time will) have in a library objects and procs for defining and working on a half edge based polygon datastructure. The user (I) can define properties for the connection elements i

Single parameter version of varargs

2024-05-09 Thread thedistantforest
Hi I just discovered the neat feature in nim of allowing conversions of parameters before it enters the actual proc. I'm curious however if there's a version of this that allows for a single parameter instead of an array of them? An example for anyone to play around with: proc toRa

Rust interop/FFI experiments?

2024-05-09 Thread arnetheduck
We have a guide written here: The short story is that it's easy to make rust behave like C for FFI purposes, and from there, everything you know about C-Nim FFI becomes applicable (which can be seen in the above guide: most of the

Using threads with gui Nigui

2024-05-09 Thread MauroG
I'm trying to use threads because I want to write messages in textArea and these messages are generated by a proc called by click a button: import nigui import std/strformat import os var ch: Channel[string] proc messaggiInTextArea(primoMsg: string) {.thread