<< 31-01-2025 >>

00:08:45FromDiscord<fabric.input_output> why not both
00:17:18FromDiscord<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:35FromDiscord<yummy_licorice> i tried formatting my code with nph
03:52:44FromDiscord<yummy_licorice> but its giving me this error
03:53:22FromDiscord<yummy_licorice> sent a code paste, see https://play.nim-lang.org/#pasty=gHXusGYE
03:53:31FromDiscord<yummy_licorice> this error didnt happen before formatting
03:53:46FromDiscord<yummy_licorice> sent a code paste, see https://play.nim-lang.org/#pasty=LHfbuiwA
04:00:37FromDiscord<that_dude.> sent a code paste, see https://play.nim-lang.org/#pasty=oDKHpEez
04:00:55FromDiscord<that_dude.> (edit) "https://play.nim-lang.org/#pasty=HwrDQITb" => "https://play.nim-lang.org/#pasty=FAKLDcnC"
04:21:22FromDiscord<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:20FromDiscord<lainlaylie> (edit) "nph compares the ASTs of the file before and ... formatting" added "after"
04:25:46FromDiscord<yummy_licorice> funny enough
04:25:53FromDiscord<yummy_licorice> i fixed it
04:26:01FromDiscord<yummy_licorice> by updating to nim 2.3.1
04:26:12FromDiscord<yummy_licorice> i was on 2.2.0
04:30:47FromDiscord<lainlaylie> that's odd, thought nph was made for an old version of nim
04:35:06FromDiscord<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:18FromDiscord<arkanoid> sent a long message, see https://pasty.ee/KldJbzOW
08:54:16FromDiscord<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:47FromDiscord<ichigo7799> "tabs are not allowed" oh GOD DAMNIT
09:01:27FromDiscord<ichigo7799> this is going to bite me over and over again
09:04:50FromDiscord<lainlaylie> i always go with init and =destroy when possible
09:05:49FromDiscord<lainlaylie> i consider this usage of defer a relic from when nim didn't have destructors
09:11:46FromDiscord<arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=CulFiWeB
09:27:24FromDiscord<arkanoid> thanks for the feedback
10:08:33FromDiscord<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:38FromDiscord<albassort> for example
10:10:18FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=hmvncQVq
10:10:25FromDiscord<albassort> "return" isn't used here because i realized thats stupid
10:10:40FromDiscord<albassort> those functions changes what the template does after the block returns
10:11:04FromDiscord<albassort> (edit) "https://play.nim-lang.org/#pasty=gXejMPTQ" => "https://play.nim-lang.org/#pasty=PadtvMol"
10:13:50FromDiscord<arkanoid> il wrapped C type internally uses heap, the wrapper initializator should be an `initFoo` or `newFoo` ?
10:32:33FromDiscord<xtrayambak> sent a code paste, see https://play.nim-lang.org/#pasty=rKRUnHTQ
10:32:49FromDiscord<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:29FromDiscord<xtrayambak> https://github.com/xTrayambak/gogh - the bindings are located at `src/louvre` so you can take em from there
10:33:37FromDiscord<xtrayambak> I'll eventually get around to finishing them :^)
10:33:43FromDiscord<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:10FromDiscord<arkanoid> ok, thanks again
10:55:25FromDiscord<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:31FromDiscord<arkanoid> why? it seems much cleaner wrapper using =destroy in custom types↵(@michael.lenz.)
11:08:06FromDiscord<arkanoid> the only issue I see is how to raise errors within =destroy, but this is not a C wrapper specific problem
11:10:59FromDiscord<arkanoid> how are errors generally handled in destructors?
11:12:17*beholders_eye quit (Ping timeout: 248 seconds)
11:14:22FromDiscord<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:14Amun-Rafrom what I understand destructors should only release the memory/whatever; I'd write a separate cleanup/free function
11:15:38FromDiscord<albassort> do cstrings alloced by exceptiosn need to be fredd?
11:16:10Amun-Rahow do you allocate these?
11:16:34FromDiscord<albassort> thats what im askin
11:17:14Amun-Raallocate cstring, make a string from it, use a string, free on defer
11:17:25FromDiscord<albassort> well, the types in exceptions are cstrings
11:17:28FromDiscord<albassort> idk where they come from
11:17:51FromDiscord<albassort> i assume they come from c?
11:17:51FromDiscord<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:06Amun-Ratrue
11:19:56FromDiscord<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:38Amun-Rause destructors only for releasing non-gc memory/handles/…
11:23:51FromDiscord<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:19FromDiscord<lainlaylie> some prior discussion: https://forum.nim-lang.org/t/9096
11:30:25FromDiscord<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:34FromDiscord<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:30FromDiscord<arkanoid> thanks for the feedbacks
11:42:02*beholders_eye joined #nim
11:54:08FromDiscord<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:21FromDiscord<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:01FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=DxyGfeHw
11:58:37FromDiscord<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:28FromDiscord<arkanoid> I have to check if pointer is nil in both close and =destroy to avoid warning, leaving the internal pointer unchanged
12:03:25FromDiscord<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:51FromDiscord<arnetheduck> (edit) "observable," => "observable to well-formed code,"
12:04:13FromDiscord<arkanoid> @arnetheduck\: true, but not after close
12:04:15FromDiscord<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:30FromDiscord<lainlaylie> (edit) "Result[...]`," => "Result[...]` that doesn't reset `s.session`,"
12:04:41FromDiscord<arnetheduck> In reply to @arkanoid "<@449019668296892420>\: true, but not": so? this is destroy, not close - close is (semantically) a different operation
12:06:17FromDiscord<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:01FromDiscord<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:22FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=IUDuENra
12:09:28FromDiscord<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:01FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=krPcGlvL
12:14:01FromDiscord<lainlaylie> looks good
12:15:31FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=GqQuEOUj
12:17:06FromDiscord<arkanoid> thanks
12:18:23FromDiscord<lainlaylie> just be careful that your release returns error if session is already nil
12:22:14FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=ufZUbVRR
12:22:31FromDiscord<arkanoid> correct, fixed again
12:23:06FromDiscord<lainlaylie> (proving, once again, that strictDefs is an essential feature that ought to be on by default)
12:24:26FromDiscord<arkanoid> what is has to do with strictDefs?
12:26:05FromDiscord<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:32FromDiscord<arkanoid> you're right, it probably should not
12:26:48FromDiscord<arkanoid> there's not happy path otherwise
12:29:51FromDiscord<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:21FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=oVfJDyXa
12:30:42FromDiscord<arkanoid> edited again, maybe maybe I got it right
12:44:53FromDiscord<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:09FromDiscord<lainlaylie> that line's been there for a long time
12:56:40FromDiscord<arnetheduck> In reply to @arkanoid "are Nim gods deprecating": see also https://github.com/status-im/nim-unittest2/
13:02:47FromDiscord<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:55FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=bbEoGFbi
13:08:12FromDiscord<arkanoid> maybe the final ok is implicit?
13:09:22Amun-RaI more a fan of this style: https://play.nim-lang.org/#pasty=EHCbjxCq keeps flow under control
13:09:30Amun-RaI'm*
13:09:39FromDiscord<arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=nyrTxBqh
13:09:52FromDiscord<arnetheduck> (edit) "https://play.nim-lang.org/#pasty=XaDNYVWd" => "https://play.nim-lang.org/#pasty=mdbealVI"
13:10:24FromDiscord<arnetheduck> (edit) "https://play.nim-lang.org/#pasty=bQHnGzHo" => "https://play.nim-lang.org/#pasty=vhUcYJQf"
13:10:50FromDiscord<arkanoid> ah! you mean flatten the ifs. Well yeah, it looks better
13:13:32FromDiscord<arnetheduck> sent a code paste, see https://play.nim-lang.org/#pasty=FuLanhDe
13:14:19FromDiscord<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:16FromDiscord<arkanoid> so you mean force the implicit return pattern
13:20:09FromDiscord<arkanoid> I quite prefer the Amun-Ra way\: sacrifice implicit return but avoid nested ifs
13:25:35FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=ANrghSEm
13:26:11FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=qadMoIXs
13:27:39FromDiscord<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:38FromDiscord<arnetheduck> they're both good styles with Result but in slightly different scenarios
13:38:09FromDiscord<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:59FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=scPjSNvT
17:30:06FromDiscord<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:15FromDiscord<yummy_licorice> In reply to @xtrayambak "https://github.com/xTrayambak/gogh - the bindings": Ooh ty
19:49:03FromDiscord<.throwstar> Is there a way i can easily call c's printf?
19:51:50FromDiscord<bostonboston> `proc printf(fmt: cstring): cint {.importc: "printf", header: "<stdio.h>", varargs, discardable.}`
19:52:20FromDiscord<.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:17FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#pasty=rSoqQuDf
21:11:39FromDiscord<solitudesf> you
21:11:48FromDiscord<solitudesf> (edit) "you" => "you're assigning T to a value"
21:12:00FromDiscord<solitudesf> (edit) "value" => "span"
21:12:05FromDiscord<solitudesf> (edit) "span" => "span, instead of value"
21:13:41FromDiscord<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:17FromDiscord<solitudesf> `span.data.toOpenArray(0, span.length)[idx] = T`↵`T` is a type. you're assigning type.
21:16:09FromDiscord<System64 ~ Flandre Scarlet> Oh!
21:19:24FromDiscord<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:57FromDiscord<solitudesf> In reply to @sys64 "But then I need": for what?
21:21:43FromDiscord<System64 ~ Flandre Scarlet> In reply to @solitudesf "for what?": I want to assign a Color to a Span of Color
21:22:42FromDiscord<solitudesf> then do it, idk. what the issue?
21:22:49FromDiscord<solitudesf> (edit) "what" => "what's"
21:23:44FromDiscord<System64 ~ Flandre Scarlet> What I mentioned↵I call ↵``proc `[]=`(pal: ppal.Palette; index: SomeInteger, color: Color)
21:24:34FromDiscord<System64 ~ Flandre Scarlet> sent a long message, see https://pasty.ee/VmXEWOZr
21:25:16FromDiscord<solitudesf> yes, you're assigning `T` which is a type, instead of `value` which is a value.
21:32:02FromDiscord<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:28FromDiscord<takemichihanagaki3129> Is there a way to disable nimsuggest?
22:50:57FromDiscord<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:23FromDiscord<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:53FromDiscord<arkanoid> sent a code paste, see https://play.nim-lang.org/#pasty=DSJkUFLy
23:59:53FromDiscord<demotomohiro> In reply to @n0bra1n3r.nim "Hey guys, do you": https://nim-lang.org/docs/system.html#staticRead%2Cstring
23:59:57FromDiscord<luteva> In reply to @takemichihanagaki3129 "Is there a way": just do not start it!?