<< 19-11-2024 >>

00:02:45*xutaxkamay joined #nim
00:10:23*xutaxkamay quit (Ping timeout: 252 seconds)
00:24:08*GnuYawk quit (Quit: The Lounge - https://thelounge.chat)
00:24:29*GnuYawk joined #nim
00:27:33*xutaxkamay joined #nim
00:29:17FromDiscord<Elegantbeef> Right you want to store state which means you want a closure
00:29:23FromDiscord<Elegantbeef> I did not get that from your first message
00:57:01FromDiscord<.tokyovigilante> Is there a best practice for object initialisation? I'm porting over an music player app which has a number of objects wrapping things like audio interfaces, track objects, network resources etc, that are relatively persistent and need some initialisation (connecting to a system audio server, loading codecs etc). There doesn't seem to be any sort of init() function that's called by default when an object is created.
01:06:28FromDiscord<Elegantbeef> `proc init(_: typdesc[YourType], ....): YourType)` Is what you'll want to do
01:06:42FromDiscord<Elegantbeef> Nim does not have constructors aside from `T(a: b, c: d)`
01:08:24*xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in)
01:08:39*xutaxkamay joined #nim
01:12:10*xutaxkamay quit (Client Quit)
01:12:30*xutaxkamay joined #nim
01:15:24*xutaxkamay quit (Client Quit)
01:15:39*xutaxkamay joined #nim
02:42:00FromDiscord<_multi> sent a long message, see https://pasty.ee/zvFgFmud
02:42:45FromDiscord<_multi> (edit) "https://pasty.ee/pOCcptMq" => "https://pasty.ee/ZtCMeaEw"
02:43:01FromDiscord<_multi> (edit) "https://pasty.ee/gDowEyaO" => "https://pasty.ee/KlxfrqJp"
02:44:53FromDiscord<.tokyovigilante> In reply to @Elegantbeef "`proc init(_: typdesc[YourType], ....):": Thanks, so just return an instance of the type?
02:48:26FromDiscord<Elegantbeef> Correct @.tokyovigilante
03:10:29*deeo99 joined #nim
03:11:14*deeo9 quit (Read error: Connection reset by peer)
03:11:14*deeo99 is now known as deeo9
03:15:34FromDiscord<.tokyovigilante> And then I should expect to be able to call YourType.init()?
03:16:07FromDiscord<.tokyovigilante> it doesn't seem to like object.yourType = YourType.init() currently
03:18:38FromDiscord<.tokyovigilante> Ah, but it does when I export the init proc properly, thanks!
03:22:12FromDiscord<.tokyovigilante> And presumably these object carrying internal state should be stored as refs?
03:23:34FromDiscord<Elegantbeef> @.tokyovigilante I will never give a single response to whether you need a ref 😄
03:23:42FromDiscord<Elegantbeef> it depends is the only good response
03:25:56FromDiscord<.tokyovigilante> In this case I'm going to assume yes, as the assignment to object.yourType is I assume a copy-assign, so my initial object is deallocated, calls my `=destroy` function, which promptly deinits all the internal C pointers, and causing a crash when they are subsequently referenced by the copy.🤯
03:26:12FromDiscord<Elegantbeef> `sink MyObject` where you give up resources
03:26:28FromDiscord<Elegantbeef> You do not need to use references cause of destructors, you use the move semantics as your friend
03:27:15FromDiscord<.tokyovigilante> Ah right, clearly I need to actually read these pages about memory management.
03:29:29FromDiscord<Elegantbeef> https://nim-lang.org/docs/destructors.html#sink-parameters will get you caught up
03:31:04FromDiscord<.tokyovigilante> Thanks
03:36:55*termer_ joined #nim
03:37:19*termer quit (Ping timeout: 244 seconds)
04:36:50*krux02 quit (Remote host closed the connection)
05:09:03FromDiscord<.bobbbob> In reply to @Elegantbeef "Nim does not have": I was never really clear why you need a constructor function anyways and not just use this.
05:10:42FromDiscord<Elegantbeef> Cause you might want default behaviour
06:12:14*xet7 quit (Quit: Leaving)
06:13:33*ntat joined #nim
06:31:42*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
06:32:10*SchweinDeBurg joined #nim
07:11:53*ntat quit (Quit: Leaving)
07:31:10*coldfeet joined #nim
07:37:20*coldfeet quit (Remote host closed the connection)
07:44:51*tiorock joined #nim
07:44:51*rockcavera quit (Killed (platinum.libera.chat (Nickname regained by services)))
07:44:51*tiorock is now known as rockcavera
07:46:56*tiorock joined #nim
07:46:56*tiorock quit (Changing host)
07:46:56*tiorock joined #nim
07:46:56*rockcavera is now known as Guest1883
07:46:56*Guest1883 quit (Killed (lead.libera.chat (Nickname regained by services)))
07:46:56*tiorock is now known as rockcavera
08:21:55om3gahave you seen this? https://github.com/pizlonator/llvm-project-deluge
08:59:33*tdc joined #nim
08:59:39*Jjp137 quit (Ping timeout: 260 seconds)
09:23:21*PMunch joined #nim
10:11:57*rockcavera quit (Remote host closed the connection)
10:30:22*tdc quit (Ping timeout: 252 seconds)
10:58:40*tdc joined #nim
11:09:33*Jjp137 joined #nim
11:50:01FromDiscord<pmunch> In reply to @nnsee "<@392962235737047041> you should make": Turns out my newer articles have `id` values so you can reference them like you mentioned. But that's only for those I've written in markdown and converted to HTML myself. The ones written in the CMS' editor doesn't have it.
11:50:08FromDiscord<pmunch> (edit) "doesn't" => "don't"
11:50:17FromDiscord<nnsee> ah i see
13:37:25*ntat joined #nim
14:10:01*krux02 joined #nim
14:15:49*lucasta joined #nim
15:20:49*ntat quit (Read error: Connection reset by peer)
15:20:51*m5zs7k quit (Read error: Connection reset by peer)
15:21:04*ntat joined #nim
15:21:14*m5zs7k joined #nim
17:33:45FromDiscord<pmunch> Hmm, wasn't there someone who wrote a HTML parser recently?
17:34:15FromDiscord<pmunch> Well I guess any lenient XML parser would be an HTML parser..
17:57:57*PMunch_ joined #nim
17:58:10*PMunch quit (Killed (NickServ (GHOST command used by PMunch_)))
17:58:18*PMunch_ is now known as PMunch
17:58:31*PMunch_ joined #nim
18:14:00FromDiscord<requiresupport> so I'm working with `StreamServer `using `chronos`, and I'd like to create an object based on StreamServer with other additional fields that I need. myStreamServer, then I'd like to use the `createStreamServer` function and cast it to my object `myStreamServer` .. I've noticed this was done in Scorper but tried similar method and failed miserably. Anyone can give a quick example with noob explanation?
18:57:18*xet7 joined #nim
19:07:20FromDiscord<intellij_gamer> In reply to @pmunch "Hmm, wasn't there someone": https://git.sr.ht/~bptato/chame this?
19:07:44PMunchAh yes, that was the one!
19:07:50*krux02 quit (Quit: Leaving)
19:09:01PMunchHmm, seems complex for what I wanted to do..
19:09:20Amun-Raparsing html is complex
19:09:24PMunchBasically I just want to add `id` tags to all header elements matching the text in the tag
19:09:34PMunchCould probably do it with `sed`..
19:10:41Amun-Rawe should write sed in nim and call it Ned
19:10:48Amun-RaI'll see myself out
19:18:25*kk joined #nim
19:35:16*coldfeet joined #nim
19:45:04*kk quit (Ping timeout: 265 seconds)
20:05:49FromDiscord<yottzumm> I’m looking for a way to query a table of objects, like a CSV file with nulls. The table is a metadata table
20:34:43FromDiscord<nnsee> In reply to @PMunch "Could probably do it": obligatory https://stackoverflow.com/a/1732454
20:44:45*coldfeet quit (Remote host closed the connection)
20:54:54*ntat quit (Quit: Leaving)
21:06:42FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=zmcXdhbe
21:09:55FromDiscord<Elegantbeef> https://github.com/beef331/traitor alternatively
21:09:56FromDiscord<Elegantbeef> @guttural666 look at how `std/streams` does it
21:10:40FromDiscord<Elegantbeef> https://github.com/yglukhov/iface
21:14:05FromDiscord<guttural666> I like your naming
21:14:19FromDiscord<guttural666> thanks, gonna look at the code
21:15:13PMunch@nnsee, haha good one
21:15:48PMunchTo be fair I'm not using this to parse random HTML, I'll just be using this to do a verifiable one-time job of adding id's to HTML tags
21:16:07FromDiscord<nnsee> yeah fwiw I think it'd work fine
21:16:12FromDiscord<nnsee> i just had to post it
21:21:41FromDiscord<bostonboston> I like the streams implementation for the interface type feel
21:23:06FromDiscord<Elegantbeef> My main issue with it is it relies on using inheritance so everything is boxed
21:23:27FromDiscord<Elegantbeef> Want a string stream that doesn't live on the heap? Good luck
21:31:41FromDiscord<guttural666> RootObj is compiler magic?
21:32:24FromDiscord<Elegantbeef> Yes
21:32:35FromDiscord<Elegantbeef> It just means you can use inheritance
21:32:51*PMunch quit (Quit: leaving)
21:36:44*tdc quit (Ping timeout: 264 seconds)
22:06:24FromDiscord<guttural666> can somebody tell me what's wrong with this? https://play.nim-lang.org/#pasty=WtgEYrUx
22:09:18FromDiscord<Elegantbeef> You don't assign the procs
22:11:56FromDiscord<guttural666> assign the procs? what do you mean
22:12:30FromDiscord<Elegantbeef> You are just instantiating the objects without setting the proc field
22:14:57FromDiscord<guttural666> hmmmmmmm
22:15:49FromDiscord<guttural666> declaring those procs as methods also didn't help, I see
22:26:54FromDiscord<ElegantBeef> Bridge is slow @guttural666 https://play.nim-lang.org/#pasty=kEluifxW
22:31:21FromDiscord<Elegantbeef> Of course not
22:31:21FromDiscord<Elegantbeef> You're using pointer procs why would a static proc matter
22:31:27FromDiscord<@terino:matrix.org> https://matrix.to/#/#_utopia_:matrix.org
22:31:31FromDiscord<Elegantbeef> @guttural666 https://play.nim-lang.org/#pasty=kEluifxW see if you assign the fields it works
22:34:06FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=qtSpUEMo
22:34:34*ftajhii joined #nim
22:39:15FromDiscord<Elegantbeef> There is no passing twice
22:40:26FromDiscord<bostonboston> r is an object, so you can use `.` as field accessor or make it the first parameter of a call, in that last line you are accessing the proc `getNextUrl` on the object `r` and then passing `r` to the proc
22:45:52FromDiscord<guttural666> yeah makes sense
23:13:04*jjido joined #nim
23:14:40*rockcavera joined #nim