00:00:01 | * | marcus quit (Remote host closed the connection) |
00:00:44 | * | marcus joined #nim |
00:01:16 | FromDiscord | <Elegantbeef> Not really without reaching to macros |
00:01:50 | FromDiscord | <Elegantbeef> https://github.com/beef331/micros/blob/master/src/micros/introspection.nim#L3-L7 if you so wish to do that |
00:03:12 | FromDiscord | <arkanoid> 90% of your answers are links to a lib you have already done. How do you do that |
00:03:21 | FromDiscord | <Elegantbeef> I am everything |
00:04:16 | FromDiscord | <luteva> In reply to @takemichihanagaki3129 "Is there a way": I mean nimsuggest is just a programm you can start if you want to. If you don't want it, just don't start it. |
00:06:13 | FromDiscord | <luteva> In reply to @takemichihanagaki3129 "Is there a way": what are you trying to do? where does there problem occur? |
00:07:31 | FromDiscord | <luteva> oh, maybe you are talking about some IDE configuration? |
00:08:36 | FromDiscord | <takemichihanagaki3129> In reply to @luteva "just do not start": This simply starts by the vs code extension. ↵But, btw, I just removed the binary. |
00:08:43 | FromDiscord | <takemichihanagaki3129> In reply to @takemichihanagaki3129 "This simply starts by": This solved my problem. |
00:11:06 | FromDiscord | <takemichihanagaki3129> sent a long message, see https://pasty.ee/VuUzZHqR |
00:11:19 | FromDiscord | <luteva> you can configure your IDE to start some programms to do some "magic". the "clean" solution would be to fiy the configuration. but if the ide can't find the programm anymore, this may work, too. 🙂 |
00:11:41 | FromDiscord | <takemichihanagaki3129> In reply to @takemichihanagaki3129 "I didn't wanted. But": But this time vscode just spawned +10 instances at once, so I prefered to remove it completely. |
00:12:45 | FromDiscord | <takemichihanagaki3129> In reply to @luteva "oh, maybe you are": IDE settings would be the ideal to me. |
00:13:26 | FromDiscord | <luteva> i think there are more nim extensions in vscode. maybe a different one may work better for you, |
00:13:31 | FromDiscord | <takemichihanagaki3129> First time nimsuggest worked to me was using Helix, on a single file project.↵Again, running with 4gb and Windows consumes 3/4 of everything... |
00:13:43 | FromDiscord | <takemichihanagaki3129> In reply to @luteva "i think there are": I'll have a look. |
00:14:03 | FromDiscord | <luteva> (nit sure though) |
00:38:04 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @takemichihanagaki3129 "Mine is breaking my": I'm glad that I'm not alone to have this issue |
00:38:23 | FromDiscord | <System64 ~ Flandre Scarlet> It already crashed my computer |
00:44:21 | FromDiscord | <takemichihanagaki3129> In reply to @sys64 "It already crashed my": My computer got locked by 6min due to it... |
00:47:05 | FromDiscord | <takemichihanagaki3129> In reply to @sys64 "It already crashed my": My older one was able to run nimsuggest at some point.↵Not the fasted way, but worked.↵6Gb on win10.↵Now, I need to buy a new one, less GB and Win11... |
00:48:50 | * | GnuYawk67 quit (Quit: The Lounge - https://thelounge.chat) |
00:49:15 | * | GnuYawk67 joined #nim |
00:56:16 | FromDiscord | <lainlaylie> i dont want to sound like a broken record here but is this not https://github.com/nim-lang/choosenim/issues/13 |
01:35:43 | FromDiscord | <Laylie> matrix bridge missed a whole hour of messages? |
01:36:55 | FromDiscord | <Elegantbeef> It tends to drop messages like a hot potato |
01:44:03 | * | alexdaguy joined #nim |
01:44:25 | FromDiscord | <arkanoid> why the two templates are different here? the first compiles, the second doesn't, but they should be the same https://play.nim-lang.org/#pasty=lCPeMABR |
01:55:07 | * | alexdaguy quit (Quit: restart) |
01:55:25 | * | alexdaguy joined #nim |
02:10:46 | * | arkanoid joined #nim |
02:13:18 | FromDiscord | <Elegantbeef> `ref Exception` vs `ref CatchableError` |
02:13:32 | FromDiscord | <Elegantbeef> Nim inherit types are no covariant so inside generic parameters a child does not match for the parent |
02:14:16 | FromDiscord | <arkanoid> gotcha |
02:15:23 | FromDiscord | <arkanoid> interesting point. Next would be why std/logging raises Exception instead of anything under CatchableError |
02:20:26 | FromDiscord | <Elegantbeef> Inheritance be damned 😄 |
02:21:05 | FromDiscord | <Elegantbeef> Joke aside I think it's just cause a procedure it calls could not be effect analyzed |
03:14:46 | FromDiscord | <arkanoid> how would you keep a bunch of non constant configs (numbers, strings) readable by X-1 threads and writable by 1?↵There is no atomicity required here, I don't care about the order of write and reads. At the moment I'm using a stack allocated object where strings are StackString(s) and it works, but I quite find the approach less flexible than what it could be. Any hint? |
03:16:50 | FromDiscord | <Elegantbeef> What's your issue with the flexibillity? |
03:19:13 | FromDiscord | <arkanoid> for example one of those settings is an Uri, and other are Path(s). Saving all string as StackString(s) forces continuous conversion between higher level abstractions within each thread, when I really need to parse it them once every change |
03:20:25 | FromDiscord | <arkanoid> I could generate a ParsedConfig object that is the validated and converted mirror of the one limited by StackString, and run each every now and then from each thread, but it feels like polling from within the same process |
03:23:34 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=wwOFfwvM |
03:23:34 | FromDiscord | <Elegantbeef> 😄 |
03:24:23 | FromDiscord | <Elegantbeef> Whoops `{.guard:lock.}` |
03:27:16 | FromDiscord | <arkanoid> Hm, I tried something similar days ago, but I failed fight with the compiler that wanted me to not call global GCed objects from within thread code |
03:28:25 | FromDiscord | <Elegantbeef> So wrap it with some `{.cast(gcsafe).}` 😄 |
03:29:02 | FromDiscord | <arkanoid> that's too much violence for me |
03:29:40 | FromDiscord | <Elegantbeef> Eh throw it inside guarded |
03:29:46 | FromDiscord | <Elegantbeef> Then it's no problemo |
03:34:07 | FromDiscord | <arkanoid> black wizard telling kids to play with weapons |
03:34:32 | FromDiscord | <arkanoid> but ok, I like locks |
03:34:42 | FromDiscord | <Elegantbeef> Well then you'll like guarded |
03:34:53 | FromDiscord | <Elegantbeef> Instead of `path: string` you do `path: Guarded[string]` |
03:37:22 | FromDiscord | <arkanoid> what is the pragma for? why aren't get and set sufficient for locking? |
03:37:41 | FromDiscord | <Elegantbeef> the program enforces you to always `{.lock:[guarded.lock].}: ....` |
03:37:53 | FromDiscord | <Elegantbeef> pragma\ |
03:38:10 | FromDiscord | <Elegantbeef> So a smart alec cannot do `guarded.data` without the lock annotation |
03:43:33 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=gNPmkCxU |
03:52:14 | FromDiscord | <mjsdev> Nevermind, I may have found a solution using getImp on the symbol |
03:52:24 | FromDiscord | <arkanoid> it's a double guard against users peeping into private data. Cool |
04:12:04 | * | ensyde joined #nim |
04:15:44 | FromDiscord | <arkanoid> `Error: 'configurationJob' is not GC-safe as it calls 'innerProc'`, where `configurationJob` is a `{.thread.}`, and `innerProc` is a proc defined into `configurationJob` function body. How can it be no t GC-safe?! it's part of the thread body! |
04:16:08 | FromDiscord | <Elegantbeef> It's probably turned into a closure |
04:16:31 | FromDiscord | <arkanoid> do I need explicit nimcall then? |
04:16:55 | FromDiscord | <Elegantbeef> Try it and see what it complains about |
04:17:03 | FromDiscord | <Elegantbeef> I'm guessing "Cannot capture X in nimcall" |
04:17:39 | FromDiscord | <arkanoid> again ` Error: 'configurationJob' is not GC-safe as it calls 'inner'` where `inner` is `proc inner(): Result[void, string] {.nimcall.} =` |
04:18:26 | FromDiscord | <Elegantbeef> Does inner access any global memory? |
04:20:47 | FromDiscord | <arkanoid> it should not. I need to cleanup other errors probably, gimme a minute |
04:36:08 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=fCfmucKn |
04:39:33 | FromDiscord | <Elegantbeef> Where is it not gcsafe? |
04:43:11 | FromDiscord | <arkanoid> `Result[Ssh2Lib, string]` allocates a string |
04:43:23 | FromDiscord | <arkanoid> I've converted error type into enum |
04:48:30 | FromDiscord | <arkanoid> or better, avoiding checking initialization from thread and just assume it |
05:14:59 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=MFEFBolT |
05:19:53 | FromDiscord | <Elegantbeef> It makes a procedure inside of `sortedbyit` with `{.raises: [].}` |
05:21:32 | FromDiscord | <arkanoid> thanks again |
05:31:27 | FromDiscord | <arkanoid> argh, why cmd proc needs to be a closure! this won't work inside threads https://github.com/nim-lang/Nim/blob/6bf9265d24c6243cd5cf9e10f7fe766fa5372396/lib/pure/algorithm.nim#L368 |
05:31:57 | FromDiscord | <Elegantbeef> Closures work on threads |
05:32:03 | FromDiscord | <Elegantbeef> Just don't send them across |
05:45:38 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=eVGqVsGl |
05:47:06 | FromDiscord | <Elegantbeef> `int` vs `BiggestInt` |
05:47:14 | FromDiscord | <arkanoid> here it is |
05:47:22 | FromDiscord | <arkanoid> thanks |
06:08:11 | * | xet7 joined #nim |
06:35:08 | * | SchweinDeBurg quit (Quit: WeeChat 4.6.0-dev) |
06:35:36 | * | SchweinDeBurg joined #nim |
08:03:58 | * | coldfeet joined #nim |
08:04:35 | * | ntat joined #nim |
09:05:27 | * | ensyde quit (Quit: WeeChat 4.5.1) |
09:34:16 | FromDiscord | <luteva> In reply to @takemichihanagaki3129 "My older one was": sorry, but I can't help with windows systems. But I am sure there are many other guys here, using windwos. |
09:39:22 | * | beholders_eye joined #nim |
09:42:11 | * | xet7 quit (Quit: Leaving) |
10:49:33 | * | coldfeet quit (Quit: Lost terminal) |
11:13:37 | * | beholders_eye quit (Ping timeout: 252 seconds) |
13:28:18 | * | rockcavera joined #nim |
13:56:50 | * | alexdaguy quit (Quit: WeeChat 4.5.1) |
14:07:43 | * | ntat quit (Quit: Leaving) |
14:14:22 | FromDiscord | <firasuke> Why are these not synced?↵- https://github.com/nim-lang/nightlies/releases/tag/latest-devel↵- https://github.com/nim-lang/nightlies/releases/tag/2025-02-01-devel-0861dabfa70f40f00c5c95d58c344ad5e0fd19ec |
15:03:09 | * | arkanoid quit (Ping timeout: 244 seconds) |
16:46:40 | FromDiscord | <nocturn9x> hello there |
16:47:11 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=LCrrXtSC |
16:50:54 | FromDiscord | <nocturn9x> ah, seems like I'm missing the mingw libraries |
16:56:46 | FromDiscord | <nocturn9x> it seems like Nim is passing `-ldl` to the linker script |
16:56:52 | FromDiscord | <nocturn9x> but that doesn't work for windows cross compilation |
16:56:56 | FromDiscord | <nocturn9x> how do I tell it to like, not do that? |
17:00:03 | * | arkanoid joined #nim |
17:00:41 | strogon14 | when defined(windows): |
17:02:00 | FromDiscord | <nocturn9x> ah I need `--os:windows` at the top of nim.cfg? |
17:02:22 | FromDiscord | <Robyn [She/Her]> In reply to @strogon14 "when defined(windows):": Isn't it `@defined windows` for the cfgm |
17:02:42 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=jPzhCLie |
17:02:47 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "ah I need `--os:windows`": don't see why that'd be an issue |
17:02:48 | FromDiscord | <nocturn9x> I am not adding `-ldl` explicitly |
17:02:52 | FromDiscord | <nocturn9x> nim is doing it on its own |
17:02:53 | FromDiscord | <nocturn9x> lol |
17:03:15 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "I am not adding": can you check in the Nim config dir? |
17:03:29 | FromDiscord | <Robyn [She/Her]> Like, the Nim compiler dir |
17:03:34 | FromDiscord | <nocturn9x> uh |
17:03:38 | FromDiscord | <nocturn9x> where would I check lol |
17:03:48 | FromDiscord | <nocturn9x> there's nothing nim-related in `~/.config` except Inim stuff |
17:04:34 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "there's nothing nim-related in": It's the same dir as your Nim compiler dir, so if you used choosenim, check .choosenim |
17:05:33 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=jpgylaIk |
17:05:34 | FromDiscord | <nocturn9x> haha |
17:05:35 | FromDiscord | <nocturn9x> found it |
17:05:42 | FromDiscord | <spotlightkid> Are you using the `dynlib` pragma or any library that does? |
17:05:49 | FromDiscord | <nocturn9x> do I just `--clang.options.linker = ""` |
17:05:52 | FromDiscord | <nocturn9x> In reply to @spotlightkid "Are you using the": nop |
17:06:34 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "this is my nim.cfg:": No clue why this is a problem, fairly recent post did this fine, but I do notice Nim 1.3.0 is defined? |
17:06:51 | FromDiscord | <nocturn9x> nono |
17:06:57 | FromDiscord | <nocturn9x> those version numbers are from my own engine |
17:07:03 | FromDiscord | <nocturn9x> it's a program specific version number |
17:07:06 | FromDiscord | <nocturn9x> nim version is 2.2.0 |
17:07:09 | FromDiscord | <Robyn [She/Her]> aaah sorry |
17:07:10 | FromDiscord | <nocturn9x> anyway I figured it out |
17:07:15 | FromDiscord | <nocturn9x> In reply to @nocturn9x "do I just `--clang.options.linker": this fixes it |
17:07:20 | FromDiscord | <Robyn [She/Her]> Then yeah not too sure |
17:07:25 | FromDiscord | <nocturn9x> it builds the exe |
17:07:26 | FromDiscord | <nocturn9x> so all good |
17:07:30 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "do I just `--clang.options.linker": oh i didn't see that sorry |
17:08:43 | FromDiscord | <spotlightkid> Anyway, I would always put compiler options in a project specific config file, e.g. a `config.nims` in your `src` directory. |
17:10:20 | FromDiscord | <nocturn9x> I have nim.cfg |
17:10:24 | FromDiscord | <nocturn9x> thought that was enough no? |
17:10:30 | FromDiscord | <nocturn9x> (edit) "enough no?" => "enough, is it not?" |
17:10:37 | FromDiscord | <nocturn9x> in my project's dir I mean |
17:12:20 | FromDiscord | <ninovanhooff> sent a code paste, see https://play.nim-lang.org/#pasty=VkUgrscj |
17:14:30 | FromDiscord | <Robyn [She/Her]> In reply to @ninovanhooff "Could I get a": I don't think there's really any performance issues here but you might need some validation and you'd want `SomeSignedInt` to prevent overflow imo |
17:19:25 | FromDiscord | <spotlightkid> Yeah, basically the same. `config.nims` makes it obvious, that you can use nimscript (and I'm not sure whether you need to use `nimble` for it to be used).↵(@nocturn9x) |
17:19:39 | * | ntat joined #nim |
17:19:40 | FromDiscord | <nocturn9x> gotcha :) |
18:26:21 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=PNOZfNrn |
18:40:27 | * | rockcavera quit (Remote host closed the connection) |
18:51:39 | * | ntat quit (Quit: Leaving) |
19:22:28 | * | coldfeet joined #nim |
19:42:25 | FromDiscord | <thepotatochronicler> Is there a way to evaluate a NimNode in a macro into a concrete value? |
19:42:43 | FromDiscord | <thepotatochronicler> And no, I don't mean `static[T]` as a param |
19:49:31 | FromDiscord | <nasuray> In reply to @spotlightkid "Yeah, basically the same.": You do not need nimble for config.nims support. Nimble uses nimscript but nimscript is builtin with the compiler. You can even make one at ~/.config/nim/config.nims and write tasks that can be invoked by the compiler as subcommands no different than a nimble task |
20:02:42 | FromDiscord | <spotlightkid> Nice! Thanks for the confirmation. |
20:30:04 | * | coldfeet quit (Quit: Lost terminal) |
20:34:06 | FromDiscord | <Elegantbeef> @thepotatochronicler Nope you cannot raise a NimNode to a true type as macros are compiled once |
20:34:19 | FromDiscord | <Elegantbeef> Like consider `var a = fromNimNode(if someCond: "test" else: 10)` |
20:54:03 | * | Guest70 joined #nim |
20:58:02 | FromDiscord | <oranwutan_78823> Hi! I'm trying to make a GUI with owlkettler, I need a ColumnView to be populated with data from an array (lets say a 5 x 5 array with random 0s and 1s), have anybody experience or know how to do it. I have read all the docs and made several (unsuccesful atempts). |
20:58:21 | FromDiscord | <oranwutan_78823> (edit) "it." => "it?" |
20:59:56 | FromDiscord | <Elegantbeef> Did you refer to https://github.com/can-lehmann/owlkettle/blob/c0c4e55f166dd74f32af0d4fef8c9b7d2f0de2e3/examples/widgets/column_view.nim ? |
21:00:30 | FromDiscord | <oranwutan_78823> Yes, they do: |
21:00:31 | FromDiscord | <oranwutan_78823> proc viewItem(row, column: int): Widget =↵ result = gui:↵ Label:↵ text = $row & ", " & $column |
21:01:16 | FromDiscord | <oranwutan_78823> But that $row and $ column just refer to the value of the index. I need to get access to the index to set the values from the aforementioned array |
21:03:13 | FromDiscord | <oranwutan_78823> thet renderse something like:↵0, 0 1,0 2,0 3,0 |
21:03:32 | FromDiscord | <oranwutan_78823> 0,1 1,1 1,2 1,3 |
21:03:35 | FromDiscord | <oranwutan_78823> and so on.. |
21:05:44 | FromDiscord | <Elegantbeef> you have the row and column though |
21:05:53 | FromDiscord | <Elegantbeef> `myArray[x + y width]` |
21:10:23 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=cQBwpfTl |
21:14:53 | FromDiscord | <oranwutan_78823> Ok! Let me take a look, thanks!!! |
21:19:33 | * | ensyde joined #nim |
21:47:05 | FromDiscord | <arkanoid> I'm experimenting writing code using same error handling pattern as Status code. I like it! It makes exception disappear and brings many benefits the the modules |
21:47:24 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @nocturn9x "this is my nim.cfg:": Wait↵We can enable SIMD?! |
21:47:40 | FromDiscord | <nocturn9x> that switch just enabled my own manual SIMD |
21:47:48 | FromDiscord | <System64 ~ Flandre Scarlet> Oh, sorry |
21:48:01 | FromDiscord | <nocturn9x> I have my engine's evaluation inference implemented using AVX2 intrinsics |
21:48:12 | FromDiscord | <nocturn9x> which are a significant speedup over the autovectorized stuff |
21:48:37 | FromDiscord | <System64 ~ Flandre Scarlet> No idea if I can take full advantage of AVX2 in my synth |
21:48:52 | FromDiscord | <nocturn9x> generally if you're doing a lot of integer ops on sequential data |
21:48:57 | FromDiscord | <nocturn9x> you probably can |
21:49:13 | FromDiscord | <System64 ~ Flandre Scarlet> my modular synth uses recursion |
21:49:34 | FromDiscord | <System64 ~ Flandre Scarlet> a module calls synthesize() in a deeper module and so on |
21:57:20 | FromDiscord | <aintea> Isn't there any way to break a line of code in nim ? |
21:58:37 | FromDiscord | <aintea> sent a code paste, see https://play.nim-lang.org/#pasty=wuYUyMFi |
21:58:53 | FromDiscord | <mjsdev> I think you need to leave the and on the line before |
21:58:59 | FromDiscord | <mjsdev> not as nice |
21:59:03 | FromDiscord | <mjsdev> but you could also use parens? |
21:59:13 | FromDiscord | <mjsdev> I think? |
21:59:59 | FromDiscord | <aintea> Parenthesis work, but I want to apply this to operators |
22:00:19 | FromDiscord | <aintea> sent a code paste, see https://play.nim-lang.org/#pasty=zlTBMjnv |
22:00:27 | FromDiscord | <aintea> and yes I have the dot operator |
22:00:38 | FromDiscord | <aintea> but I prefer this one |
22:09:25 | FromDiscord | <oranwutan_78823> In reply to @Elegantbeef "`myArray[x + y *": It is a nice example, not exactly what I need, I said an "array" but maybe it is a bad example. The big picture is that I need to render de content of a csv or excel file within the column viewer. So I need something like table[i, j] to be rendered. |
22:09:47 | FromDiscord | <oranwutan_78823> HOnestly, the API to columnviewer is hard to understand for me. |
22:12:29 | * | beholders_eye joined #nim |
22:34:03 | FromDiscord | <arkanoid> Elegantbeef\: hi! your `Guarded` module suggestion you sent me yesterday makes no calls to `initLock` and `deinitLock`. Is this a deliberate action or is it required to do so? |
22:38:35 | FromDiscord | <Elegantbeef> You should have a constructor which inits it and a destructor that deinits it |
22:42:48 | FromDiscord | <Elegantbeef> Here's the rest of the owl arkanoid https://play.nim-lang.org/#pasty=JUEYkvOF |
22:42:59 | FromDiscord | <Elegantbeef> Whoops |
22:43:40 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=uaOwvpbD here's the full owl |
22:43:56 | FromDiscord | <Elegantbeef> We disable copies so we ensure there is only one instance of these made and you do not accidentally copy them |
22:44:30 | FromDiscord | <arkanoid> maybe you need also var for set? |
22:44:30 | FromDiscord | <Elegantbeef> We have a destructor so the lock is automatically deinited, and we have a constructor so you don't even need to pretend the lock exists 😄 |
22:44:42 | FromDiscord | <Elegantbeef> Ah yes good catch |
22:45:00 | FromDiscord | <Elegantbeef> Also probably need var for get aswell since it acquires the lock |
22:47:15 | FromDiscord | <arkanoid> thanks for the owl |
22:50:41 | FromDiscord | <arkanoid> it doesn't like the that the destructor touches data without proper protection `guarded.nim(11, 21) Error: unguarded access: guarded.data` |
22:51:29 | FromDiscord | <arkanoid> Id say first destroy data with lock, then deinit lock |
22:51:56 | FromDiscord | <Elegantbeef> Right |
22:53:04 | FromDiscord | <arkanoid> mh, but acquire requires var, so this makes =destroy require var |
22:53:34 | FromDiscord | <arkanoid> but `Warning: A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter` |
22:54:41 | FromDiscord | <arkanoid> also `nim-2.2.0/lib/std/private/syslocks.nim(175, 7) Error: cannot 'importc' variable at compile time; initSysLockAux` |
22:55:26 | FromDiscord | <Elegantbeef> Are you doing `const bleh = guard(...)`? |
22:56:04 | FromDiscord | <arkanoid> no, the error is given when compiling `guarded.nim` alone as is, with no use (still) |
22:56:27 | FromDiscord | <arkanoid> nim check guarded.nim |
22:56:44 | FromDiscord | <Elegantbeef> No issue here on 2.20 |
22:57:04 | FromDiscord | <arkanoid> mh, let me skip my conf then |
22:57:10 | FromDiscord | <Elegantbeef> Everything is generic so there would be no instantiations until use so any error is clearly wrong |
22:57:17 | FromDiscord | <arkanoid> you're right, it's was my config, not sure what |
23:06:54 | FromDiscord | <arkanoid> I just had to add `return` and `var` to the `get` https://play.nim-lang.org/#pasty=cpkMWIyg |
23:11:29 | * | Guest70 quit (Quit: Client closed) |
23:14:34 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=hcnBgutT |
23:15:27 | FromDiscord | <Elegantbeef> Why does that matter? |
23:15:36 | FromDiscord | <Elegantbeef> Oh god you're doing a result of a guarded |
23:15:49 | FromDiscord | <Elegantbeef> That's no bueno as the lock moves iirc |
23:17:11 | FromDiscord | <arkanoid> \:( |
23:17:32 | FromDiscord | <Elegantbeef> The idea was to pass the state as a pointer then have the fields guarded then you do `.field.get` |
23:19:16 | FromDiscord | <arkanoid> that would be the same of having the pointer on the stack available for all |
23:19:29 | FromDiscord | <Elegantbeef> Except now you have safeties and no long have to cast gcsafe |
23:21:37 | * | jkl quit (Quit: Gone.) |
23:27:02 | FromDiscord | <arkanoid> true, but not sure which one is worst\: copying pointers explicitly between threads, or use cast |
23:28:40 | FromDiscord | <Elegantbeef> The copying doesn't provide safeties if the data changes from other threads 😄 |
23:35:50 | * | jkl joined #nim |
23:37:28 | FromDiscord | <arkanoid> sure, I'm not saying that guarded is not necessary, I'm saying that copy pointer between thread is unnecessary, as state object is 1 and is global |
23:37:29 | FromDiscord | <arkanoid> I need to guard field access, and guarded should be sufficient. (I first need to untangle `Result[Config, ConfigError]` from my code) |
23:37:29 | FromDiscord | <arkanoid> I'm not quite sure what happens if a lock is copied |
23:38:04 | FromDiscord | <arkanoid> shouldn't be responsibility of Lock object to forbid copy and dup? https://github.com/nim-lang/Nim/blob/version-2-2/lib/core/locks.nim#L1 |
23:48:25 | FromDiscord | <Elegantbeef> In fact it's preferable to prevent competing over a lock for writing |
23:48:25 | FromDiscord | <arkanoid> sure thing, but threads runs how the scheduler wants, without shared locks you can't prevent reader to be in the middle of writer op |
23:48:26 | FromDiscord | <Elegantbeef> After all you didn't describe what you're doing and I just pulled the Guarded idea out of my arse |
23:48:26 | FromDiscord | <Elegantbeef> I'm assuming there is no issue if a cycle runs with outdated info |
23:50:58 | FromDiscord | <arkanoid> it's a simple producer consumer task. Producer can change config, consumers read config and act accordingly. Producer may receive an updated config at any time and change the existing one |
23:51:54 | FromDiscord | <arkanoid> Guarded is OK. In my specific context I could use it to guard the whole Config object instead of the single field. This doesn't make a bug difference performance wise |
23:55:05 | * | beholders_eye quit (Ping timeout: 260 seconds) |
23:55:11 | FromDiscord | <arkanoid> but the issues are the same, copies are done and I need to change how I deal with errors |
23:56:06 | FromDiscord | <arkanoid> Btw I feel like i have all the pieces of the solution already, I just need to move them to stop Guarded fight with Result and make Threads happy. Thanks for the help |
23:56:26 | FromDiscord | <Elegantbeef> I did it?! 😛 |
23:59:59 | FromDiscord | <arkanoid> btw I'm googling what happen when locks are copied, still no answers. I'm quite curious |