Shared global var in ORC?

2023-03-11 Thread jasonfi
If you're going to access the same global var from different threads you should use a lock to prevent race conditions.

Difference between generics and templates

2023-03-11 Thread ElegantBeef
They're both a variation of metaprogramming, but their semantics are slightly different. A template is code substitution that substitutes at every invocation whereas a generic only generates a procedure once on it's first invocation. proc doThing(a: auto) = mixin otherThing

Difference between generics and templates

2023-03-11 Thread WizardUli
May I ask what are the differences in generics vs templates except for slightly different syntax? I've tried to understand it from the Manual but to me it seems that they have the same use-case. I've tried searching for some discussion about this but couldn't find anything, perhaps it's clear to

Windows Screen Capture Help

2023-03-11 Thread Naterlarsen
I am trying to create a simple application that captures the desktop screen, however, not able to find much information about how to do this. I have been looking for some time and have had no luck. Please help. Please see the code below. import winim let window = FindWindow("Window Title", nil

Make Nim docker images official?

2023-03-11 Thread jpalomaki
Hello, @moigagoo @Araq I very recently started using the [Nim docker image](https://github.com/moigagoo/nimage) in a small AWS + Nim [experiment](https://github.com/jpalomaki/nim-app/blob/main/Dockerfile) (also just started learning Nim), and the image seems to work great. How much work would

iterators composition

2023-03-11 Thread mantielero
Thanks for the ideas

The Algorithms In Nim

2023-03-11 Thread dlesnoff
I am still working on the contributing.md. In any case, I think it does not prevent to PR before me. On other stuff preferably.

The Algorithms In Nim

2023-03-11 Thread pietroppeter
Great news @dlesnoff! I think this is a great way to showcase Nim and it could be a good opportunity for beginners to start practicing Nim. As far as organization goes I say you already have work done here: and I guess you will be transferring tha

The Algorithms In Nim

2023-03-11 Thread dlesnoff
Hello, Presentation of the project I have asked the creation of a new repository to the organizers of [The Algorithms](https://the-algorithms.com/). This is an educational project that aims to collect implementations of mainstream algorithms and data structures. [AnupKumarPanwar](https:/

Shared global var in ORC?

2023-03-11 Thread zevv
Yeah, that's an oldie, I ran in exactly the same issue in 2018:

Shared global var in ORC?

2023-03-11 Thread alexeypetrushin
Finally solved, I had to disable the `--threads:on` switch and mark procs with `gcsafe` and it works with `--mm:orc` and without. It's single threaded but I for my needs it's enough. Just wonder why compiler that proc is GC safe, and requires explicit proc annotation with `.gcsafe.`. The worki

Template in template: should this work?

2023-03-11 Thread moigagoo
Sigh... Unfortunately, Araq's ugly hack won't let be pass multiple VNodes into the proc. You always need to wrap the content in an additional div or something.

Shared global var in ORC?

2023-03-11 Thread alexeypetrushin
I just noticed in the [Introducing ORC blog post](https://nim-lang.org/blog/2020/12/08/introducing-orc.html) that while example has sessions, it it doesn't use it. How these sessions are meant to be used in the response? The code from example copied below import asynchttpserver, as

Shared global var in ORC?

2023-03-11 Thread jasonfi
When I had forgotten a global var in my code, with ORC, I had weird problems that didn't show an error that related to the global var. When I removed it the problems went away. So, I'd say, don't do it. It's safer to send data over channels, and it's quite quick. So you could put your table in

Shared global var in ORC?

2023-03-11 Thread alexeypetrushin
I actually don't need nether multi-threading nor async. If it would be possible to do that with just one thread without async, it would be ok for my purposes (it will be slow, but it's ok for me).

Difference {.importcpp.} vs {.importjs.}

2023-03-11 Thread rel
Yes, that is I wanted to try: newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.} Run in `dom.nim` compiles to JS: event_1124073573 = new Event(eventType_1124073566); Run and newEvent*(name: cstring): Event {.im

Shared global var in ORC?

2023-03-11 Thread alexeypetrushin
As far as I know ORC made it possible to share global variables. I'm creating networking service, which maintains stateful Session object in memory. Is that possible to do with ORC? I'm using `-mm:orc` switch, but it still complains that procs not `gcsafe`. import std/[httpcore, as

Template in template: should this work?

2023-03-11 Thread moigagoo
It's very useful, thanks! I think I'll go with the do notation.

Template in template: should this work?

2023-03-11 Thread moigagoo
> Well for one the signature of bar in your example is (string, untyped) and > you are only giving the untyped parameter. That's a typo, sorry. > But beyond that this really depends on the DSL at hand. Thanks for the detailed response!

Can Nim do Type States?

2023-03-11 Thread Araq
> The DO-178 standard was mainly defined for the C language and I don't think > it is strictly applicable for other languages ​​like Nim. That's true but the bureaucrats will likely simply "adapt" the rules from C to anything else as it's easier than thinking things through.

Can Nim do Type States?

2023-03-11 Thread elcritch
> DO-178 governs how software is written for safety-critical avionics systems > and it really puts the guardrails on how one writes code. Metaprogramming is > considered a code-translation. It is allowable in certain circumstances, but > requires extra scrutiny. We like to avoid extra scrutiny w