00:08:45 | FromDiscord | <fabric.input_output> why not both |
00:17:18 | FromDiscord | <Elegantbeef> Soft shell are nicer |
01:28:27 | * | SchweinDeBurg quit (Quit: WeeChat 4.6.0-dev) |
01:29:28 | * | SchweinDeBurg joined #nim |
02:58:37 | * | xet7 joined #nim |
03:49:05 | * | SchweinDeBurg quit (Quit: WeeChat 4.6.0-dev) |
03:49:53 | * | SchweinDeBurg joined #nim |
03:52:35 | FromDiscord | <yummy_licorice> i tried formatting my code with nph |
03:52:44 | FromDiscord | <yummy_licorice> but its giving me this error |
03:53:22 | FromDiscord | <yummy_licorice> sent a code paste, see https://play.nim-lang.org/#pasty=gHXusGYE |
03:53:31 | FromDiscord | <yummy_licorice> this error didnt happen before formatting |
03:53:46 | FromDiscord | <yummy_licorice> sent a code paste, see https://play.nim-lang.org/#pasty=LHfbuiwA |
04:00:37 | FromDiscord | <that_dude.> sent a code paste, see https://play.nim-lang.org/#pasty=oDKHpEez |
04:00:55 | FromDiscord | <that_dude.> (edit) "https://play.nim-lang.org/#pasty=HwrDQITb" => "https://play.nim-lang.org/#pasty=FAKLDcnC" |
04:21:22 | FromDiscord | <lainlaylie> nph compares the ASTs of the file before and formatting and, to my understanding, cancels the changes if the AST is different |
04:23:20 | FromDiscord | <lainlaylie> (edit) "nph compares the ASTs of the file before and ... formatting" added "after" |
04:25:46 | FromDiscord | <yummy_licorice> funny enough |
04:25:53 | FromDiscord | <yummy_licorice> i fixed it |
04:26:01 | FromDiscord | <yummy_licorice> by updating to nim 2.3.1 |
04:26:12 | FromDiscord | <yummy_licorice> i was on 2.2.0 |
04:30:47 | FromDiscord | <lainlaylie> that's odd, thought nph was made for an old version of nim |
04:35:06 | FromDiscord | <yummy_licorice> likely has more to do with the cache being reset ig? |
04:41:45 | * | xet7 quit (Ping timeout: 252 seconds) |
04:54:11 | * | xet7 joined #nim |
05:44:35 | * | xet7 quit (Quit: Leaving) |
05:44:49 | * | ensyde joined #nim |
08:39:18 | FromDiscord | <arkanoid> sent a long message, see https://pasty.ee/KldJbzOW |
08:54:16 | FromDiscord | <bosinski2023> usually, i'd prefer to wrap and work with init/destructors. Once that works it looks clean and is the easiest for others to use, when doing a lib. |
09:00:47 | FromDiscord | <ichigo7799> "tabs are not allowed" oh GOD DAMNIT |
09:01:27 | FromDiscord | <ichigo7799> this is going to bite me over and over again |
09:04:50 | FromDiscord | <lainlaylie> i always go with init and =destroy when possible |
09:05:49 | FromDiscord | <lainlaylie> i consider this usage of defer a relic from when nim didn't have destructors |
09:11:46 | FromDiscord | <arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=CulFiWeB |
09:27:24 | FromDiscord | <arkanoid> thanks for the feedback |
10:08:33 | FromDiscord | <albassort> weird concept:↵Can i make a template that works as kinda like a fucntion where i can do "return false/false" at the end of branches to change how the template bheaves |
10:08:38 | FromDiscord | <albassort> for example |
10:10:18 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=hmvncQVq |
10:10:25 | FromDiscord | <albassort> "return" isn't used here because i realized thats stupid |
10:10:40 | FromDiscord | <albassort> those functions changes what the template does after the block returns |
10:11:04 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#pasty=gXejMPTQ" => "https://play.nim-lang.org/#pasty=PadtvMol" |
10:13:50 | FromDiscord | <arkanoid> il wrapped C type internally uses heap, the wrapper initializator should be an `initFoo` or `newFoo` ? |
10:32:33 | FromDiscord | <xtrayambak> sent a code paste, see https://play.nim-lang.org/#pasty=rKRUnHTQ |
10:32:49 | FromDiscord | <xtrayambak> I already wrote some and I have a compositor working with em if you want, I've bound a good chunk of Louvre |
10:33:29 | FromDiscord | <xtrayambak> https://github.com/xTrayambak/gogh - the bindings are located at `src/louvre` so you can take em from there |
10:33:37 | FromDiscord | <xtrayambak> I'll eventually get around to finishing them :^) |
10:33:43 | FromDiscord | <lainlaylie> In reply to @arkanoid "il wrapped C type": i think the accepted rule is "new iff ref object" |
10:38:21 | * | rockcavera quit (Remote host closed the connection) |
10:40:10 | FromDiscord | <arkanoid> ok, thanks again |
10:55:25 | FromDiscord | <michael.lenz.> In reply to @arkanoid "I'm wrapping C code": I would choose manual handling |
10:58:08 | * | beholders_eye joined #nim |
11:02:24 | * | coldfeet joined #nim |
11:07:31 | FromDiscord | <arkanoid> why? it seems much cleaner wrapper using =destroy in custom types↵(@michael.lenz.) |
11:08:06 | FromDiscord | <arkanoid> the only issue I see is how to raise errors within =destroy, but this is not a C wrapper specific problem |
11:10:59 | FromDiscord | <arkanoid> how are errors generally handled in destructors? |
11:12:17 | * | beholders_eye quit (Ping timeout: 248 seconds) |
11:14:22 | FromDiscord | <arkanoid> nim stdlib ignores errors in destructors.↵for example when closing file\:↵https://github.com/nim-lang/Nim/blob/ec324ad0736c3e0cfa26b64d6631b15693633a6f/lib/system/io.nim#L323↵https://pubs.opengroup.org/onlinepubs/009696799/functions/fclose.html |
11:15:14 | Amun-Ra | from what I understand destructors should only release the memory/whatever; I'd write a separate cleanup/free function |
11:15:38 | FromDiscord | <albassort> do cstrings alloced by exceptiosn need to be fredd? |
11:16:10 | Amun-Ra | how do you allocate these? |
11:16:34 | FromDiscord | <albassort> thats what im askin |
11:17:14 | Amun-Ra | allocate cstring, make a string from it, use a string, free on defer |
11:17:25 | FromDiscord | <albassort> well, the types in exceptions are cstrings |
11:17:28 | FromDiscord | <albassort> idk where they come from |
11:17:51 | FromDiscord | <albassort> i assume they come from c? |
11:17:51 | FromDiscord | <arkanoid> well but use a separate function for anything that is not just a free() inside destructors quite kills the reason to prefer destructors over defer/finally |
11:18:06 | Amun-Ra | true |
11:19:56 | FromDiscord | <arkanoid> so what's the general rule here? use destructor only for procs that can't fail and to realease memory/resources, and fallback to defer/finally for closing files/sockets/sessions whatever? |
11:20:38 | Amun-Ra | use destructors only for releasing non-gc memory/handles/… |
11:23:51 | FromDiscord | <arkanoid> not quite clear yet what is what. A network disconnection is a something that should go into destructor or not? I'm wrapping https://libssh2.org/libssh2_session_disconnect_ex.html |
11:26:37 | * | coldfeet quit (Quit: Lost terminal) |
11:30:19 | FromDiscord | <lainlaylie> some prior discussion: https://forum.nim-lang.org/t/9096 |
11:30:25 | FromDiscord | <arkanoid> it seems that the C++ people reached this agreement\:↵● the "cleanup" that raises errors should be available outside the destructor if user wants to handle errors↵● the very same "cleanup" function is also called automatically in destructor if not previously called manually, but this time the exceptions are "swallowed" |
11:31:34 | FromDiscord | <arkanoid> relevant resources\:↵● https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL57-CPP.+Do+not+let+exceptions+escape+from+destructors+or+deallocation+functions↵● https://stackoverflow.com/questions/130117/if-you-shouldnt-throw-exceptions-in-a-destructor-how-do-you-handle-errors-in-i |
11:34:30 | FromDiscord | <arkanoid> thanks for the feedbacks |
11:42:02 | * | beholders_eye joined #nim |
11:54:08 | FromDiscord | <arkanoid> Nim compiler seems to dislike this pattern\: `Warning: A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter``var T` is required to edit the passed function as it contains the variable that controls if the object has already been cleaned up or not |
11:54:21 | FromDiscord | <arkanoid> Nim compiler seems to dislike this pattern\: `Warning: A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter``var T` is required to edit the passed object as it contains the variable that controls if the object has already been cleaned up or not |
11:57:01 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=DxyGfeHw |
11:58:37 | FromDiscord | <arkanoid> without `var T` raw C object pointer `sessions` can't be set to null, or any other value to check if the object is still valid or not |
12:01:28 | FromDiscord | <arkanoid> I have to check if pointer is nil in both close and =destroy to avoid warning, leaving the internal pointer unchanged |
12:03:25 | FromDiscord | <arnetheduck> after `destroy` the instance is no longer supposed to be observable, so it shouldn't matter if you reset it or not |
12:03:51 | FromDiscord | <arnetheduck> (edit) "observable," => "observable to well-formed code," |
12:04:13 | FromDiscord | <arkanoid> @arnetheduck\: true, but not after close |
12:04:15 | FromDiscord | <lainlaylie> how about having a `proc closeImpl(s: SSH2Session): Result[...]`, making `close` call it and reset `s.session` on success, and `=destroy` call it and discard the result |
12:04:30 | FromDiscord | <lainlaylie> (edit) "Result[...]`," => "Result[...]` that doesn't reset `s.session`," |
12:04:41 | FromDiscord | <arnetheduck> In reply to @arkanoid "<@449019668296892420>\: true, but not": so? this is destroy, not close - close is (semantically) a different operation |
12:06:17 | FromDiscord | <arnetheduck> so to do what you want, you need third function (call it "release") which just does the closing part (and as others have noted, ignores errors) |
12:08:01 | FromDiscord | <arnetheduck> close is composed of "destroy" and "reset" basically, in your particular case ..↵↵there's actually a similar issue in c++: what should be the state of an object _after_ a `move`? it was undefined, last I looked, but as a matter of practical expediency, most types choose to leave it in a defined state, the same as for a "default-initialized" object (ie "empty string" ) |
12:09:22 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=IUDuENra |
12:09:28 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=GCqMVnFU |
12:10:29 | * | beholders_eye quit (Ping timeout: 248 seconds) |
12:11:01 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=krPcGlvL |
12:14:01 | FromDiscord | <lainlaylie> looks good |
12:15:31 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=GqQuEOUj |
12:17:06 | FromDiscord | <arkanoid> thanks |
12:18:23 | FromDiscord | <lainlaylie> just be careful that your release returns error if session is already nil |
12:22:14 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=ufZUbVRR |
12:22:31 | FromDiscord | <arkanoid> correct, fixed again |
12:23:06 | FromDiscord | <lainlaylie> (proving, once again, that strictDefs is an essential feature that ought to be on by default) |
12:24:26 | FromDiscord | <arkanoid> what is has to do with strictDefs? |
12:26:05 | FromDiscord | <lainlaylie> your `proc release` a couple edits ago only had the `if s.session != nil` branch, leaving you with (in the best case) an empty error message or (in the worst case) an error when you were expecting an ok |
12:26:32 | FromDiscord | <arkanoid> you're right, it probably should not |
12:26:48 | FromDiscord | <arkanoid> there's not happy path otherwise |
12:29:51 | FromDiscord | <arnetheduck> In reply to @arkanoid "there's not happy path": release needs an `ok` at the end of the happy path or it will implicitly be `err` |
12:30:21 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=oVfJDyXa |
12:30:42 | FromDiscord | <arkanoid> edited again, maybe maybe I got it right |
12:44:53 | FromDiscord | <arkanoid> are Nim gods deprecating std/unittest in favor of testament for simple user projects too? I don't recall this line last time I read unittest docs https://nim-lang.org/docs/unittest.html#testament |
12:53:09 | FromDiscord | <lainlaylie> that line's been there for a long time |
12:56:40 | FromDiscord | <arnetheduck> In reply to @arkanoid "are Nim gods deprecating": see also https://github.com/status-im/nim-unittest2/ |
13:02:47 | FromDiscord | <arnetheduck> In reply to @arkanoid "[Edit](https://discord.com/channels/371759389889003": also, fwiw, we we work with Result, we tend to avoid "happy path" endings inside `if` and other control flow.. ie we would have written `if session == nil: return err(...)` to avoid the bug, if we wanted to return an error in the case of double close.. this way, it's visually easier to check that there's an `ok` at the end |
13:07:55 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=bbEoGFbi |
13:08:12 | FromDiscord | <arkanoid> maybe the final ok is implicit? |
13:09:22 | Amun-Ra | I more a fan of this style: https://play.nim-lang.org/#pasty=EHCbjxCq keeps flow under control |
13:09:30 | Amun-Ra | I'm* |
13:09:39 | FromDiscord | <arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=nyrTxBqh |
13:09:52 | FromDiscord | <arnetheduck> (edit) "https://play.nim-lang.org/#pasty=XaDNYVWd" => "https://play.nim-lang.org/#pasty=mdbealVI" |
13:10:24 | FromDiscord | <arnetheduck> (edit) "https://play.nim-lang.org/#pasty=bQHnGzHo" => "https://play.nim-lang.org/#pasty=vhUcYJQf" |
13:10:50 | FromDiscord | <arkanoid> ah! you mean flatten the ifs. Well yeah, it looks better |
13:13:32 | FromDiscord | <arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=FuLanhDe |
13:14:19 | FromDiscord | <arnetheduck> like that, the compiler will check that all branches have an expression at the end - _I wish_ nim had this semantic for top-level code but it doesn't, so here we are |
13:16:16 | FromDiscord | <arkanoid> so you mean force the implicit return pattern |
13:20:09 | FromDiscord | <arkanoid> I quite prefer the Amun-Ra way\: sacrifice implicit return but avoid nested ifs |
13:25:35 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=ANrghSEm |
13:26:11 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=qadMoIXs |
13:27:39 | FromDiscord | <arnetheduck> I'm not saying "force implict return" - I'm saying `either "implict return" or "flat ifs" ` and the situation dictates which is preferable |
13:28:38 | FromDiscord | <arnetheduck> they're both good styles with Result but in slightly different scenarios |
13:38:09 | FromDiscord | <arkanoid> mh, it works but it calls `=destroy` twice if `.tryGet()` is used to init global |
14:24:34 | * | beholders_eye joined #nim |
14:59:58 | * | beholders_eye quit (Ping timeout: 252 seconds) |
15:29:25 | * | ntat joined #nim |
15:30:18 | * | coldfeet joined #nim |
16:10:41 | * | zgasma quit (Quit: Lost terminal) |
16:48:59 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=scPjSNvT |
17:30:06 | FromDiscord | <arnetheduck> In reply to @arkanoid "<@449019668296892420>\: you said this": https://github.com/arnetheduck/nim-results/blob/df8113dda4c2d74d460a8fa98252b0b771bf1f27/results.nim#L793 - it gives the full exception though and not the message |
17:39:10 | * | ensyde quit (Ping timeout: 260 seconds) |
17:55:31 | * | beholders_eye joined #nim |
18:09:34 | * | beholders_eye quit (Ping timeout: 245 seconds) |
18:29:20 | * | beholders_eye joined #nim |
18:47:15 | FromDiscord | <yummy_licorice> In reply to @xtrayambak "https://github.com/xTrayambak/gogh - the bindings": Ooh ty |
19:49:03 | FromDiscord | <.throwstar> Is there a way i can easily call c's printf? |
19:51:50 | FromDiscord | <bostonboston> `proc printf(fmt: cstring): cint {.importc: "printf", header: "<stdio.h>", varargs, discardable.}` |
19:52:20 | FromDiscord | <.throwstar> thanks |
20:13:43 | * | beholders_eye quit (Ping timeout: 244 seconds) |
20:21:12 | * | beholders_eye joined #nim |
20:28:19 | * | coldfeet quit (Quit: Lost terminal) |
21:05:17 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#pasty=rSoqQuDf |
21:11:39 | FromDiscord | <solitudesf> you |
21:11:48 | FromDiscord | <solitudesf> (edit) "you" => "you're assigning T to a value" |
21:12:00 | FromDiscord | <solitudesf> (edit) "value" => "span" |
21:12:05 | FromDiscord | <solitudesf> (edit) "span" => "span, instead of value" |
21:13:41 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @solitudesf "you're assigning T to": This is a Span of Color, so I should be able to set a color? |
21:15:17 | FromDiscord | <solitudesf> `span.data.toOpenArray(0, span.length)[idx] = T`↵`T` is a type. you're assigning type. |
21:16:09 | FromDiscord | <System64 ~ Flandre Scarlet> Oh! |
21:19:24 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @solitudesf "`span.data.toOpenArray(0, span.length)[idx] = T`": But then I need another generic? Such as U for example? |
21:19:57 | FromDiscord | <solitudesf> In reply to @sys64 "But then I need": for what? |
21:21:43 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @solitudesf "for what?": I want to assign a Color to a Span of Color |
21:22:42 | FromDiscord | <solitudesf> then do it, idk. what the issue? |
21:22:49 | FromDiscord | <solitudesf> (edit) "what" => "what's" |
21:23:44 | FromDiscord | <System64 ~ Flandre Scarlet> What I mentioned↵I call ↵``proc `[]=`(pal: ppal.Palette; index: SomeInteger, color: Color) |
21:24:34 | FromDiscord | <System64 ~ Flandre Scarlet> sent a long message, see https://pasty.ee/VmXEWOZr |
21:25:16 | FromDiscord | <solitudesf> yes, you're assigning `T` which is a type, instead of `value` which is a value. |
21:32:02 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @solitudesf "yes, you're assigning `T`": Ah yeah, I'm dumb lol |
22:31:17 | * | beholders_eye quit (Ping timeout: 248 seconds) |
22:35:59 | * | ntat quit (Quit: Leaving) |
22:50:28 | FromDiscord | <takemichihanagaki3129> Is there a way to disable nimsuggest? |
22:50:57 | FromDiscord | <takemichihanagaki3129> In reply to @takemichihanagaki3129 "Is there a way": Mine is breaking my whole system, starts to spawn a lot of instances and consumes the whole memory and CPU. |
23:11:51 | * | oprypin quit (Quit: Bye) |
23:12:01 | * | oprypin joined #nim |
23:56:23 | FromDiscord | <n0bra1n3r.nim> Hey guys, do you know of a way to embed a binary file in a nim binary? I'm trying to embed binary spirv into my app binary, similar to https://en.cppreference.com/w/c/preprocessor/embed. `slurp` doesn't work since it expands to a string. |
23:57:53 | FromDiscord | <arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=DSJkUFLy |
23:59:53 | FromDiscord | <demotomohiro> In reply to @n0bra1n3r.nim "Hey guys, do you": https://nim-lang.org/docs/system.html#staticRead%2Cstring |
23:59:57 | FromDiscord | <luteva> In reply to @takemichihanagaki3129 "Is there a way": just do not start it!? |