A few (perhaps naive) questions

2023-08-05 Thread jrfondren
> The corresponding C program, using long long, could go up to 94th. #include #include int main() { int i, nth = 95; long long fnm2 = 0, fnm1 = 1, fn; for (i = 0; i < nth; i++) { fn = fnm2 + fnm1; fnm2 = fnm1; fnm1 = fn;

Is ORC considered production-ready? What is the consensus on its use?

2023-08-05 Thread Araq
I know a couple of projects that use asyncdispatch with ORC successfully for months without any crashes.

autome import throws error

2023-08-05 Thread Araq
`expr` is now `typed`.

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread hugogranstrom
Sweet! :D Macros are pretty frickin' cool when you realize how simple they can be! As for pragma, you should be set to go already:

Trouble Porting to FreeBSD

2023-08-05 Thread thindil
Just a small update after some tests, more like note for myself. ;) The whole process of installing Nim on FreeBSD looks that (without downloading, decompressing, etc.): 1. Run `./build_all.sh` 2. Copy proper binaries to _/usr/local/bin_ 3. Copy _lib_ directory to _/usr/local/lib/nim/_ , s

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread Isofruit
Exactly things like this! I tried your approach and it worked beautifully. In fact, I switched approaches a bit and instead of generating a new proc, I just take the procDefinition, copy the node and add a bunch of assignment statements to the body of the copied proc definition and return that,

Is ORC considered production-ready? What is the consensus on its use?

2023-08-05 Thread termer
> It's a bit later, but it does seem like the stdlib's async library will need > some TLC to work well with ORC. Future's cause all sorts of chaotic cycles. > Ideally the core async library will be ARC compatible itself, which would > make it more deterministic. I imagine in the coming months t

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread hugogranstrom
> Did you try this out? As long as the proc body is valid (which it is in this > case), it should to the best of my knowledge just work I'll add a bit more on this and how to solve this kind of problem when it doesn't work. Let's say that `generateMrapper` injected a new variable in your proc,

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread hugogranstrom
I'm not entirely sure I understand you completely, but I read it as you wanting a nicer syntax for your `generateMapper` macro? > For context on why I have 2 parameters in my macro: I'm so far under the > impression that I need to keep the procdef and the explicit assignment > statements below

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread Isofruit
Thank you so much! Yes that worked and I got my project to work as I wanted. Then a small question for suggestions: The current syntax that I got this to work with is this one: ... lots of procs and macros... macro generateMapper(procDef: typed, explicitMappings: untyped):

A few (perhaps naive) questions

2023-08-05 Thread koistinen
I googled "nim bigints" and got and figured it out from the readme.md file. If I had gone on to read the examples folder I would likely have written nicer code.

autome import throws error

2023-08-05 Thread geotre
Looks like the package hasn't been updated in 7 years, you'll need to fork and update the package or switch to an older version of Nim

autome import throws error

2023-08-05 Thread IvanS
Yeah, saw it's rather old. I've got it to work by editing it to exclude the mouse functions. Need to compile with --nilseqs:on since it uses string = nil I'll look into wAuto, that package is more up to date.

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Thank you! It worked as expected.

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Just one more detail. Modulo the import bigints Run nim how did you know how to use fnm2 : BigInt = initBigInt(0) fnm1 : BigInt = initBigInt(1) fn : Big_int Run nim part? Sorry for my question, but thus I have never used any libr

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Interesting. Although, to my mind, this does not explain the tiny gap between Nim and C. Thank you very much!

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
I used nimble install bigints. Can you install libraries with choosenim as well?

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Useful. The thing is that Nim (with int) goes up to 91st whilst C (with long long) up to 94th (small, but noticeable difference). Thank you.

Why this nim code is not valid?

2023-08-05 Thread mohan24
Thank so much for your help, i really respect that🙏

Can I use Nim with GPU Computing?

2023-08-05 Thread sls1005
If you are on Windows, you should use `.dll` as extension name instead of `.so`.

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread hugogranstrom
To get the type of a node, you need to use a `typed` macro: macro generateMapper(body: typed): untyped = Run Simplified explanation: An untyped macro doesn't know anything about what each identifier (ident) actually refers to. A typed macro instead used symbols (as ne

Can I use Nim with GPU Computing?

2023-08-05 Thread 4n0n4me
I am not familiar with CUDA or OpenCL. I don't use them by programming in C, instead, with Python packages, only what I need to do is to install CUDA. I am trying to brute SHA-512 with Nim. At first, official package `checksums`, but I find it very slow. is mu

How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")

2023-08-05 Thread Isofruit
I've been playing around with some metaprogramming in nim and found myself wanting to have a list of fields of a type I receive a node for from a proc definition. Basically I have a macro that takes in a proc definition and generates a proc based on that and some statements. The syntax looks lik

autome import throws error

2023-08-05 Thread IvanS
I would like to use autome to check for hotkeys, but compiling my program throws an error: import autome let hotkey_check = registerHotkey(0x43, {modAlt}) # Alt-c waitForHotkey(hotkey_check) echo "Hotkey Alt-c invoked" Run mouse.nim(5, 22) Error

Why this nim code is not valid?

2023-08-05 Thread blackmius
` nim import strutils, sugar type Writer[A] = (A, string) proc to_upper(s: string): Writer[string] = (s.toUpperAscii(), "to_upper()") proc to_words(s: string): Writer[seq[string]] = (s.split(" "), "to_words()") proc compose [A, B, C]( m1: (A) -> Writer[B], m2: (B) -> Writer[C] ): (A) -> Writer[C

A few (perhaps naive) questions

2023-08-05 Thread koistinen
After, installing choosenim and latest stable nim and bigints I tried: import bigints var nth : int = 500 fnm2 : BigInt = initBigInt(0) fnm1 : BigInt = initBigInt(1) fn : Big_int echo(fnm2) for i in 0 ..< nth: fn = fnm2 + fnm1 fnm

A few (perhaps naive) questions

2023-08-05 Thread sls1005
Nim's `int` is usually (but not guarated to be) the same as C's `long int`. To get the similar behavior as C's `unsigned long long int`, there's a integer type named `culonglong`.

CBOR?

2023-08-05 Thread blackmius
i made small google research on finding CBOR and yes there is no nim implementation. maybe it would be easy to make bindings to existing c/c++ libraries

A few (perhaps naive) questions

2023-08-05 Thread Isofruit
That is the nature of the beast, your int64 is pretty much running out of space to represent a Fibonacci number that large (and ends a bit earlier in nim because the fact nim ints are signed by default means defacto it's 63 bit in order to be able to represent negative numbers. Got to use uint64

Why this nim code is not valid?

2023-08-05 Thread mohan24
I was trying to convert this rust code(which my friend made long ago) into nim: [https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9c5e295e7e9de7d5e2ba0c17ec5bf0da](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9c5e295e7e9de7d5e2ba0c17ec5bf0da) So m

A few (perhaps naive) questions

2023-08-05 Thread koistinen
int is a fixed number of bits in nim. You might want to use a type like bigints. Start by getting: import bigints Run to work.

A few (perhaps naive) questions

2023-08-05 Thread demotomohiro
`sizeof(int)` is same to pointer size in Nim. That means int is 64bit on 64bit CPU and is 32bit on 32bit CPU. int in Nim is signed int. If you use uint or uint64, you can use larger value but NO overflow check. If you need larger size int type,

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Thank you very much. Unfortunately, my knowledge of C is not sufficient to appreciate the topic regarding the second link you mentioned. So, bottom line is that there is no _native_ way to go further in the sequence without the library you mentioned in the first link, right? Again, thank you.

A few (perhaps naive) questions

2023-08-05 Thread Odysseus
Hello to all! I am a newcomer in the _Nim_ programming language. My experience in programming, so far, includes: 1. _Pascal_ (as a University student, way too many years back) 2. 3-4 failed (at various stages) attempts to learn _C_ 3. a working knowledge of _Mathematica_ (for symbolic stuf

Nim version 2.0.0 is here

2023-08-05 Thread Odysseus
Hello, if I may, just a tiny bug I have observed in my system (Void Linux) with the Fish shell. The choosenim tool, near the end of the process, suggests that for the case of the Fish shell one should use: $ set -ga fish_user_paths /home/$SUSER/.nimble/bin but such invocation is not persistent