<< 12-11-2024 >>

00:46:21*lucasta quit (Quit: Leaving)
00:54:15*lucasta joined #nim
01:13:01*lucasta quit (Quit: Leaving)
01:22:05*xet7 joined #nim
02:14:49*rockcavera quit (Remote host closed the connection)
02:33:19FromDiscord<.tokyovigilante> Dumb question, but how do I return early from a function?
02:34:47FromDiscord<.tokyovigilante> Or more accurately a template, maybe that's why `return` isn't working
02:40:43FromDiscord<Elegantbeef> You use a block and do `break blockname`
02:40:48FromDiscord<Elegantbeef> Then you question whether you need a template
02:45:16FromDiscord<.tokyovigilante> ta, thanks. It's for a conditional log, ie if level < loglevel: return, but if level >= log: doLog() works as well
02:45:34FromDiscord<.tokyovigilante> (edit) "if" => "`if" | "return," => "return`," | "level" => "`level" | "doLog()" => "doLog()`"
02:47:30*xutaxkamay quit (Ping timeout: 246 seconds)
02:48:03*xutaxkamay joined #nim
02:51:23FromDiscord<Elegantbeef> What is the full template?
03:31:25FromDiscord<.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=oPxtoqbx
03:32:39FromDiscord<Elegantbeef> Ah the instantiation info is needed, carry on
05:21:08*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
05:25:04*SchweinDeBurg joined #nim
06:41:04FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=ZjXchhTx
06:42:02FromDiscord<odexine> where is this await placed
06:42:40FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=EnQorpTL
06:42:53FromDiscord<odexine> how do you then call connect
06:43:28FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=eLDjFBiF
06:43:57FromDiscord<Elegantbeef> Do you have a `runForever()` or similar blocking call?
06:44:16FromDiscord<riku5543> Yeah I'm using webui and there's a proc called wait() that waits for the window to be closed
06:44:36FromDiscord<odexine> does it call `poll()` from asyncdispatch
06:44:53FromDiscord<odexine> because if it doesnt then that means your futures arent actually being run
06:45:44FromDiscord<riku5543> Hm it's in C land so I have no idea what it does..
06:45:51FromDiscord<Elegantbeef> So yes it doesn't
06:46:13FromDiscord<riku5543> Is there a way to get them to work together?
06:46:34FromDiscord<Elegantbeef> Is there a bool or similar you could use instead?
06:47:08FromDiscord<riku5543> Hm for what?
06:47:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=kVBUegFE
06:49:40FromDiscord<riku5543> Does poll block forever?
06:49:48FromDiscord<riku5543> I'm trying to figure out where to put it
06:50:03FromDiscord<odexine> poll has to run inside a loop
06:50:09Amun-Rano
06:50:28FromDiscord<odexine> well, "has to" in the sense that it would be most useful if it were...
06:51:03FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=OVIhYGrp
06:51:05FromDiscord<odexine> it just runs "one increment" of a future: aka if there are futures ready now it works on those then stops, so it blocks a little at a time
06:51:19FromDiscord<odexine> you need to somehow modify wait to include poll inside it
06:51:36FromDiscord<odexine> or replicate the function of wait and add poll inside it
06:53:26FromDiscord<riku5543> I think I could replace it with a check to see if the window is running and call poll in the meantime. Can I use os.sleep with this or should I just let it run real fast?
06:53:40FromDiscord<Elegantbeef> Never use sleep in your main loop
06:53:52FromDiscord<Elegantbeef> What webui library are you using?
06:53:59FromDiscord<odexine> let it run real fast or change the timeout on poll i guess?
06:54:13FromDiscord<riku5543> In reply to @Elegantbeef "What webui library are": https://github.com/webui-dev/nim-webui this one
06:54:59FromDiscord<riku5543> Alright I'll try that, thanks for the help, I never knew poll was required for await. (I'm guessing runForever calls it already, huh? \:P)
06:55:23FromDiscord<odexine> it does
06:55:33FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=RkMwqLHq
06:55:39FromDiscord<odexine> `pol()`
06:55:40FromDiscord<odexine> lol
06:55:42FromDiscord<_.heartlove._> pol()
06:55:55FromDiscord<riku5543> p o l a n d
06:56:01FromDiscord<Elegantbeef> I swear I'm not a greentexter
06:57:28FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=FLXWiNAI
06:57:40FromDiscord<Elegantbeef> Why
06:57:54FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=OcSJKejz
06:58:08FromDiscord<riku5543> Oh yeah that's how you can use braincells
06:58:12FromDiscord<riku5543> Mine are rusty
06:59:17FromDiscord<odexine> uh oh
07:03:40FromDiscord<riku5543> Hm it says "No handles or timers registered in dispatcher." even if it reaches the await later in the program
07:04:14FromDiscord<Elegantbeef> If only the try except was shown
07:04:23FromDiscord<Elegantbeef> Too bad someone removed it cause they thought they knew better šŸ˜›
07:04:51FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=kxYggEUK
07:05:00FromDiscord<riku5543> But it's just the same message no matter what lol
07:06:40FromDiscord<riku5543> I'm going to try a smaller program to see if I can figure stuff out
07:06:56FromDiscord<Elegantbeef> Well it should work now
07:07:07FromDiscord<Elegantbeef> That exception is to be expected if there are no futures to complete
07:08:04FromDiscord<Elegantbeef> There is `hasPendingOperations` you might be able to defend `poll` with
07:08:31FromDiscord<riku5543> Ooh good to know
07:08:33FromDiscord<riku5543> Thanks
07:09:41FromDiscord<Elegantbeef> To explain further about async. Since it's just a cpu time share, you have to explicitly give up your cpu to process futures that are ready. As such you need to use `poll` `await` `drain` `waitfor` to say "ok look at the futures in the pool and finish any that are ready"
07:23:15*PMunch joined #nim
07:43:35FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=PzACqjTP
07:48:21FromDiscord<Elegantbeef> Are you sure `window.shown` is true?
07:48:54FromDiscord<riku5543> Yeah heh, I placed a plain `echo` there with no conditions and it constantly runs until the window is closed
07:49:23FromDiscord<Elegantbeef> So then just do the try except and call it a day
07:52:43FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=AOOCIICP
08:00:20FromDiscord<riku5543> Does the regular `net` library work with multiple threads? I might try that instead
08:01:30*fallback quit (Ping timeout: 260 seconds)
08:05:35FromDiscord<Elegantbeef> Of course it does, were you attempting to use async with threads?
08:05:46FromDiscord<Elegantbeef> Cause each thread gets it's own event pool
08:07:34FromDiscord<riku5543> No it was all on one thread, I think something is incompatible though so I'm trying out malebolgia
08:17:23*fallback joined #nim
08:26:19FromDiscord<enthus1ast.> I would not use async network in the main gui thread. It kinda works but not good, at least I would use one network thread
08:27:06FromDiscord<enthus1ast.> If you nevertheless want/try this, make the poll timeout very small (25?!l
08:29:01FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=xRPSAbtZ
08:36:48FromDiscord<enthus1ast.> Never do network code without try except, it can fail in many ways (I get it, it's debugging code). I don't know the webgui lib you're using, but I guess it runs its own event loop, so in case of async networking you should call poll in an timer/timeout (or something similar). Or directly in a thread. I also don't know malbolgia ^^ but it could be that it spawns stuff also on the main thread
08:37:43FromDiscord<enthus1ast.> To be honest, I still like to use the boring old threads
08:37:54FromDiscord<enthus1ast.> Threads and channels
08:42:03FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=KJWgqfSi
09:15:52FromDiscord<enthus1ast.> When you use async you would have async handlers for the network, so there would be stuff pending. In your debug code there is none after you connect, so to avoid this you can asyncCheck a sleepAsync loop
09:23:21*Jjp137 quit (Ping timeout: 246 seconds)
09:26:39*Jjp137 joined #nim
10:13:47FromDiscord<riku5543> I figured out a working combo. I have to use blocking networking and have the ui start a new thread for it. If exceptions aren't caught here, the proc will hang, but if I use try/except, it actually works fine surprisingly
10:18:30FromDiscord<riku5543> And now that I think about it, I'm not sure if it's hanging per se or if the proc just stops executing entirely since it encountered an error, honestly that seems more reasonable lol.
10:18:48FromDiscord<riku5543> Coding late at night while sick is fun
10:20:48FromDiscord<riku5543> (Oh yeah I couldn't use async stuff cause it seems to not work on the main thread while using webui, and since I have to make a new thread anyway, using regular net works fine)
10:52:34FromDiscord<enthus1ast.> yes, i just had a look at the webui (it looks quite cool ngl)
10:53:02FromDiscord<enthus1ast.> but it seems to miss a function where you can create a reoccuring task on the backend
10:53:35FromDiscord<enthus1ast.> so so far the only option i see to use the async stuff in the main thread is to drive the poll from the js, but this is kinda weird šŸ˜‰
10:53:59FromDiscord<enthus1ast.> or just not do it
10:54:14FromDiscord<enthus1ast.> you can even create a networking thread and setup the async networking there
10:54:20FromDiscord<enthus1ast.> (edit) "even" => ""
12:13:34FromDiscord<konan_5> hello, hereā†µis there any opportunity to work with you/
12:14:43PMunchThere is a jobs channel on Discord
12:15:10PMunchNot sure if that is what you're looking for
12:15:16PMunchAlso a 90% chance this is just spam..
12:36:22*beholders_eye joined #nim
12:43:15*beholders_eye quit (Ping timeout: 276 seconds)
12:43:42*beholders_eye joined #nim
13:39:40*ntat joined #nim
13:41:08FromDiscord<Jack> Yeah, they've spammed this in other rooms too.ā†µ(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>)
13:49:22FromDiscord<Jack> If anybody is looking to start contributing towards Nim itself, the project's repository can be found [here](https://github.com/nim-lang/Nim). If you looking for something else, a variety of Nim projects can be found [here](https://github.com/topics/nim).
14:20:47FromDiscord<Jack> If anybody is looking to start contributing towards Nim itself, the project's repository can be found [here](https://github.com/nim-lang/Nim). If you are looking for something else, a variety of Nim projects can be found [here](https://github.com/topics/nim).
14:34:58PMunchWhy are you telling the Nim community where to find Nim stuff? We already know..
14:35:03*beholders_eye quit (Ping timeout: 276 seconds)
14:36:19*beholders_eye joined #nim
14:40:27FromDiscord<grumblygibson> In reply to @enthus1ast. "so so far the": I have also been looking for this. Maybe the abandoned Neel? webui and webGui and nimview all have some internal event loop that prevents the backend from being the driver. It's possible that interacting with the js layer is a way around this: server sends a js call, the page refreshes, and actually displays.
14:42:14FromDiscord<odexine> In reply to @PMunch "Why are you telling": im assuming that was to konan_5
14:42:48PMunchOh right
15:01:50*ntat quit (Quit: Leaving)
15:12:42FromDiscord<enthus1ast.> In reply to @grumblygibson "I have also been": I guess that's the way for this lib. I did not see any API in the c code. But I might have missed it
15:17:48*PMunch quit (Quit: Leaving)
17:06:20*coldfeet joined #nim
17:11:39*coldfeet quit (Remote host closed the connection)
17:51:11*lx12ucy joined #nim
17:52:26lx12ucyhi! i'm a bit confused as to why I'm not able to access fields of a custom type initialized in a seperate file and returned by a proc
17:53:12lx12ucyI'm able to echo the variable for the type correctly, but it gives me an error if i try to echo anything more specific
17:53:32lx12ucyecho(configuration) gives (nerdfonts: true, box: true, boxLogo: true, roundCorners: true, login: true, logo: "auto", separator: " ā”‚ ", colorSymbol: "ā—", titleColor: "cyan", dataColor: "blue", otherColor: "magenta")
17:53:55lx12ucybut echo(configuration.nerdfonts) is an error, is this an intended behavior?
17:54:59lx12ucysays "Error: undeclared field: 'nerdfonts' for type config.Config"
17:55:09FromDiscord<planetis_m> In reply to @lx12ucy "but echo(configuration.nerdfonts) is an": You need to export the fields first, using the marker
17:55:55lx12ucyohh
17:57:21lx12ucywhere does that go?
17:59:08FromDiscord<odexine> after the field name before the colon
17:59:33FromDiscord<demotomohiro> https://nim-lang.org/docs/manual.html#modules
18:00:12FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=yUzolXnH
18:01:56lx12ucyyay! thank you!
18:03:18*coldfeet joined #nim
18:04:12*lx12ucy quit (Quit: application quit, bye!)
18:13:31*coldfeet quit (Remote host closed the connection)
18:20:10*lx12ucy joined #nim
18:21:41*lx12ucy quit (Client Quit)
18:30:36*coldfeet joined #nim
18:37:00*coldfeet quit (Remote host closed the connection)
18:51:24FromDiscord<k0ts> We need to rustify our error messages
18:51:33FromDiscord<k0ts> Hint: did you forget to export it?
19:14:35FromDiscord<guttural666> is there a way to specify the type of an enum? say uint8?
19:25:38FromDiscord<demotomohiro> For wrapping C enum types: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-size-pragma
19:31:23*ntat joined #nim
19:33:32FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=ccDZtnRJ
19:36:34FromDiscord<guttural666> In reply to @demotomohiro "For wrapping C enum": sorry, this actually does what I want
19:36:35FromDiscord<guttural666> thanks
20:01:53*beholders_eye quit (Ping timeout: 248 seconds)
20:22:23FromDiscord<aethrvmn_32073> Hey guys, is this expected behaviour?ā†µā†µhttps://play.nim-lang.org/#pasty=MrwnTteR
20:22:36FromDiscord<aethrvmn_32073> If so, what am I missing?
20:25:26FromDiscord<bubbly_avocado_86424> nim documentation is almost great really
20:25:29FromDiscord<bubbly_avocado_86424> yet, not
20:26:43FromDiscord<Jack> Not necessarily them, but people like them.ā†µ(@odexine)
20:26:47FromDiscord<Elegantbeef> @aethrvmn_32073 seems the playground is having issues, throw it somewhere else I guess
20:29:46FromDiscord<aethrvmn_32073> In reply to @Elegantbeef "<@1292739848053981250> seems the playground": https://pastebin.com/bdteDX4U
20:33:24FromDiscord<solitudesf> In reply to @aethrvmn_32073 "https://pastebin.com/bdteDX4U": this is expected. defaults are assigned with `ObjectConstructor()` (which tuples dont have) or with `default`
20:34:13FromDiscord<aethrvmn_32073> In reply to @solitudesf "this is expected. defaults": what part of the docs has gone completely over my head?
20:34:23FromDiscord<aethrvmn_32073> aka where do I learn more about this?
20:34:33FromDiscord<solitudesf> In reply to @aethrvmn_32073 "what part of the": https://nim-lang.org/docs/manual.html#types-default-values-for-object-fields
20:35:13FromDiscord<Elegantbeef> Use objects then your life is better
20:36:03FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#types-tuples-and-object-types aswell as here
20:36:25FromDiscord<Elegantbeef> Tuples are structurally typed which means `var a: tuple[a, b: int] = (10, 20)` is valid
20:37:56FromDiscord<Elegantbeef> If you wanted a named tuple you can of course do `var a = (a: 10, b: 20)` but use an object šŸ˜„
20:38:16FromDiscord<aethrvmn_32073> In reply to @Elegantbeef "If you wanted a": I'm trying to figure all these out rn hahaha
20:38:27FromDiscord<aethrvmn_32073> thanks alot!
20:41:25FromDiscord<Elegantbeef> Objects are nominally typed if you want to understand the difference
20:43:22FromDiscord<bubbly_avocado_86424> In reply to @k0ts "We need to rustify": i just spent over one hour to find out ā†µvar webb = newHttpClient(sslContext=(newContext(verifyMode=CVerifyNone))ā†µā†µis not working because i had to import the std/net module also
20:47:38FromDiscord<bubbly_avocado_86424> makes sense now but hey, i guess this is what i takes to learn by doing
20:48:41FromDiscord<Elegantbeef> Nim is very adhoc so how would it error more
20:48:42FromDiscord<solitudesf> it takes two seconds to see which module has `newContext`. what error are you expecting there
20:48:48FromDiscord<Elegantbeef> Iterate all modules in your nimble path searching for `newContext`?
20:49:09FromDiscord<bubbly_avocado_86424> well, that not how i went about
20:51:19FromDiscord<bubbly_avocado_86424> i started search in the httpclient module and did not notice i ended up in the net module (sigh)
20:59:53*lucasta joined #nim
21:10:44FromDiscord<TFed> i want to make function, that updates object's contentā†µā†µlike set function, clean and init functions
21:12:41FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=KCjeiDiT
21:12:59FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=EDmpvvSc
21:13:10FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=PgmluXRl
21:13:51FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=OnuQyBFP
21:13:59FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1306003271361761363): i want to make function, that updates object's contentā†µā†µlike does set, clean and init functions
21:14:42*ftajhii joined #nim
21:14:59FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=sXZNBmgK
21:15:07FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=prUaFftL
21:17:11FromDiscord<Elegantbeef> Discord is really loving all the edits
21:17:25FromDiscord<Elegantbeef> if `Pack` is an `object` you need to take in `var Pack`
21:18:35ftajhiiI've decided to tinker with Nim, what would be a good repo to follow for someone wanting to learn the language?
21:27:41*zgasma joined #nim
21:37:59*ntat quit (Quit: Leaving)
21:38:05FromDiscord<bubbly_avocado_86424> In reply to @ftajhii "I've decided to tinker": here ? https://nim-lang.org/docs/lib.html
22:43:11FromDiscord<aethrvmn_32073> In reply to @TFed "i want to make": if you're messing around with the object it might be better to use `ref object` instead
22:43:35FromDiscord<aethrvmn_32073> so you dont have to carry the `var` on every proc you define
22:48:52*disso-peach joined #nim
22:51:55FromDiscord<bosinski2023> sent a code paste, see https://play.nim-lang.org/#pasty=kDCGVoBn
22:52:33FromDiscord<Elegantbeef> This is a bad suggestionā†µ(@aethrvmn_32073)
22:52:52FromDiscord<aethrvmn_32073> doesn't it depend on the usecase?
22:52:53FromDiscord<Elegantbeef> You need to put it in another macro
22:53:07FromDiscord<Elegantbeef> Exactly only use `ref` if you need ref semantics
22:53:09FromDiscord<Elegantbeef> Not cause you're lazy
22:53:58FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=SQpJUtVp
23:15:46*rockcavera joined #nim
23:47:57*disso-peach quit (Quit: Leaving)