Hello `nph`, an opinionated source code formatter for Nim

2023-12-15 Thread giaco
this is good, very good. Thanks!

What is the difference between std/atomics and threading/atomics, which one is recommended?

2023-12-15 Thread Araq
I use `std / atomics` but I don't know either. :-)

What is the difference between std/atomics and threading/atomics, which one is recommended?

2023-12-15 Thread aiac
as title

How to force inline?

2023-12-15 Thread gcao
Thanks for the input. My fibonacci implementation is not Nim proc. It's in my pet language and interpreted by a Nim VM. Inline won't be a problem I think. I am using recursive Fibonacci to benchmark my code. However, I don't know which other language I can compare with. Even Ruby implementation

Why is `enumerate()` a macro?

2023-12-15 Thread choltreppe
`enumerate` always just counts the iterations starting from 0. `pairs` goes through the indecies of the array (which can be any ordinal or subrange of one). or for tables it goes through the keys.

Why is `enumerate()` a macro?

2023-12-15 Thread awr1
what even is the difference in functionality between `enumerate` and the `pairs` iterator?

Why is `enumerate()` a macro?

2023-12-15 Thread Araq
> Iterators are easier to implement and more composable (e.g. could be passed > to templates). The macro has already been implemented and guarantees no overhead.

Why is `enumerate()` a macro?

2023-12-15 Thread Calonger
Iterator is only composible in iterator () : T form . Using means runtime closure , expensive .

How to force inline?

2023-12-15 Thread cblake
@gcao \- because your file name seems to be "fibonacci.nim", it bears mention that some versions of some compilers and some versions of Nim have an ability to inline several recursion levels of f(n)=f(n-1)+f(n-2) BUT they are very finicky about the shape of code to trigger this code optimization

Why is `enumerate()` a macro?

2023-12-15 Thread goldsteinq
Hi! I’ve noticed that `enumerate()` is a macro that transforms a `for` loop. It seems like it would be easy to make it an `iterator` instead. Iterators are easier to implement and more composable (e.g. could be passed to templates). [PR that originally added them](https://github.com/nim-lang/Nim

How to force inline?

2023-12-15 Thread treeform
template `==`*(a, b: Key): bool = cast[int64](a) == cast[int64](b) Run Nim's operators are just function calls and they resolve just like everything else by types. Nim templates always force things inline, unlike the C compiler which can decide to inline or not even aft

How to force inline?

2023-12-15 Thread gcao
Thanks. So the table is able to find the right template as long as the signature matches?

How to force inline?

2023-12-15 Thread Yardanico
There's a Nim-native way of inlining code - templates, although they can be a bit different in specific cases, but I think in your cases you can just swap `proc` to a `template` and get the expected functionality.

How to force inline?

2023-12-15 Thread gcao
hi. I'm trying to force inline with codegenDec but couldn't get it to work. I have below code. `Key` is used as Table key. proc `==`*(a, b: Key): bool {.codegenDecl: "__attribute__((always_inline)) $# $#$#".} = cast[int64](a) == cast[int64](b) Run When I compil

SIGSEGV: Illegal storage access. (Attempt to read from nil?) in coroutines

2023-12-15 Thread aiac
* code: import std/[strformat] import std/[os] import std/[times,monotimes] import std/[coro] var fibers: seq[CoroutineRef] = @[] proc doSleep() = sleep 3000 let st = getMonoTime() for i in 0..<10:

Capture atomics in closure

2023-12-15 Thread JiyaHana
Due to the thread procedure trying to access the shared variable res directly. In Nim thread procedures can't capture variables by closure as it may lead to unsafe memory access. However, since res is of type Atomic[int], which is safe for concurrent access, you can work around this by-passing r

Wishlist: Ideal UI library for Nim

2023-12-15 Thread Araq
> No, I don't think is the candidate > since we have to supply HTML file in Questionable reasoning and questionable choices of technology.

Smart Hemp Gummies Australia Reviews Is Scam Or Trusted?

2023-12-15 Thread erikgavis
Smart Hemp Gummies Australia:- The presence of a potent listen known as cannabinoids permits the endocannabinoid device to serve as a sink and works to improve its function. Smart Hemp Gummies Australia will now not most effective help you relax from your psychological problems, however will als

Wishlist: Ideal UI library for Nim

2023-12-15 Thread oyster
rencently, I am studying and have finished 2 projects quickly. Sorry, is based on vue/quasar for python language, and it can be bundled as a native application or runs as web server. Now I do expect that there is something like in