<< 04-11-2024 >>

03:35:32FromDiscord<.tokyovigilante> Hey team, is there an elegant way to monitor a file descriptor for events? Context, pipewire posts events to and FD which should be responded to by running a loop interation function, and I feel like this should be done using asyncdispatch somehow, but am not clever enough to figure it out. I did this in Swift with GCD which has a dispatch read source for file descriptors.
03:36:41FromDiscord<.tokyovigilante> wait, is it this easy? `result.fd = AsyncFD(fd)`
03:38:46FromDiscord<Elegantbeef> It might be, though `selectors` also is there
03:40:54FromDiscord<k0ts> addRead and addWrite from asyncdispatch are worth a look
03:42:54FromDiscord<.tokyovigilante> Nice, so I could either wrap my fd in an AsyncFD, then use addRead, or selectors, thanks.
04:34:11FromDiscord<wannabelokesh> In reply to @user2m "any learning resources? I'm": wrapping c headers in nim? ↵I need some intro to this stuff please..
05:04:37FromDiscord<demotomohiro> In reply to @wannabelokesh "wrapping c headers in": This might helps you to learn how to wrap C code for Nim: https://internet-of-tomohiro.pages.dev/nim/clibrary.en
05:28:46*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
05:29:12*SchweinDeBurg joined #nim
05:45:35*xet7 joined #nim
06:33:43*fallback quit (Ping timeout: 252 seconds)
06:50:24*coldfeet joined #nim
06:54:10*fallback joined #nim
07:01:19*coldfeet quit (Remote host closed the connection)
07:45:17*xutaxkamay_ joined #nim
07:45:24*xutaxkamay quit (Read error: Connection reset by peer)
07:46:07*xutaxkamay_ is now known as xutaxkamay
08:18:38FromDiscord<bubbly_avocado_86424> sent a long message, see https://pasty.ee/HtijhHpo
08:25:12FromDiscord<Elegantbeef> You're running the program so anything after the file to compile is passed as a parameter
08:25:33FromDiscord<Elegantbeef> Cue "would be nice if it used the idiom that `--` signified end of parameters"
08:29:23FromDiscord<demotomohiro> In reply to @bubbly_avocado_86424 "progressing with my little": https://nim-lang.org/docs/nimc.html#compiler-usage↵> Arguments: arguments are passed to the program being run (if --run option is selected)
08:29:56FromDiscord<bubbly_avocado_86424> In reply to @demotomohiro "https://nim-lang.org/docs/nimc.html#compiler-usage ": yes, yet, it is not possible to pass compiler arguments without -r
08:33:36FromDiscord<odexine> In reply to @bubbly_avocado_86424 "yes, yet, it is": ? What? You can definitely pass arguments to the compiler without r
08:34:20FromDiscord<bubbly_avocado_86424> In reply to @odexine "? What? You can": Error: arguments can only be given if the '--run' option is selected
08:34:39FromDiscord<odexine> Put them before the name of the file
08:34:46FromDiscord<bubbly_avocado_86424> ohhhh
08:34:59FromDiscord<Elegantbeef> Can take a horse to water
08:35:11FromDiscord<bubbly_avocado_86424> dies in shame
08:35:17FromDiscord<odexine> In reply to @Elegantbeef "Cue "would be nice": Sorely needed
08:36:14FromDiscord<bubbly_avocado_86424> sent a long message, see https://pasty.ee/HmZeaDgg
08:36:44FromDiscord<Elegantbeef> Well it is Nim cause it does not have the `--` idiom and uses the file name instead
08:41:02FromDiscord<bubbly_avocado_86424> regardless, i should 've tried and find out
08:48:37FromDiscord<buwubie> sent a code paste, see https://play.nim-lang.org/#pasty=DuFVxFiy
08:49:46FromDiscord<buwubie> sent a code paste, see https://play.nim-lang.org/#pasty=btrirwpO
08:50:42FromDiscord<buwubie> the purpose is to read a binary file with different types one after the other and to identify the types and allocate space for them dynamically
08:56:48FromDiscord<demotomohiro> In reply to @buwubie "Hello! does anybody know": How about to use [Object variants](https://nim-lang.org/docs/manual.html#types-object-variants) like https://github.com/nim-lang/Nim/blob/version-2-2/lib/pure/json.nim#L195
09:07:04FromDiscord<pmunch> In reply to @buwubie "the purpose is to": Short answer is no, you can't do it that way.↵Long answer is that you can achieve what you want to do, but not in the way you're trying to do it. Nim doesn't allow ambiguity in what type something is during runtime. Everything is statically and strictly typed, so you can't have your variable `x` change type during runtime. What you _can_ do is use object variants like @demotomohiro mentioned, a
09:14:32FromDiscord<bubbly_avocado_86424> @buwubie do you mean type as in exe, dll, docx, elf, pdf etc ?
09:14:45FromDiscord<buwubie> so technically i could discriminate based on the data types i read from my file. And based on that i pick and choose what i want my enum to be used as. Would this allow me to write overload the same proc for each posibility? Like and echo that prints each type in a certain way.
09:15:52FromDiscord<buwubie> In reply to @bubbly_avocado_86424 "<@493109136859332609> do you mean": No, like data types, i would have a table with (type, size) and have a file with [(string, 9), (int, 4), (int, 4), (char, 1)]
09:20:01FromDiscord<bubbly_avocado_86424> @Buwu is that binary file by coincidence something like a time-series file ?
09:21:51FromDiscord<buwubie> no, i need to define a new type of file for a project that acts like a docx in a way. It should store paragraphs, headers, comments and so on in a single binary file and then be able to export to HTML. But it should be made from objects, to be able to add stuff like images in there
09:22:36FromDiscord<bubbly_avocado_86424> In reply to @buwubie "no, i need to": reads a lot like bson
09:22:40FromDiscord<buwubie> (edit) "no, i need to define a new type of file for a project that acts like a docx in a way. It should store paragraphs, headers, comments and so on in a single binary file and then be able to export to HTML. But it should be made from objects, to be able to add stuff like images in there ... " added "in the future"
09:23:23FromDiscord<bubbly_avocado_86424> (edit) "bson" => "bson↵https://bsonspec.org/spec.html"
09:24:19FromDiscord<bubbly_avocado_86424> (edit) "bson↵https://bsonspec.org/spec.html" => "bson↵https://bsonspec.org/spec.html↵↵BSON, short for Bin­ary JSON, is a bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. Like JSON, BSON sup­ports the em­bed­ding of doc­u­ments and ar­rays with­in oth­er doc­u­ments and ar­rays. BSON also con­tains ex­ten­sions that al­low rep­res­ent­a­tion of data types that are not part of the
09:26:57FromDiscord<buwubie> In reply to @bubbly_avocado_86424 "reads a lot like": I will look into it, never heard of it before. Time to take a break and rethink everything from zero :). Thank you very much
10:16:42*disso-peach joined #nim
10:50:42FromDiscord<Robyn [She/Her]> In reply to @buwubie "no, i need to": msgpack? cbor?
10:51:06FromDiscord<Robyn [She/Her]> cbor is kiiinda like binary XML afaik
11:40:43FromDiscord<odexine> cbor is often said to be better than bson in terms of being a streaming binary file spec but its w/e
11:55:30*alexdaguy joined #nim
12:37:16*beholders_eye joined #nim
12:46:39*xutaxkamay_ joined #nim
12:48:43*xutaxkamay quit (Ping timeout: 264 seconds)
12:48:44*xutaxkamay_ is now known as xutaxkamay
13:59:40FromDiscord<nervecenter> In reply to @buwubie "no, i need to": MessagePack is good for that. It's a key-value store that uses strings for keys and binary type-tagged data for values. Also includes a raw binary blob data type since the altnerative, tagged arrays, tag the type of each element which can get inefficient. That'd be perfect for your images and such.
13:59:53FromDiscord<nervecenter> https://msgpack.org/
14:00:03FromDiscord<nervecenter> https://github.com/jangko/msgpack4nim
14:00:57FromDiscord<nervecenter> `msgpack4nim` has a compile flag called `msgpack_obj_to_map` which is very useful for converting static Nim objects into msgpack maps
14:07:50FromDiscord<nnsee> i would not use msgpack for new projects when cbor is a thing
14:08:34FromDiscord<nnsee> cbor was branched off of msgpack in order to fix some of msgpack's design shortcomings
14:09:58FromDiscord<nnsee> cbor has the benefit of being an ietf standard - msgpack on the other hand is not
14:10:02FromDiscord<spotlightkid> That's what I've read on Wikipedia, but the example they give of a feature that CBOR has over msgpack, was later addeed to msgpack too.
14:10:46FromDiscord<spotlightkid> There is CDDL, though, so that's an advantage if you want to generate good API descriptions.
14:24:58FromDiscord<blackmius> In reply to @buwubie "no, i need to": docx is a zip archive containing xml meta data and other content as different files,
14:25:09FromDiscord<spotlightkid> https://git.sr.ht/~ehmry/nim_cbor (haven't tried it).
14:26:09FromDiscord<nnsee> yes, the docx format isn't... the most sophisticated format in the world
14:28:06*alexdaguy quit (Quit: WeeChat 4.4.3)
14:45:33*ntat joined #nim
15:18:58*Onionhammer quit (Ping timeout: 252 seconds)
15:28:42*lucasta joined #nim
15:31:12FromDiscord<wannabelokesh> In reply to @PMunch "Crap, I hit back": welcome to discord native, I guess..
15:34:19*beholders_eye quit (Ping timeout: 260 seconds)
15:40:17FromDiscord<solarvortex_ae> Does nim have any kind of dynamic importing
15:41:02FromDiscord<solarvortex_ae> Eg: i want to automatically import every file in folder a
15:41:50FromDiscord<odexine> you'd need to write a macro for that
15:42:02FromDiscord<odexine> actually, i dont even think a macro can write import statements, not that i remember
15:44:19FromDiscord<solarvortex_ae> Ah
15:44:24FromDiscord<solarvortex_ae> :(
15:45:43*beholders_eye joined #nim
15:47:43FromDiscord<ayex> I am fairly sure it can\: I imported, or maybe included files with macro, to inspect pragmas of the import/include..↵(@odexine)
15:48:08FromDiscord<odexine> i dont exactly remember
15:48:22FromDiscord<odexine> im like 20% confident that it cant, which means its more likely that it can
15:48:32FromDiscord<ayex> I am fairly sure it can\: I imported, or maybe included files with macro, to inspect pragmas of the import/include. (pretty amazing what kind of actions macros enable)
15:49:50FromDiscord<wannabelokesh> 1. are macros in nim any similar to what macros are in C? ↵2. what's a wrapper at all? like in above message someone attached a github repo for "wrapping c headers in nim"..↵what are they at all? can I wrap c headers in c too 😆 ?
15:50:12FromDiscord<wannabelokesh> or is it one language (for wrapper) behind another?
15:50:22FromDiscord<wannabelokesh> (edit) "wrapper)" => "wrapping)"
15:50:32FromDiscord<odexine> 1. no. they are more powerful↵2. wrappers are like "glue" to use one language in another, so a nim wrapper for c is a thing that allows you to use c stuff in nim
15:50:47Amun-Rawannabelokesh: C macros are nim's templates
15:51:02FromDiscord<odexine> they are more powerful -> nim's are
15:51:10FromDiscord<odexine> sorry, i didnt realise that was ambiguous
15:55:55FromDiscord<wannabelokesh> its fine. i got that already
15:55:57FromDiscord<wannabelokesh> rizz
15:56:10FromDiscord<double_spiral> Correct me if im wrong, passing in a variable via `var <type>` is like `ref <type>` but safer right?
15:56:54FromDiscord<odexine> not really like ref type, ref type implies an extra allocation
15:57:25FromDiscord<wannabelokesh> In reply to @odexine "1. no. they are": 2. ↵is it like writing library or framework in one language and applying it in another? ↵or polyglot programming (which I heard of but don't know the way I must know how it works)?
15:57:41FromDiscord<wannabelokesh> and why wrapping?
15:57:44FromDiscord<Robyn [She/Her]> var type params basically say "hey! give me mutable access to this!
15:57:50FromDiscord<Robyn [She/Her]> (edit) "this!" => "this!""
15:58:06FromDiscord<odexine> In reply to @wannabelokesh "2. is it": its like exposing the components of a library for another language
15:58:26FromDiscord<double_spiral> In reply to @chronos.vitaqua "var type params basically": Whats the difference between that and ref though, in practice they seemingly do the same thing
15:58:46FromDiscord<odexine> In reply to @wannabelokesh "and why wrapping?": because you're encapsulating another (A) language's library with code to use it in this (B) language
16:00:22FromDiscord<odexine> In reply to @double_spiral "Whats the difference between": hm, this is hard to explain
16:01:10FromDiscord<Robyn [She/Her]> In reply to @double_spiral "Whats the difference between": ref means when you store it in an immutable variable (`let` for example) the data inside the reference can still be mutated
16:01:29FromDiscord<Robyn [She/Her]> you're storing a pointer to an object instead of the object
16:01:45FromDiscord<Robyn [She/Her]> (edit) "an" => "the"
16:02:02FromDiscord<Robyn [She/Her]> Do you have any Java knowledge?
16:02:02FromDiscord<wannabelokesh> In reply to @odexine "because you're encapsulating another": why not do the whole project in same language?
16:02:15FromDiscord<Robyn [She/Her]> Or know the difference between `Integer` and `int`?
16:02:18FromDiscord<wannabelokesh> yes
16:02:21FromDiscord<double_spiral> In reply to @chronos.vitaqua "Do you have any": A tiny bit
16:02:24FromDiscord<double_spiral> In reply to @chronos.vitaqua "Or know the difference": No idea
16:02:27FromDiscord<Robyn [She/Her]> was talking to helix
16:02:33FromDiscord<nnsee> In reply to @wannabelokesh "why not do the": because if something already exists in C, and it's a large library, porting it to Nim entirely is a herculean task
16:02:45FromDiscord<odexine> In reply to @wannabelokesh "why not do the": because oftentimes this other library isnt something you made
16:02:47FromDiscord<wannabelokesh> Integer OOP based↵int primitive type
16:02:48FromDiscord<nnsee> not impossible, but not really something that many people want to do when wrapping is an option
16:02:51FromDiscord<odexine> and possibly thousands of lines long
16:03:03FromDiscord<Robyn [She/Her]> okay well in Java, `int` is a primitive and it directly stores the value, `Integer` is an instance of a class, and in Java, those are always pass by reference
16:03:21FromDiscord<Robyn [She/Her]> In reply to @wannabelokesh "why not do the": wanna port sqlite3 to Nim? :p
16:03:35FromDiscord<double_spiral> Sounds fun, who wouldnt wanna do that?
16:03:38FromDiscord<Robyn [She/Her]> you get to reuse another ecosystem's code (C in this case) in Nim
16:03:54FromDiscord<odexine> In reply to @double_spiral "Sounds fun, who wouldnt": people who dont have time
16:04:04FromDiscord<odexine> and want to get the implementation done aspa
16:04:10FromDiscord<odexine> (edit) "aspa" => "asap"
16:04:14FromDiscord<wannabelokesh> ok
16:04:28FromDiscord<Robyn [She/Her]> In reply to @double_spiral "Sounds fun, who wouldnt": people who value reliability and the robustness of an existing, developed project
16:05:53FromDiscord<nnsee> In reply to @double_spiral "Sounds fun, who wouldnt": apparently not this guy https://github.com/kawasin73/prsqlite
16:05:58FromDiscord<nnsee> (rust, not nim, but still)
16:11:22*beholders_eye quit (Ping timeout: 244 seconds)
16:21:04*Onionhammer joined #nim
16:35:42*beholders_eye joined #nim
16:39:34FromDiscord<spotlightkid> Rustaceans don't count. They all have this bad case of NIH syndrom.
16:43:31FromDiscord<Robyn [She/Her]> In reply to @spotlightkid "Rustaceans don't count. They": NIH?
16:44:50FromDiscord<nervecenter> "Not invented here" syndrome. If it's not made in Rust it either doesn't exist, or should be made in Rust and lock people into using it with Rust.
16:45:00FromDiscord<nervecenter> (edit) "made" => "(re)made"
16:45:54FromDiscord<odexine> RIIR
17:16:18*beholders_eye quit (Ping timeout: 272 seconds)
18:04:50*lucasta quit (Quit: Leaving)
18:21:38*fallback quit (Ping timeout: 252 seconds)
18:26:46*beholders_eye joined #nim
18:39:13*beholders_eye quit (Ping timeout: 252 seconds)
19:02:20*fallback joined #nim
19:51:57*jkl quit (Quit: Gone.)
19:53:29*jkl joined #nim
20:57:25FromDiscord<aurelian5014> i wonder how long the c amalgamation takes to compile
20:57:42FromDiscord<aurelian5014> brb, embedding
21:08:17*ntat quit (Quit: Leaving)
21:54:15FromDiscord<emanresu3> can you create your own source code filters without recompiling nim?
22:01:15FromDiscord<fabric.input_output> hate it when this happens https://media.discordapp.net/attachments/371759389889003532/1303116878176321628/image.png?ex=672a95aa&is=6729442a&hm=577c74111c335f4cbc943cad6f40b8c5e6ef720e0107082c7c61593b23dc0a7c&
22:01:36FromDiscord<Robyn [She/Her]> In reply to @nervecenter ""Not invented here" syndrome.": ah lmao
22:03:33FromDiscord<fabric.input_output> every time I try and stretch the type system a little bit nim blows up
22:05:15FromDiscord<fabric.input_output> I don't even know enough to go and fix it myself in the compiler :(
22:17:33FromDiscord<Robyn [She/Her]> In reply to @fabric.input_output "hate it when this": wanna share the code?
22:23:02FromDiscord<mtriplet> Can anyone explain this to me?
22:23:07FromDiscord<mtriplet> sent a code paste, see https://play.nim-lang.org/#pasty=sLmDjcpS
22:31:11FromDiscord<michaelb.eth> In reply to @mtriplet "Can anyone explain this": it’s not actively developed, so you’re better off using another editor, unless you want to hack on NimEdit itself
22:31:54FromDiscord<mtriplet> In reply to @michaelb.eth "it’s not actively developed,": ugh
22:31:56FromDiscord<mtriplet> great
23:08:08*lucasta joined #nim
23:18:37FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=BVfMgZGz
23:18:42FromDiscord<albassort> is this function in the stdlib
23:20:06FromDiscord<Elegantbeef> `get` exists and does that
23:22:32FromDiscord<albassort> In reply to @Elegantbeef "`get` exists and does": which get
23:22:36FromDiscord<albassort> im not seeing any get which does this
23:22:43FromDiscord<albassort> oh it see it
23:22:47FromDiscord<albassort> thank u
23:30:17*disso-peach quit (Quit: Leaving)