sink parameters not being copied even when there are later reads (refc)

2024-02-23 Thread gabbhack
I think the reason is that `sink` with refc doesnt do anything, because ownership semantics only work with A/ORC. `AnObject` in first example not copied because big enough object automatically passed by reference (optimization by compiler)

Does seq have a method to get mutable ref element?

2023-09-09 Thread gabbhack
`[]` method already returns `var T`. By default, you cant pass it to vars, but can to procedures. proc myInc(mut: var int) = mut += 1 var test = @[1, 2, 3] test[1].myInc Run If you want to save ref to variable you can use "views" {.exper

Is there a way to see the NIM version in an NIM executable (binary) ?

2023-05-09 Thread gabbhack
Use magic `NimVersion` constant. echo(NimVersion) Run

string fmt doesn't work inside of template?

2023-05-04 Thread gabbhack
I think this is because after instantiating the `button` template, you have `echo fmt"{size}"` line. Use procedure instead or declare the size variable explicitly

asyncCheck break my function

2023-04-06 Thread gabbhack
`asyncCheck` does not wait for future completion, so your `asyncfunction` completes immediately. If you need to wait for more than one futures execution, use [all](https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D). import asyncdispatch proc run(

Templates - how to check if a template has been used

2021-03-02 Thread gabbhack
https://github.com/nim-lang/Nim/wiki/Tips-and-tricks#template-scopes

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread gabbhack
I think that in your case, the compiler considers `[8, int8]` as a array constructor.

Problem with template and async

2020-08-28 Thread gabbhack
Same error

Defer doesnt work with block, break and await

2020-08-28 Thread gabbhack
Works: (block, break, sync) Works: (block, break, asyncCheck) Works: (block, await) Nope: (block, break, await) import asyncdispatch

Problem with template and async

2020-08-27 Thread gabbhack
Thank you, I think I can work with this. > I think it's because async proc is transformed into iterator so you can't > return immediately If this is the reason, then this code shouldn't work, but it does import asyncdispatch proc main(): Future[bool] {.async.} = retu

Problem with template and async

2020-08-27 Thread gabbhack
I don't understand why this example don't work. Is the body of the template should not simply be inlined at compile time?

play.nim-lang.org has been down for several hours

2020-08-12 Thread gabbhack
:(

HTTPS requests in Nim

2020-08-12 Thread gabbhack
Check Other dependencies on [https://nim-lang.org/install_windows.html](https://nim-lang.org/install_windows.html) or install nim via choosenim

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

2020-08-10 Thread gabbhack
Yes proc inside(x: int, y: openArray[int]): bool = x in y echo 1.inside([1,2,3,4,5]) Run No import sets proc inside(x: int, y: openArray[int] | HashSet[int]): bool = x in y echo 1.inside([1,2,3,4,5])