how to pass multiple parameters into proc - not varargs

2020-08-11 Thread Hlaaftana
I don't really understand your problem, but what you want is probably a combination of named and default arguments? proc newPerson(name: string, age: int, job: Option[string] = none(string)): Person = # ... let a = newPerson(name = "John", age = 30) let b = newPer

Nim website front page redesign (unofficial and WIP)

2020-08-11 Thread doongjohn
Update: new url: [https://nimfrontpage-fun.vercel.app](https://nimfrontpage-fun.vercel.app) Todo: * dark/light theme switch * implement playground * add featured projects (games, library, etc...)

how to pass multiple parameters into proc - not varargs

2020-08-11 Thread Salient
What's up guys, I'm trying to pass multiple parameters into my procedure based on the key-value pairs of a Json object. I have many procedures, all having various amounts of parameters and types. I'm trying to have a single proc that places the appropriate parameters into the appropriate posit

Problem with cross-compiling for Windows

2020-08-11 Thread hauser
So while trying to cross-compile a pretty simple Nim program for Windows, I get the following error message during compilation: Error: execution of an external compiler program '/usr/bin/x86_64-w64-mingw32-gcc -c -w -mno-ms-bitfields -O2 -g -pipe -Wall -Werror=format-security -Wp

Why `openArray[int] | HashSet[int]` doesn't work?

2020-08-11 Thread mratsim
It's a bug: [https://github.com/nim-lang/Nim/issues/7432](https://github.com/nim-lang/Nim/issues/7432)

Local dev: nimble install or symbolic links?

2020-08-11 Thread jasonfi
Thanks.. I should have looked at the nimble options again, I think I have used this before!

Local dev: nimble install or symbolic links?

2020-08-11 Thread stisa
Nimble has a mode for that, `nimble develop`. I think it fits your use case

Local dev: nimble install or symbolic links?

2020-08-11 Thread jasonfi
I'm working on a project where I've separated libraries/applications into different nimble packages to make things more organized and reusable. However my worry is that if I forget to run a "nimble install" command when I've made changes to a library, I could have trouble debugging code that isn

A simple bitsarray lib

2020-08-11 Thread cblake
You both might be interested in something called "Aggregate Bit Vectors". The idea is simple: for each big 64-bit or whatever word in your bit vector, let that be just 1 bit in a "level higher" structure if _any_ bit is on and zero if they are all off. You can then do the same trick again for a

call-by-value Y combinator

2020-08-11 Thread cblake
Also, if you want to make the code look more recursive (maybe subjective...), you can add a for-loop macro to some `thatDef.nim` module: import macros # This needs {.experimental: "forLoopMacros".} macro toItr*(x: ForLoopStmt): untyped = ## Convert factory proc call f

Nim for Beginners Video Series

2020-08-11 Thread lum
**Hi**! I really like your videos! Can you make a video about **metaprogramming**? I think it will be interesting

A simple bitsarray lib

2020-08-11 Thread treeform
Hey I made one as well :) [https://github.com/treeform/bitty](https://github.com/treeform/bitty) I think bit operations are fun.

Nim for Beginners Video Series

2020-08-11 Thread Kiloneie
#24 is live at: [https://youtu.be/aME-tyPCPvE](https://youtu.be/aME-tyPCPvE) Objects.

Why use range[0..255] instead of char?

2020-08-11 Thread digitalcraftsman
> Not in a strongly typed language. A char is a character while a range[0 .. > 255] is an integer in the range 0 to 255. @spip of course the type system distinguishes between char and range[0..255] as types. My last comment was about a char that can be seen as a (printable) character like 'w' o

Why use range[0..255] instead of char?

2020-08-11 Thread sky_khan
Nim is not (kinda) typeless as C. You cant assign integer values to a char variable directly in Nim. So, if you declare it's parameters as char, you would have to convert your integers to char like rgb(chr(255),chr(0),chr(0))

Why use range[0..255] instead of char?

2020-08-11 Thread spip
Not in a strongly typed language. A `char` is a character while a `range[0 .. 255]` is an integer in the range 0 to 255. Just like the temperature of my oven can not be interpreted as an amount in my wallet!;-)

Why use range[0..255] instead of char?

2020-08-11 Thread digitalcraftsman
That's just a matter of perspective: one can interpret a char as a character or as a plain byte ;)

Why use range[0..255] instead of char?

2020-08-11 Thread sky_khan
Because rgb("w","t","f") doesnt make sense :)

Using "Checked C" compiler with Nim

2020-08-11 Thread moerm
Here is a real world example excerpt taken from some of my C code (with anonymized function and var names) so you can see how it looks like: #include //... typedef struct { uint32_t P checked[128]; uint32_t Q checked[128]; } FOO_State; //... u

Using "Checked C" compiler with Nim

2020-08-11 Thread moerm
You must understand what it's about and how it works. If you just use it like a normal C compiler, it will behave like that (specifically like clang) which isn't particularly useful and adds nothing in terms of safety/correctness. For that you must "annotate" the C code, in particular arrays and

Why use range[0..255] instead of char?

2020-08-11 Thread digitalcraftsman
My initial consideration was that range[0..255] doesn't require a explicit type cast but the program has to ensure that the argument is indeed between 0 and 255. In the end the compiler either knows the value of the arguments at compile time or the value is determined at run time (i.e. by readin

Using "Checked C" compiler with Nim

2020-08-11 Thread Mats
Hi, I stumbled on the Microsoft opensource (MIT) "Checked C" project, has anyone tried using this safer c compiler (based on clang/llvm) as NIM compiler? I guess being able to use "Checked C" with NIM would build an even stronger case for NIM as a safe programming language. [https://www.micros

Why use range[0..255] instead of char?

2020-08-11 Thread SolitudeSF
so you can construct it with any integer arguments.

Why use range[0..255] instead of char?

2020-08-11 Thread digitalcraftsman
Hello guys, while browsing the Nim standard library I noticed that a contructor for the [Color](https://nim-lang.org/docs/colors.html#rgb%2Crange%5B%5D%2Crange%5B%5D%2Crange%5B%5D) type is defined as follows: proc rgb(r, g, b: range[0 .. 255]): Run Why would one limi