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:17 | FromDiscord | <Elegantbeef> Right you want to store state which means you want a closure |
00:29:23 | FromDiscord | <Elegantbeef> I did not get that from your first message |
00:57:01 | FromDiscord | <.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:28 | FromDiscord | <Elegantbeef> `proc init(_: typdesc[YourType], ....): YourType)` Is what you'll want to do |
01:06:42 | FromDiscord | <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:00 | FromDiscord | <_multi> sent a long message, see https://pasty.ee/zvFgFmud |
02:42:45 | FromDiscord | <_multi> (edit) "https://pasty.ee/pOCcptMq" => "https://pasty.ee/ZtCMeaEw" |
02:43:01 | FromDiscord | <_multi> (edit) "https://pasty.ee/gDowEyaO" => "https://pasty.ee/KlxfrqJp" |
02:44:53 | FromDiscord | <.tokyovigilante> In reply to @Elegantbeef "`proc init(_: typdesc[YourType], ....):": Thanks, so just return an instance of the type? |
02:48:26 | FromDiscord | <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:34 | FromDiscord | <.tokyovigilante> And then I should expect to be able to call YourType.init()? |
03:16:07 | FromDiscord | <.tokyovigilante> it doesn't seem to like object.yourType = YourType.init() currently |
03:18:38 | FromDiscord | <.tokyovigilante> Ah, but it does when I export the init proc properly, thanks! |
03:22:12 | FromDiscord | <.tokyovigilante> And presumably these object carrying internal state should be stored as refs? |
03:23:34 | FromDiscord | <Elegantbeef> @.tokyovigilante I will never give a single response to whether you need a ref 😄 |
03:23:42 | FromDiscord | <Elegantbeef> it depends is the only good response |
03:25:56 | FromDiscord | <.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:12 | FromDiscord | <Elegantbeef> `sink MyObject` where you give up resources |
03:26:28 | FromDiscord | <Elegantbeef> You do not need to use references cause of destructors, you use the move semantics as your friend |
03:27:15 | FromDiscord | <.tokyovigilante> Ah right, clearly I need to actually read these pages about memory management. |
03:29:29 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/destructors.html#sink-parameters will get you caught up |
03:31:04 | FromDiscord | <.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:03 | FromDiscord | <.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:42 | FromDiscord | <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:55 | om3ga | have 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:01 | FromDiscord | <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:08 | FromDiscord | <pmunch> (edit) "doesn't" => "don't" |
11:50:17 | FromDiscord | <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:45 | FromDiscord | <pmunch> Hmm, wasn't there someone who wrote a HTML parser recently? |
17:34:15 | FromDiscord | <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:00 | FromDiscord | <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:20 | FromDiscord | <intellij_gamer> In reply to @pmunch "Hmm, wasn't there someone": https://git.sr.ht/~bptato/chame this? |
19:07:44 | PMunch | Ah yes, that was the one! |
19:07:50 | * | krux02 quit (Quit: Leaving) |
19:09:01 | PMunch | Hmm, seems complex for what I wanted to do.. |
19:09:20 | Amun-Ra | parsing html is complex |
19:09:24 | PMunch | Basically I just want to add `id` tags to all header elements matching the text in the tag |
19:09:34 | PMunch | Could probably do it with `sed`.. |
19:10:41 | Amun-Ra | we should write sed in nim and call it Ned |
19:10:48 | Amun-Ra | I'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:49 | FromDiscord | <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:43 | FromDiscord | <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:42 | FromDiscord | <guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=zmcXdhbe |
21:09:55 | FromDiscord | <Elegantbeef> https://github.com/beef331/traitor alternatively |
21:09:56 | FromDiscord | <Elegantbeef> @guttural666 look at how `std/streams` does it |
21:10:40 | FromDiscord | <Elegantbeef> https://github.com/yglukhov/iface |
21:14:05 | FromDiscord | <guttural666> I like your naming |
21:14:19 | FromDiscord | <guttural666> thanks, gonna look at the code |
21:15:13 | PMunch | @nnsee, haha good one |
21:15:48 | PMunch | To 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:07 | FromDiscord | <nnsee> yeah fwiw I think it'd work fine |
21:16:12 | FromDiscord | <nnsee> i just had to post it |
21:21:41 | FromDiscord | <bostonboston> I like the streams implementation for the interface type feel |
21:23:06 | FromDiscord | <Elegantbeef> My main issue with it is it relies on using inheritance so everything is boxed |
21:23:27 | FromDiscord | <Elegantbeef> Want a string stream that doesn't live on the heap? Good luck |
21:31:41 | FromDiscord | <guttural666> RootObj is compiler magic? |
21:32:24 | FromDiscord | <Elegantbeef> Yes |
21:32:35 | FromDiscord | <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:24 | FromDiscord | <guttural666> can somebody tell me what's wrong with this? https://play.nim-lang.org/#pasty=WtgEYrUx |
22:09:18 | FromDiscord | <Elegantbeef> You don't assign the procs |
22:11:56 | FromDiscord | <guttural666> assign the procs? what do you mean |
22:12:30 | FromDiscord | <Elegantbeef> You are just instantiating the objects without setting the proc field |
22:14:57 | FromDiscord | <guttural666> hmmmmmmm |
22:15:49 | FromDiscord | <guttural666> declaring those procs as methods also didn't help, I see |
22:26:54 | FromDiscord | <ElegantBeef> Bridge is slow @guttural666 https://play.nim-lang.org/#pasty=kEluifxW |
22:31:21 | FromDiscord | <Elegantbeef> Of course not |
22:31:21 | FromDiscord | <Elegantbeef> You're using pointer procs why would a static proc matter |
22:31:27 | FromDiscord | <@terino:matrix.org> https://matrix.to/#/#_utopia_:matrix.org |
22:31:31 | FromDiscord | <Elegantbeef> @guttural666 https://play.nim-lang.org/#pasty=kEluifxW see if you assign the fields it works |
22:34:06 | FromDiscord | <guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=qtSpUEMo |
22:34:34 | * | ftajhii joined #nim |
22:39:15 | FromDiscord | <Elegantbeef> There is no passing twice |
22:40:26 | FromDiscord | <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:52 | FromDiscord | <guttural666> yeah makes sense |
23:13:04 | * | jjido joined #nim |
23:14:40 | * | rockcavera joined #nim |