My Nim Development Weekly Report (3/12)

2023-03-12 Thread ringabout
## Progress ### chores [closes #16654; add a test case](https://github.com/nim-lang/Nim/pull/21478). [closes #20704; add a test case](https://github.com/nim-lang/Nim/pull/21480). [closes #6231; add a test case](https://github.com/nim-lang/Nim/pull/21485). [closes #8295; add a test case](https:

Why does Nim compiler allways depends on another's language compiler?

2023-03-12 Thread SerjEpatoff
Targeting LLVM is an easy and obvious way, but let's mind the disadvantages. 1. You start to depend on a LLVM project existence, plans, roadmaps, and ecosystem. Your resources, as a small independent grass–root publisher, are nothing compared to Apple ones. Sooner or later the effort of stayin

NimForUE

2023-03-12 Thread SerjEpatoff
Incredible project, thank you!

Announce: LimDB, a fast, persistent table with LMDB under the hood

2023-03-12 Thread SerjEpatoff
DB–on–top–of–mmap idea is up in the air for many decades. But unfortunately no serious DB engine writers are using it in production. Some of them tried, early MongoDB is one example, but obviously gave up. Let's try to reason about this status quo. 1. First of all, read this paper:

How to decouple code?

2023-03-12 Thread alexeypetrushin
Using `ref` for this case feels really wrong. In this specific case using value type and var looks like a much better approach. It clearly specifies intention and behaviour, that there's some mutable variable and that the argument going to be mutate. Version with ref, while works, doesn't conve

try-catch misbehavior

2023-03-12 Thread ElegantBeef
Nim has two dialects one where you can catch defects and one where you cannot. The one where you cannot is more 'correct' to the purpose of defects, they're supposed to be used in places where the logic is wrong. So if you rely on catching a defect you can easily create issues for people that us

How to decouple code?

2023-03-12 Thread SolitudeSF
`experimantal: strictFuncs` supposed to prevent that, but it doesnt detect mutation through a call.

How to decouple code?

2023-03-12 Thread ElegantBeef
Pointers are not mutable their content is. It's the same as `let a: new int; a[] = 300` it's valid. Strictfuncs in 2.0 will disallow writing to references regardless.

How to decouple code?

2023-03-12 Thread alexeypetrushin
Thanks, it solves the problem. I didn't knew you can modify `let ref` object without `var` :)

Cursor Location for user input.

2023-03-12 Thread ElegantBeef
Also could consider

How to decouple code?

2023-03-12 Thread ElegantBeef
`var T` is not capable of being captured cause it's possible to be stack allocated, use `TableRef` and remove `var`, this makes it heap allocated and capable of being captured.

How to decouple code?

2023-03-12 Thread alexeypetrushin
I have two files, the **generic Server** in the library, and the **App**. Server doesn't know the concrete type of the Session, it's only defined later in the App. How to write such code, the way I wrote it below doesn't work as for some reason I can't modify global var object in the closure. (

Cursor Location for user input.

2023-03-12 Thread Symb0lica
Use write(stdout,"Enter a file path > ") Run rather than echo "Enter a file path > " Run

Strange SIGSEGV / nil

2023-03-12 Thread ElegantBeef
`buildHttpHandler` returns nil.

Shared global var in ORC?

2023-03-12 Thread ElegantBeef
There is nothing preventing you from using a different API to multi thread with Nim, consider embedded. On multiple platforms they do not use the typical threading API. The program is compiled as if it's single threaded, but has access to multithreading.

Strange SIGSEGV / nil

2023-03-12 Thread alexeypetrushin
Can't understand what's causes SIGSEGV in this code? import std/[httpcore, asynchttpserver, asyncnet, tables, asyncdispatch] proc build_http_handler(): proc (req: Request): Future[void] {.async, gcsafe.} = proc http_handler(req: Request): Future[void] {.async, gcsafe.}

Shared global var in ORC?

2023-03-12 Thread alexeypetrushin
> The compiler knows the procedure accesses global GC'd memory which is not > technically gcsafe as it can create a race condition There could be no race condition in single thread mode. > since there are other methods of threading that one could use outside of the > Nim stdlib I don't underst

try-catch misbehavior

2023-03-12 Thread inv2004
I would like to up the topic again, because 1.6.12 forced the CatchableError. The main idea around it is clear, except `IndexDefect`, but it is unclear which strategic should I use? * Should I check all bound manually? * It makes code more verbose like Rust * It is unclear why I h

Shared global var in ORC?

2023-03-12 Thread ElegantBeef
I still do not know if it's wrong. The compiler knows the procedure accesses global GC'd memory which is not technically gcsafe as it can create a race condition. So it marks the procedure as unsafe. The compiler is not wrong here since you access a global variable that is GC'd, the question is

Shared global var in ORC?

2023-03-12 Thread alexeypetrushin
Aren't shared table support only non-ref keys and values? It says

Windows Screen Capture Help

2023-03-12 Thread Naterlarsen
Thank you for the information and the help. I appreciate it.

Cursor Location for user input.

2023-03-12 Thread Naterlarsen
I noticed when using user input, the cursor always shows below the request for the user to input information. Not sure I'm placing this so it should request on the same link as the user input - Example: import os while true: echo "Enter a file path > "

why use nim over c#?

2023-03-12 Thread mx1990
hi ppl thank you for your replies ive spent the last weekend going through the Nim Official Tutorial and doing some exercises on Exercism and doing some other stuff i really find that the language goals of efficiency, expressiveness and elegance have been well met and i want to work more with i

Make Nim docker images official?

2023-03-12 Thread jpalomaki
@jackhftang FWIW, I personally started using @moigagoo's image because it is mentioned in the Nim docs: . It is, however, labeled as "Community managed". @moigagoo This repository seems to contain the info on how to create and maintain official images:

Shared global var in ORC?

2023-03-12 Thread Zoom
Are there any reasons you don't use `std/sharedtables` and opt for manual locking?

Difference between generics and templates

2023-03-12 Thread Zoom
That is a great and I'd say manual-worthy explanation.

Version 1.6.12 released!

2023-03-12 Thread noah
`choosenim stable` worked for me

Shared global var in ORC?

2023-03-12 Thread alexeypetrushin
No, the reason that we need to mark `gcsafe` in this case seems to be different one. Compiler can infer `gcsafe`. I think the problem here is that it wrongly analyses that this proc is not gcsafe and then stops and wont apply that infer. Wrongly, because it's single thread mode, and so it's saf

Make Nim docker images official?

2023-03-12 Thread moigagoo
I'm all for passing the repo to nim-lang organization. Another important thing that's missing now is CI integration.

Shared global var in ORC?

2023-03-12 Thread jackhftang
> why compiler needs to explicitly mark that proc as gcsafe? Can't compiler > infer that automatically? Because `serve` explicitly [marked to require gcsafe](https://github.com/nim-lang/Nim/blob/v1.6.12/lib/pure/asynchttpserver.nim#L405) it is like compiler won't automatically cast int32 to int

Make Nim docker images official?

2023-03-12 Thread jackhftang
One more thing, could @moigagoo transfer the repo to [nim-lang organization](https://github.com/nim-lang) if this repo is really official.

Difference between generics and templates

2023-03-12 Thread shirleyquirk
var a = (proc(s: string))(doThing) Run Always wanted to know how to do this, thanks @eb

Windows Screen Capture Help

2023-03-12 Thread Lantos
Hey Naterlarsen, looks like you are new to the forums so Welcome! Just for future posts you can use code blocks to format your code so that it is easier for people to read your code to help you out. You can use three back ticks and then the short name of the language to do so like ```nim your