Installing choosenim (on Windows) on a custom folder does not seem to work

2022-04-19 Thread didlybom
It is not an option for me to switch to Linux in my work laptop, specially given that we develop Windows software :) It seems to me that choosenim should remember / detect that it’s installed in a custom folder. Having to type the choosenim and nimble paths every time is not para ti al and very

Fidgets: widgets using Fidget

2022-04-19 Thread elcritch
# Events API for Fidgets Got an initial event API setup for Fidgets. It uses Patty to create ADT's so Fidgets can statically check their event inputs. Here's the results using an async hook: Here's an example usage for defining the events: proc animatedProgress*( delta: fl

Installing choosenim (on Windows) on a custom folder does not seem to work

2022-04-19 Thread archnim
> and even adds it to the path The fact that your custom dir has been added to the path only means that the system can run the programs inside it. Choosenim doesn't refer to that information.

Installing choosenim (on Windows) on a custom folder does not seem to work

2022-04-19 Thread archnim
> Am I doing something wrong? If you have installed choosenim in a custom directory, You always have to pass the '\--choosenimDir' param. If not choosenim won't guess where you want it to work. Then it will return to default dir. That's why choosenim is reinstalling itself over and over in ~.ch

Installing choosenim (on Windows) on a custom folder does not seem to work

2022-04-19 Thread archnim
On Linux, to add automatically `--choosenimDir` and ` --nimbleDir`, you could simply create a command alias or a shebang script. There should be something similar on windows. I really encourage you to switch to linux.

Varargs limitation

2022-04-19 Thread archnim
> It really works ! It seems that there must be at least at least one value for > the varargs. Interesting !

Varargs limitation

2022-04-19 Thread archnim
It really works ! even without the `@`. The manual says about varargs: > This transformation is only done if the varargs parameter is the last > parameter in the procedure header. It should be updated...

Varargs limitation

2022-04-19 Thread Hlaaftana
This already works. proc blabla(arg1: int, arg2: varargs[char], arg3: int) = echo arg1, @arg2, arg3 blabla 3, 'd', 'e', 's', 'a', 7 Run Multiple varargs are also supposed to be disallowed, [see issue](https://github.com/nim-lang/Nim/issues/19332).

Varargs limitation

2022-04-19 Thread archnim
Beyond that question, I'm asking myself if it's necessary to always put a varargs at the end. I think that while there is only one varargs allowed per proc, we can avoid undecidable situations. I imagine a Nim where: * You can pass only one varargs[T] to a proc * You must pass at least enou

Varargs limitation

2022-04-19 Thread juancarlospaco
`openArray`.

Varargs limitation

2022-04-19 Thread archnim
Hello world. Since a varargs[T] most be the last argument of its function, is there any way to pass a block to a template that uses varargs ? For exemple is it possible to write a version of `withLock` that acquires several locks at once ? import locks var lk1, lk2,

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-19 Thread krakengore
Great thanks, working directly with nimcall and avoid splitting closures raw parts is way better ! This is what i'm looking for, looking good so far (but still a long way to go !!!): import macros {.emit: """/*TYPESECTION*/ #include #include // This is p

server-client webframework

2022-04-19 Thread reversem3
excuse my ignorance but what makes this web-framework different then say , prologue , jester, the dozens of other web frameworks on nimble.directory?

Seeking advices for a C programming book

2022-04-19 Thread reversem3
Does it make sense to go over the types and generics in Modula3 to understand nim better ?

Program level variables

2022-04-19 Thread PMunch
The [global](https://nim-lang.org/docs/manual.html#pragmas-global-pragma) pragma can also be used for similar behavior to static class members in C++.

Optimize parsing large file line-by-line

2022-04-19 Thread dom96
> Note that parsing files was discussed in the Manning book Thanks for mentioning! In case you want to have a look at the example code from Nim in Action: . Happy to answer any questions about it.

Optimize parsing large file line-by-line

2022-04-19 Thread ingo
> Note that parsing files was discussed in the Manning book, and I recently > added a section to my book too[...] what about using streams and an iterator? import streams proc pgmRead(strm: FileStream, filePos: int=0): auto= var data: char strm.setPosition(fileP

Seeking advices for a C programming book

2022-04-19 Thread Araq
> But where is Modula-3's opaque type then? Nim offers `system.RootRef` which allows for comparable solutions. YMMV.

Seeking advices for a C programming book

2022-04-19 Thread Araq
IIRC ++ and -- were taken from BCPL which predated the PDP 11, but it doesn't matter, C does add **much** syntax over an assembler. For example, usually store operations do not "return the value", but C's assignment does so that code like `while (((x = getch()) != 0)` is possible. That's not a p

Seeking advices for a C programming book

2022-04-19 Thread Sixte
> Most points I brought up equally affect LLVM too. ;-) Unfortunately. With a strange syntax... So do I have to define my own intermediate assembler or are there alternatives?

Seeking advices for a C programming book

2022-04-19 Thread Sixte
So, would LLVM be a better choice? C is basically a stack-based reimplementation of FORTRAN for the PDP 11. The "++" and "\--" were directly taken from the PDP 11 Assembler. The "register" keyword was important in a time where automatic register allocation was not available.

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-19 Thread demotomohiro
Just passing a nimcall procedure with an object type seems simpler and don't need to care about how to manage heap. But object types that contains seq/string/ref objects might not work. It might be not efficient if size of the object type is large and you frequently copy the function object. Co

Program level variables

2022-04-19 Thread shirleyquirk
If you mean a static member sure you can emulate that: type Foo* = object var fooBar = 9 proc bar*(t: typedesc[Foo]):int = fooBar echo Foo.bar Run with the global unexported and the getter exported, and ufcs

Seeking advices for a C programming book

2022-04-19 Thread Araq
> Could you please write an article addressing the weaknesses of C? It seems > that you have a lot of interesting things to say. Many things are well documented like the confusion of pointers with arrays, the syntax that could really do well with better scoping rules (Are "namespaces" really so

Optimize parsing large file line-by-line

2022-04-19 Thread Stefan_Salewski
> > npeg would fare in a scenario like this, I was curious too, so I tested it: . See third code block and table data.

Optimize parsing large file line-by-line

2022-04-19 Thread PMunch
Common "mistake" by people coming from Python. Tables/dictionaries are actually quite an expensive data structure to create, tuples are more or less free. So unless you need to add keys on runtime you should probably stick with a tuple (or just a normal object, depending on what you're doing wit

Program level variables

2022-04-19 Thread archnim
> you are referring to > Exactly. But as you said, it's not a current method in Nim.

Program level variables

2022-04-19 Thread Stefan_Salewski
You declare it at global scope, and attach the export marker, the asterisk * to it. But It will not be available automatically everywhere, you still have to import that symbol into all the modules that will use it.

Program level variables

2022-04-19 Thread archnim
By the way, I can bind a proc to a type, can I do the same thing with a var ? (an equivalent of static attributes in C++)

Program level variables

2022-04-19 Thread Stefan_Salewski
> I can bind a proc to a type, Sorry, I can not understand your question that well, maybe Mr. Munch can answer it, he is generally really good in understanding questions. I guess with "bind a proc to a type" you are referring to

Program level variables

2022-04-19 Thread archnim
I want it to share state in real time between several modules, some of which launch threads. Anyway Importing a module containing the globals works fine in my case. I just wanted to know if there is an easier way that I ignored. Thanks.

Program level variables

2022-04-19 Thread PMunch
You can always but an exported global in a module and just import that everywhere. Otherwise you have to use a define I think, or patch it into the system module.. Maybe more important is _why_ you want a program level global.

Compiler ignores my `if` a throws an error

2022-04-19 Thread PMunch
Just creating an overload for `*` is probably a bad idea. Actually checking the type on compile-time with `when` is definitely the better option in this case as the type is always known on compile-time.

async stdin/stdout errors (compiling nimlsp on Windows)

2022-04-19 Thread PMunch
Please report `nimlsp` errors on the GitHub issue tracker, posting them here is a great way for me to miss your problem (you got lucky this time). I think the error here is that the standard input on Windows isn't capable of async reads, and somehow the devel version of Nim detects this (althoug

Program level variables

2022-04-19 Thread archnim
OK. Thank you. I'm reading your book. What a pleasure ! Thank you very much for it.

Program level variables

2022-04-19 Thread archnim
Hello world. How can I create a variable (or constant) that is available across all the modules of a same program ? Is there an equivalent of Nodejs's `Global` object ?

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-19 Thread krakengore
Thanks! yeah i did exactly that and noticed the closure function pointer in C is written as `returnType (*)(Args... args, void* env)` with additional parameters prepended before the env pointer. Is there a way to attach a nim destructor to an imported cpp object that will both call the C++ dest

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-19 Thread Yardanico
You can check out answers for these questions yourself if you compile with something like `nim c -d:danger --nimcache:ccode file.nim` and then check the C files in the ccode folder. For example, for: proc main = var external: string proc my(x: int) = echo x