Fill array in C style

2022-08-22 Thread nya
Thanks to all for examples. I thought that it is can be done only with generating array/sequence during compile time. @xigoi Sorry, it's my error, you are right. Non zero fill initialization in C really possible only in runtime. Or I must use GCC extension or doing filling sequence with preproc

First program does not compile and is hard to debug

2022-08-22 Thread franchesoni
Hello, I spent the last three days learning Nim, and just today coded the application I wanted to do (an image processing filter). As I wrote what I wanted as math, I wanted to code it like math (functionally and using for loops), but Python was too slow, thus I looked for an alternative langua

Can't get basic example of creating reference objects to work. Compilation errors.

2022-08-22 Thread xigoi
Oh no. It's been revealed that all accounts on this forum are just Araq pretending that someone is using his language.

Fill array in C style

2022-08-22 Thread xigoi
By the way, the C code you provided doesn't actually fill the array with 500; it sets the first element to 500 and fills the rest with zeroes.

Why is nimscript interpreted and why the limitations?

2022-08-22 Thread ElegantBeef
It would mean for every single compile time evaluation you'd have to compile a program which will slow down compile time even further. This means for every `static` block or anything that can be done statically you go out to a compiled program. Macros, any constant evaluations through `static` o

Fill array in C style

2022-08-22 Thread ElegantBeef
For clarity this does not require a template, a procedure works fine: proc initArray[T](size: static int, value: T): array[size, T] = for ele in result.mitems: ele = value const arr = initArray(10, 500) const arr2 = initArray(5, "hey") proc mai

Tuple unpacking for an array rvalue?

2022-08-22 Thread franchesoni
I am having the same issue!

Fill array in C style

2022-08-22 Thread jyapayne
Not sure if there is a better/easier way, but this will only fill the array at compile time: template initArray[T](size: static int, value: T): untyped = block: var res: array[size, T] for i in 0 ..< res.len: res[i] = value res const a

Fill array in C style

2022-08-22 Thread nya
Hello. Can Nim fill array with same value (not zero) while defining array? I know about `fill` method in standard library, but it is initialization in runtime (instead of creating static filled memory blocks in pre pre main by compiler). int array[10] = {500}; int main() {

Why is nimscript interpreted and why the limitations?

2022-08-22 Thread turmoil
Genuinely interested about the design decision for nimscript. Why is it interpreted? Is it not possible to compile the nimscript to a local binary and then execute, or JIT compile it? Or is this too complex to implement for little benefit?

Is it possible to create a blockchain with the nim programming language?

2022-08-22 Thread MareliMurray
It's hard to answer your question unambiguously, cosmos blockchain platform plans to integrate with at least two new programming languages ​​for smart contracts Secure ECMAScript and Kadenamint.

Convert Python codes to Nim codes

2022-08-22 Thread mratsim
Here is with an "unsate" slice version that doesn't use experimental features. It compiles but results are different. I added one string formatting but I think another one is missing #--- # Name:

Issues when creating static library on macOS

2022-08-22 Thread vitaliy
Hi all! I'm building a static library named `lightclient` on macOS via this command invocation: nim c --app:staticlib --header:lightclient.h --noMain lightclient.nim Run During the final stage, when the build process invokes `ar` tool, i get this error:

String vs Array concatenation

2022-08-22 Thread mratsim
> Copying strings is computationally trivial because they are guaranteed to not > contain complex types like seqs might. You can just copy their entire block > of memory verbatim once. That can definitely be tens or hundreds of times > faster than copying individual items. Probably we can speci

use memlib call dll proc face nil access

2022-08-22 Thread bung
it's nil acceptable

Convert Python codes to Nim codes

2022-08-22 Thread whospal
Sorry, I'm still lost about how to use the slide.

use memlib call dll proc face nil access

2022-08-22 Thread PMunch
Well you're passing in a null as the third argument, presumably that might be the cause.

Can't get basic example of creating reference objects to work. Compilation errors.

2022-08-22 Thread abdulhaq
I was going bald by the age of 27. If this guy sticks to C++ he's going to be bald before he gets to 21!

Nim without libc?

2022-08-22 Thread elcritch
It depends a lot on what stdlib modules you use as well. The embedded use cases should be good guides. Most things in std/os for example will pull in more C functions.

Nim without libc?

2022-08-22 Thread guibar
This section of the compiler manual may be useful: For info compiling an hello world program with `nim c --gc:arc --os:any -d:useMalloc` on linux uses the libc functions: U calloc@GLIBC_2.2.5

String vs Array concatenation

2022-08-22 Thread Hlaaftana
The procs in system above with the signature `proc `&`*[T](x, y: sink seq[T]): seq[T]` (notice sink) are supposed to optimize by using inplace `add` (which will not always copy), but they don't seem to do so. Using `add`, if possible, is what you are supposed to do. Copying strings is computati

Can't get basic example of creating reference objects to work. Compilation errors.

2022-08-22 Thread Clonk
> I'm having some success with C++ since this morning & Code::Blocks is much > nicer than VSCode. I hate VSCode now too. You have to fight it to compile > some code... Code::Blocks works out-of-the-box, Yeah it's a well kept secret that Code::Blocks is in fact the superior solution and ultimate

String vs Array concatenation

2022-08-22 Thread drkameleon
I've been benchmarking a bit to see how different things work (in Arturo) and one of these is: concatenation/appending-to an array vs a string. The exact same operation is slower for arrays than for strings. Which is not so surprising. What _is_ surprising is that what I'm calculating is roughly

Nim without libc?

2022-08-22 Thread pp
Maybe there is some potential using , that can create executables that work on 6 OS with no change (Linux, Mac, Windows, NetBSD, FreeBSD, OpenBSD). I was asking myself if any Nim guy did play with this... and this post gives me the opportunity.