03:35:32 | FromDiscord | <.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:41 | FromDiscord | <.tokyovigilante> wait, is it this easy? `result.fd = AsyncFD(fd)` |
03:38:46 | FromDiscord | <Elegantbeef> It might be, though `selectors` also is there |
03:40:54 | FromDiscord | <k0ts> addRead and addWrite from asyncdispatch are worth a look |
03:42:54 | FromDiscord | <.tokyovigilante> Nice, so I could either wrap my fd in an AsyncFD, then use addRead, or selectors, thanks. |
04:34:11 | FromDiscord | <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:37 | FromDiscord | <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:38 | FromDiscord | <bubbly_avocado_86424> sent a long message, see https://pasty.ee/HtijhHpo |
08:25:12 | FromDiscord | <Elegantbeef> You're running the program so anything after the file to compile is passed as a parameter |
08:25:33 | FromDiscord | <Elegantbeef> Cue "would be nice if it used the idiom that `--` signified end of parameters" |
08:29:23 | FromDiscord | <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:56 | FromDiscord | <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:36 | FromDiscord | <odexine> In reply to @bubbly_avocado_86424 "yes, yet, it is": ? What? You can definitely pass arguments to the compiler without r |
08:34:20 | FromDiscord | <bubbly_avocado_86424> In reply to @odexine "? What? You can": Error: arguments can only be given if the '--run' option is selected |
08:34:39 | FromDiscord | <odexine> Put them before the name of the file |
08:34:46 | FromDiscord | <bubbly_avocado_86424> ohhhh |
08:34:59 | FromDiscord | <Elegantbeef> Can take a horse to water |
08:35:11 | FromDiscord | <bubbly_avocado_86424> dies in shame |
08:35:17 | FromDiscord | <odexine> In reply to @Elegantbeef "Cue "would be nice": Sorely needed |
08:36:14 | FromDiscord | <bubbly_avocado_86424> sent a long message, see https://pasty.ee/HmZeaDgg |
08:36:44 | FromDiscord | <Elegantbeef> Well it is Nim cause it does not have the `--` idiom and uses the file name instead |
08:41:02 | FromDiscord | <bubbly_avocado_86424> regardless, i should 've tried and find out |
08:48:37 | FromDiscord | <buwubie> sent a code paste, see https://play.nim-lang.org/#pasty=DuFVxFiy |
08:49:46 | FromDiscord | <buwubie> sent a code paste, see https://play.nim-lang.org/#pasty=btrirwpO |
08:50:42 | FromDiscord | <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:48 | FromDiscord | <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:04 | FromDiscord | <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:32 | FromDiscord | <bubbly_avocado_86424> @buwubie do you mean type as in exe, dll, docx, elf, pdf etc ? |
09:14:45 | FromDiscord | <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:52 | FromDiscord | <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:01 | FromDiscord | <bubbly_avocado_86424> @Buwu is that binary file by coincidence something like a time-series file ? |
09:21:51 | FromDiscord | <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:36 | FromDiscord | <bubbly_avocado_86424> In reply to @buwubie "no, i need to": reads a lot like bson |
09:22:40 | FromDiscord | <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:23 | FromDiscord | <bubbly_avocado_86424> (edit) "bson" => "bson↵https://bsonspec.org/spec.html" |
09:24:19 | FromDiscord | <bubbly_avocado_86424> (edit) "bson↵https://bsonspec.org/spec.html" => "bson↵https://bsonspec.org/spec.html↵↵BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. Like JSON, BSON supports the embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow representation of data types that are not part of the |
09:26:57 | FromDiscord | <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:42 | FromDiscord | <Robyn [She/Her]> In reply to @buwubie "no, i need to": msgpack? cbor? |
10:51:06 | FromDiscord | <Robyn [She/Her]> cbor is kiiinda like binary XML afaik |
11:40:43 | FromDiscord | <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:40 | FromDiscord | <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:53 | FromDiscord | <nervecenter> https://msgpack.org/ |
14:00:03 | FromDiscord | <nervecenter> https://github.com/jangko/msgpack4nim |
14:00:57 | FromDiscord | <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:50 | FromDiscord | <nnsee> i would not use msgpack for new projects when cbor is a thing |
14:08:34 | FromDiscord | <nnsee> cbor was branched off of msgpack in order to fix some of msgpack's design shortcomings |
14:09:58 | FromDiscord | <nnsee> cbor has the benefit of being an ietf standard - msgpack on the other hand is not |
14:10:02 | FromDiscord | <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:46 | FromDiscord | <spotlightkid> There is CDDL, though, so that's an advantage if you want to generate good API descriptions. |
14:24:58 | FromDiscord | <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:09 | FromDiscord | <spotlightkid> https://git.sr.ht/~ehmry/nim_cbor (haven't tried it). |
14:26:09 | FromDiscord | <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:12 | FromDiscord | <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:17 | FromDiscord | <solarvortex_ae> Does nim have any kind of dynamic importing |
15:41:02 | FromDiscord | <solarvortex_ae> Eg: i want to automatically import every file in folder a |
15:41:50 | FromDiscord | <odexine> you'd need to write a macro for that |
15:42:02 | FromDiscord | <odexine> actually, i dont even think a macro can write import statements, not that i remember |
15:44:19 | FromDiscord | <solarvortex_ae> Ah |
15:44:24 | FromDiscord | <solarvortex_ae> :( |
15:45:43 | * | beholders_eye joined #nim |
15:47:43 | FromDiscord | <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:08 | FromDiscord | <odexine> i dont exactly remember |
15:48:22 | FromDiscord | <odexine> im like 20% confident that it cant, which means its more likely that it can |
15:48:32 | FromDiscord | <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:50 | FromDiscord | <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:12 | FromDiscord | <wannabelokesh> or is it one language (for wrapper) behind another? |
15:50:22 | FromDiscord | <wannabelokesh> (edit) "wrapper)" => "wrapping)" |
15:50:32 | FromDiscord | <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:47 | Amun-Ra | wannabelokesh: C macros are nim's templates |
15:51:02 | FromDiscord | <odexine> they are more powerful -> nim's are |
15:51:10 | FromDiscord | <odexine> sorry, i didnt realise that was ambiguous |
15:55:55 | FromDiscord | <wannabelokesh> its fine. i got that already |
15:55:57 | FromDiscord | <wannabelokesh> rizz |
15:56:10 | FromDiscord | <double_spiral> Correct me if im wrong, passing in a variable via `var <type>` is like `ref <type>` but safer right? |
15:56:54 | FromDiscord | <odexine> not really like ref type, ref type implies an extra allocation |
15:57:25 | FromDiscord | <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:41 | FromDiscord | <wannabelokesh> and why wrapping? |
15:57:44 | FromDiscord | <Robyn [She/Her]> var type params basically say "hey! give me mutable access to this! |
15:57:50 | FromDiscord | <Robyn [She/Her]> (edit) "this!" => "this!"" |
15:58:06 | FromDiscord | <odexine> In reply to @wannabelokesh "2. is it": its like exposing the components of a library for another language |
15:58:26 | FromDiscord | <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:46 | FromDiscord | <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:22 | FromDiscord | <odexine> In reply to @double_spiral "Whats the difference between": hm, this is hard to explain |
16:01:10 | FromDiscord | <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:29 | FromDiscord | <Robyn [She/Her]> you're storing a pointer to an object instead of the object |
16:01:45 | FromDiscord | <Robyn [She/Her]> (edit) "an" => "the" |
16:02:02 | FromDiscord | <Robyn [She/Her]> Do you have any Java knowledge? |
16:02:02 | FromDiscord | <wannabelokesh> In reply to @odexine "because you're encapsulating another": why not do the whole project in same language? |
16:02:15 | FromDiscord | <Robyn [She/Her]> Or know the difference between `Integer` and `int`? |
16:02:18 | FromDiscord | <wannabelokesh> yes |
16:02:21 | FromDiscord | <double_spiral> In reply to @chronos.vitaqua "Do you have any": A tiny bit |
16:02:24 | FromDiscord | <double_spiral> In reply to @chronos.vitaqua "Or know the difference": No idea |
16:02:27 | FromDiscord | <Robyn [She/Her]> was talking to helix |
16:02:33 | FromDiscord | <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:45 | FromDiscord | <odexine> In reply to @wannabelokesh "why not do the": because oftentimes this other library isnt something you made |
16:02:47 | FromDiscord | <wannabelokesh> Integer OOP based↵int primitive type |
16:02:48 | FromDiscord | <nnsee> not impossible, but not really something that many people want to do when wrapping is an option |
16:02:51 | FromDiscord | <odexine> and possibly thousands of lines long |
16:03:03 | FromDiscord | <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:21 | FromDiscord | <Robyn [She/Her]> In reply to @wannabelokesh "why not do the": wanna port sqlite3 to Nim? :p |
16:03:35 | FromDiscord | <double_spiral> Sounds fun, who wouldnt wanna do that? |
16:03:38 | FromDiscord | <Robyn [She/Her]> you get to reuse another ecosystem's code (C in this case) in Nim |
16:03:54 | FromDiscord | <odexine> In reply to @double_spiral "Sounds fun, who wouldnt": people who dont have time |
16:04:04 | FromDiscord | <odexine> and want to get the implementation done aspa |
16:04:10 | FromDiscord | <odexine> (edit) "aspa" => "asap" |
16:04:14 | FromDiscord | <wannabelokesh> ok |
16:04:28 | FromDiscord | <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:53 | FromDiscord | <nnsee> In reply to @double_spiral "Sounds fun, who wouldnt": apparently not this guy https://github.com/kawasin73/prsqlite |
16:05:58 | FromDiscord | <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:34 | FromDiscord | <spotlightkid> Rustaceans don't count. They all have this bad case of NIH syndrom. |
16:43:31 | FromDiscord | <Robyn [She/Her]> In reply to @spotlightkid "Rustaceans don't count. They": NIH? |
16:44:50 | FromDiscord | <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:00 | FromDiscord | <nervecenter> (edit) "made" => "(re)made" |
16:45:54 | FromDiscord | <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:25 | FromDiscord | <aurelian5014> i wonder how long the c amalgamation takes to compile |
20:57:42 | FromDiscord | <aurelian5014> brb, embedding |
21:08:17 | * | ntat quit (Quit: Leaving) |
21:54:15 | FromDiscord | <emanresu3> can you create your own source code filters without recompiling nim? |
22:01:15 | FromDiscord | <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:36 | FromDiscord | <Robyn [She/Her]> In reply to @nervecenter ""Not invented here" syndrome.": ah lmao |
22:03:33 | FromDiscord | <fabric.input_output> every time I try and stretch the type system a little bit nim blows up |
22:05:15 | FromDiscord | <fabric.input_output> I don't even know enough to go and fix it myself in the compiler :( |
22:17:33 | FromDiscord | <Robyn [She/Her]> In reply to @fabric.input_output "hate it when this": wanna share the code? |
22:23:02 | FromDiscord | <mtriplet> Can anyone explain this to me? |
22:23:07 | FromDiscord | <mtriplet> sent a code paste, see https://play.nim-lang.org/#pasty=sLmDjcpS |
22:31:11 | FromDiscord | <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:54 | FromDiscord | <mtriplet> In reply to @michaelb.eth "it’s not actively developed,": ugh |
22:31:56 | FromDiscord | <mtriplet> great |
23:08:08 | * | lucasta joined #nim |
23:18:37 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=BVfMgZGz |
23:18:42 | FromDiscord | <albassort> is this function in the stdlib |
23:20:06 | FromDiscord | <Elegantbeef> `get` exists and does that |
23:22:32 | FromDiscord | <albassort> In reply to @Elegantbeef "`get` exists and does": which get |
23:22:36 | FromDiscord | <albassort> im not seeing any get which does this |
23:22:43 | FromDiscord | <albassort> oh it see it |
23:22:47 | FromDiscord | <albassort> thank u |
23:30:17 | * | disso-peach quit (Quit: Leaving) |