00:00:40 | FromDiscord | <Robyn [She/Her]> Fair |
00:01:28 | * | beholders_eye quit (Read error: Connection reset by peer) |
00:03:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=dphLlISJ |
00:04:01 | FromDiscord | <Elegantbeef> To me enum branches are existential types and not just runtime types so they should exist and be operated on |
00:07:09 | FromDiscord | <Robyn [She/Her]> Aah okay I understand that now |
00:07:41 | * | beholders_eye joined #nim |
00:08:14 | FromDiscord | <Robyn [She/Her]> Though, does that require explicit conversion or do converters handle the conversion in a nice way? |
00:09:03 | FromDiscord | <Robyn [She/Her]> In reply to @chronos.vitaqua "Though, does that require": Seems like converters handle it nicely |
00:09:08 | FromDiscord | <Elegantbeef> There is upcasting to `Shape` but no down casting |
00:09:20 | FromDiscord | <Elegantbeef> Shape cannot be safely downcasted it's a type narrowing operation |
00:09:49 | FromDiscord | <Elegantbeef> All circles are shapes but not all shapes are circles |
00:10:21 | FromDiscord | <Robyn [She/Her]> I don't think I understand? Wouldn't you just rely on the `kind` stored in the defined sum type to handle the converter code? |
00:10:32 | FromDiscord | <Elegantbeef> Converters are statically dispatched |
00:10:41 | FromDiscord | <Robyn [She/Her]> Ah |
00:11:22 | FromDiscord | <Robyn [She/Her]> Then, the user would have to explicitly do `Shape.Circle` if they wanted to pass a circle to `area`? |
00:11:27 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=mDqJQBmm |
00:11:29 | FromDiscord | <Elegantbeef> Whoops |
00:11:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=dvJakDrR |
00:11:42 | FromDiscord | <Elegantbeef> Well that's where an `unpack` would come in |
00:11:45 | FromDiscord | <Robyn [She/Her]> (edit) "Then, the user would have to explicitly do `Shape.Circle` if they wanted to pass a circle ... to" added "that was upcasted to a shape" |
00:12:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=TdJbBkBe |
00:12:31 | FromDiscord | <Elegantbeef> So you'd do like `shape.unpackIt(it.area())` |
00:12:53 | FromDiscord | <Robyn [She/Her]> Yeah okay that makes sense, I'm assuming the only reason it isn't implemented is because you don't use fungus often? Or just didn't think of it |
00:13:23 | FromDiscord | <Elegantbeef> Just never got to it |
00:13:53 | FromDiscord | <Robyn [She/Her]> Makes sense, I might add this feature if I procrastinate my project for longer |
00:13:56 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/10836 has a bunch of ramblings from me |
00:14:08 | FromDiscord | <Elegantbeef> Specificaally https://forum.nim-lang.org/t/10836#72416 |
00:15:05 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "https://forum.nim-lang.org/t/10836 has a bunch": Oh wow I actually like that proposed syntax a lot |
00:15:31 | FromDiscord | <Elegantbeef> It's literally fungus but inside a typesection 😄 |
00:17:18 | FromDiscord | <Robyn [She/Her]> Yeah exactly! |
00:17:49 | FromDiscord | <Robyn [She/Her]> Why isn't it just called `sum` instead of `case` or `enum`? |
00:18:23 | FromDiscord | <Elegantbeef> No clue, but sum is a common word |
00:18:32 | FromDiscord | <Elegantbeef> `case` is less of a common word and is already a keyword |
00:18:58 | * | greaser|q quit (Changing host) |
00:18:58 | * | greaser|q joined #nim |
00:19:00 | * | greaser|q is now known as GreaseMonkey |
00:19:31 | FromDiscord | <Robyn [She/Her]> That's a good point |
00:20:20 | FromDiscord | <Elegantbeef> Hey I pretend to know some things about design |
00:38:52 | FromDiscord | <Robyn [She/Her]> Posted a new comment in the thread |
01:07:24 | * | def- quit (Quit: -) |
01:08:41 | * | def- joined #nim |
02:03:41 | * | beholders_eye quit (Ping timeout: 240 seconds) |
02:30:54 | * | krux02 quit (Remote host closed the connection) |
04:00:55 | FromDiscord | <morgan> In reply to @Elegantbeef "<@277133333773811712> are you attempting": i set up tuples with math operations as 2d points and using them to index into an array object (bounds plus 1d ptr uncheckedarray) |
04:05:50 | FromDiscord | <morgan> In reply to @Elegantbeef "https://forum.nim-lang.org/t/10836 has a bunch": what does this actually gain over variant types? it certainly isn’t a replacement as it imposes one axis of variability |
04:33:22 | * | rockcavera quit (Remote host closed the connection) |
04:35:05 | * | rockcavera joined #nim |
04:36:31 | FromDiscord | <Elegantbeef> @morgan It's a more structured approach to variant types |
04:38:26 | FromDiscord | <danielsokil> Hi all |
04:38:41 | FromDiscord | <danielsokil> sent a code paste, see https://play.nim-lang.org/#pasty=tSBUdvff |
04:39:02 | FromDiscord | <danielsokil> sent a code paste, see https://play.nim-lang.org/#pasty=iQyiHnLu |
04:39:19 | FromDiscord | <Elegantbeef> You're not invoking `check` |
04:39:23 | FromDiscord | <Elegantbeef> You're attempting to add ap roc |
04:39:35 | FromDiscord | <danielsokil> Yes, silly me, lol just noticed |
04:40:25 | FromDiscord | <danielsokil> In reply to @Elegantbeef "You're not invoking `check`": Thanks (; |
04:42:27 | FromDiscord | <danielsokil> What is Nims alternative to Go coroutines (goroutines)? |
04:42:40 | FromDiscord | <danielsokil> From my understanding, async is single threaded? |
04:42:43 | FromDiscord | <Elegantbeef> It does not have a good threading story |
04:43:34 | FromDiscord | <danielsokil> Can I do async across multiple threads, safely? |
04:43:49 | FromDiscord | <Elegantbeef> Nope futures must be completed on the thread that made them |
04:45:19 | FromDiscord | <Elegantbeef> So if you want multi threaded async you practically need to send across channels what the thread needs to create a request |
04:46:40 | FromDiscord | <danielsokil> And, these are lightweight threads right? runtime managed |
04:46:58 | FromDiscord | <Elegantbeef> No they're proper threads |
04:52:10 | FromDiscord | <danielsokil> In this example: https://nim-by-example.github.io/parallelism/↵↵`createThread` creates a system thread? |
04:52:26 | FromDiscord | <Elegantbeef> Yes |
04:57:34 | FromDiscord | <nnsee> In reply to @Elegantbeef "You're not invoking `check`": am i missing messages here? to me it looks like he just said hi and you already knew the solution to his problem |
04:57:58 | FromDiscord | <nnsee> https://media.discordapp.net/attachments/371759389889003532/1243790140497858600/Screenshot_20240525-075736_Firefox2.png?ex=6652c155&is=66516fd5&hm=36d9698d12a35ec8136e44c7aa5f9ae163fe8733bd0be564a58f44ed885e2cad& |
04:58:06 | FromDiscord | <nnsee> something like this happened yesterday as well |
04:58:14 | FromDiscord | <Elegantbeef> They did the wrong thing and they deleted their messages |
04:58:19 | FromDiscord | <nnsee> oh |
04:58:20 | FromDiscord | <Elegantbeef> People are bad people |
05:00:22 | FromDiscord | <danielsokil> 😝 |
05:01:31 | FromDiscord | <nnsee> some day i _will_ catch beef in the act of clairvoyance |
05:02:35 | FromDiscord | <danielsokil> What is the default GC in Nim2? |
05:02:44 | FromDiscord | <Elegantbeef> No matter how many crystals I put in my pooper I never get any magic |
05:02:54 | FromDiscord | <Elegantbeef> Nim 2.0 uses Orc |
05:03:11 | FromDiscord | <Elegantbeef> Which is move semantics with destructors and a mark and sweep cycle collector |
05:06:57 | FromDiscord | <nnsee> arc is just orc without the mark & sweep, right? |
05:07:34 | FromDiscord | <odexine> pretty much |
05:08:20 | FromDiscord | <danielsokil> sent a code paste, see https://play.nim-lang.org/#pasty=czvJJleu |
05:08:49 | FromDiscord | <Elegantbeef> You need to do `let ipAddress = ipAddress` before to remove the `lent` and copy it |
05:08:57 | FromDiscord | <Elegantbeef> It's an annoying part about `lent T` |
05:09:44 | FromDiscord | <danielsokil> what is a lent string? |
05:09:48 | FromDiscord | <danielsokil> In there a lender? |
05:10:07 | FromDiscord | <morgan> In reply to @Elegantbeef "<@277133333773811712> It's a more": ah ok |
05:10:12 | FromDiscord | <danielsokil> (edit) "In" => "Is" |
05:10:45 | FromDiscord | <Elegantbeef> `lent` is a non copy reference |
05:11:07 | FromDiscord | <danielsokil> Okay, a pointer |
05:11:16 | FromDiscord | <Elegantbeef> Well no |
05:11:19 | FromDiscord | <Elegantbeef> Cause we have pointers 😄 |
05:12:10 | FromDiscord | <Elegantbeef> But yes the implementation is that it's a safe pointer |
05:12:20 | FromDiscord | <danielsokil> In reply to @Elegantbeef "You need to do": So with this, we can explicitly copy |
05:12:54 | FromDiscord | <Elegantbeef> Well a copy is made whenever you make `lent` a "R value" |
05:13:33 | FromDiscord | <danielsokil> Could I get the underlying pointer to `ipAddress`? |
05:13:58 | FromDiscord | <Elegantbeef> `addr` does that |
05:15:54 | FromDiscord | <danielsokil> What about pntr value? |
05:16:37 | FromDiscord | <Elegantbeef> Huh? |
05:18:02 | FromDiscord | <danielsokil> Ah, `repr` gets it done |
05:18:30 | FromDiscord | <Elegantbeef> Ah do you mean "how does one dereference"? 😄 |
05:19:48 | FromDiscord | <danielsokil> Yes |
05:20:03 | FromDiscord | <Elegantbeef> `[]` |
05:20:50 | FromDiscord | <danielsokil> sent a code paste, see https://play.nim-lang.org/#pasty=kDLMewzz |
05:20:58 | FromDiscord | <morgan> ptr and ref are pointers (ref is just managed). lent afaik is an annotation to handle compilation |
05:21:34 | FromDiscord | <Elegantbeef> Well we have references of three variety and they're all type annotations |
05:22:12 | FromDiscord | <Elegantbeef> `lent T` is valid only as a return type, `var T` is valid as parameters and return type. `ref T` is a heap allocated `T` that is automatically managed |
05:22:42 | FromDiscord | <morgan> ah interesting i didn't know lent was only as returns |
05:24:04 | FromDiscord | <danielsokil> Do we have a decent AES lib, specifically one that supports ECB mode |
05:25:04 | FromDiscord | <danielsokil> Block padding, etc |
05:29:51 | FromDiscord | <morgan> In reply to @morganalyssa "i set up tuples": ok so copying the procs into the file makes it compile |
05:34:31 | * | SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev) |
06:00:39 | * | SchweinDeBurg joined #nim |
06:30:46 | * | beholders_eye joined #nim |
06:35:32 | * | beholders_eye quit (Ping timeout: 268 seconds) |
06:40:09 | FromDiscord | <codic> is it possible to stop nimble from checking all the dependnceies of a project upon compilation |
06:40:17 | FromDiscord | <codic> and printing them |
06:46:39 | FromDiscord | <kots> `nimble setup` and then use `nim` directly |
06:46:46 | FromDiscord | <kots> nimble users might be able to give you a "better" answer |
07:52:48 | * | derpydoo joined #nim |
08:01:53 | FromDiscord | <dawidek.2137> nim doc about bind statement:↵"But a bind is rarely useful because symbol binding from the definition scope is the default."↵↵So when is it actually useful if it's the default? |
08:04:42 | FromDiscord | <dawidek.2137> also I don't see how it's the default... I need to import `tables` to use my template that calls `tables.contains` from another file, so I'm getting confused |
08:07:21 | FromDiscord | <dawidek.2137> ok, I see, the compiler only chimps out if I call `notin` which implicitly refers to `tables.contains`, if I call `contains` directly there is no problem |
08:07:32 | FromDiscord | <dawidek.2137> is it necessary to avoid notin etc? |
08:11:01 | FromDiscord | <Elegantbeef> `bind` is default when there is no overloaded symbol |
08:12:54 | FromDiscord | <dawidek.2137> makes sense, but what about the `notin` problem? |
08:13:31 | FromDiscord | <dawidek.2137> tables.`[]=` also doesn't get picked up in my template call unless I import tables in the file where the template gets called |
08:13:46 | FromDiscord | <Elegantbeef> `mixin` |
08:14:05 | FromDiscord | <Elegantbeef> Templates are expanded late so you need to either use `contains` or `mixin` |
08:15:57 | FromDiscord | <dawidek.2137> doesn't mixin do the opposite of what I want? |
08:16:45 | FromDiscord | <dawidek.2137> which is to bind notin to whatever it was defined as in the file where the template was defiend |
08:18:05 | FromDiscord | <Elegantbeef> You do not want to bind `notin` you want to bind `contains` |
08:18:22 | FromDiscord | <Elegantbeef> `mixin` accepts both scope of declaration and instantiation scope |
08:18:52 | FromDiscord | <Elegantbeef> `notin` is a template that does `not(contains(x, y))` |
08:19:06 | FromDiscord | <Elegantbeef> Though it's untyped so should be exanded at declaration |
08:25:17 | FromDiscord | <dawidek.2137> sent a code paste, see https://play.nim-lang.org/#pasty=AGKRKrJu |
08:25:30 | FromDiscord | <dawidek.2137> also `mixin contains` etc |
08:25:53 | FromDiscord | <Elegantbeef> Do you have a min repro? |
08:26:59 | FromDiscord | <dawidek.2137> I'll try to make one |
08:28:59 | FromDiscord | <dawidek.2137> sent a code paste, see https://play.nim-lang.org/#pasty=ftezKBQj |
08:30:25 | FromDiscord | <Elegantbeef> Oh you're using a template |
08:31:46 | FromDiscord | <Elegantbeef> Because this is a template it does not expand `notin` until it's instantiated, as such your `bind` or `mixin` contains goes on deaf ears |
08:32:48 | FromDiscord | <Elegantbeef> Symbol resolution and symbol opening is a fun thing with templates |
08:38:52 | FromDiscord | <dawidek.2137> 💩 |
08:40:07 | FromDiscord | <Elegantbeef> I can only say "Only use a template where it makes sense" |
09:36:13 | * | derpydoo quit (Ping timeout: 268 seconds) |
09:53:35 | * | ntat joined #nim |
10:21:58 | * | derpydoo joined #nim |
10:25:33 | * | ntat quit (Quit: Leaving) |
11:15:35 | * | def- quit (Quit: -) |
11:15:52 | * | def- joined #nim |
11:27:31 | * | derpydoo quit (Ping timeout: 260 seconds) |
11:30:21 | FromDiscord | <tauruuuuuus> Soooo I'm not sure I'm doing something wrong there, but it seems like I can't evaluate untyped stuff in macros at compile time? Is it right? |
11:33:21 | * | def- quit (Quit: -) |
11:34:35 | * | def- joined #nim |
11:34:57 | * | dtomato quit (Quit: The Lounge - https://thelounge.chat) |
11:35:26 | * | dtomato joined #nim |
11:37:14 | FromDiscord | <dawidek.2137> I think so |
11:38:42 | FromDiscord | <dawidek.2137> (besides "evaluating" it in a quote as a compile time expression, but you obviously can't get the result as anything but a NimNode) |
11:39:43 | * | def- quit (Quit: -) |
11:40:12 | * | def- joined #nim |
11:48:56 | FromDiscord | <ninovanhooff> Is float multiplication faster, slower or equal to float division? ie. is there a performance difference between `a0.5` and `a/2.0`? |
11:51:24 | FromDiscord | <odexine> mult is faster but often is not the main bottleneck |
12:01:59 | * | def- quit (Quit: -) |
12:04:03 | FromDiscord | <Phil> In reply to @tauruuuuuus "Soooo I'm not sure": Define "evaluating".↵If you want to access the types etc. you'll need to use typed |
12:04:07 | FromDiscord | <Phil> (edit) removed "the" |
12:21:49 | * | def- joined #nim |
12:29:29 | * | dtomato quit (Quit: The Lounge - https://thelounge.chat) |
12:34:37 | * | dtomato joined #nim |
13:07:23 | FromDiscord | <dmisener> Fungus |
13:08:24 | FromDiscord | <dmisener> Please ignore above - finger fumble |
13:23:22 | * | def- quit (Quit: -) |
13:24:24 | * | def- joined #nim |
13:47:00 | * | dtomato quit (Quit: The Lounge - https://thelounge.chat) |
13:47:28 | * | dtomato joined #nim |
14:19:11 | * | beholders_eye joined #nim |
14:19:52 | FromDiscord | <System64 ~ Flandre Scarlet> Is it possible to get Nim autocompletion, errors and so on in neovim? |
14:20:55 | FromDiscord | <kots> Yes, I use nimlangserver with nvim-lspconfig |
14:24:55 | FromDiscord | <Robyn [She/Her]> In reply to @dmisener "Fungus": Fungus is a good Nim library :) |
14:37:47 | * | beholders_eye quit (Ping timeout: 264 seconds) |
14:43:02 | * | lucasta joined #nim |
15:06:17 | FromDiscord | <goerge_lsd> http://marcio.io/2015/07/calculating-multiple-file-hashes-in-a-single-pass/ |
15:06:35 | FromDiscord | <goerge_lsd> Can this be easily done in nim ? Calculate various checksums in a single pass |
15:07:05 | FromDiscord | <dawidek.2137> silly idea, but can I magically make my enums be backed up by strings on js backend without modifying the compiler? 🤫 |
15:07:23 | FromDiscord | <dawidek.2137> i want to more easily see what's up when printing objects in browser console |
15:07:32 | FromDiscord | <Robyn [She/Her]> In reply to @dawidek.2137 "silly idea, but can": What do you mean backed up by strings? |
15:07:36 | FromDiscord | <Robyn [She/Her]> Do you mean a string representation for it? |
15:07:42 | FromDiscord | <dawidek.2137> they are numbers in js after compilation |
15:07:52 | FromDiscord | <dawidek.2137> when you console.log from the console etc |
15:09:15 | FromDiscord | <dawidek.2137> I know I can use use typed constants to fake enum semantics etc but then I lose exhaustiveness checks in case statements |
15:13:02 | FromDiscord | <juancarlospaco> Enum can have string values. |
15:14:17 | FromDiscord | <juancarlospaco> (edit) "values." => "values, or make a $ for it." |
15:14:29 | FromDiscord | <goerge_lsd> why is md5 proc for string https://nim-lang.org/docs/md5.html#getMD5%2Cstring while sha1 is for openArray[char] ? https://nim-lang.org/docs/sha1.html#secureHash%2CopenArray%5Bchar%5D |
15:15:36 | FromDiscord | <juancarlospaco> openarray char takes string too. |
15:15:39 | FromDiscord | <goerge_lsd> Didn't these docs used to have links to proc source on github ? |
15:15:47 | FromDiscord | <goerge_lsd> i know, but why the inconsistency |
15:16:36 | FromDiscord | <juancarlospaco> both take string. |
15:17:32 | FromDiscord | <juancarlospaco> openarray sometimes can be used for some optimizations in the code. |
15:17:44 | FromDiscord | <goerge_lsd> @juancarlospaco I am looking to see if you can create various checksums of a file in one pass, without reaing the file from disk many times |
15:18:06 | FromDiscord | <goerge_lsd> found an example in go, somehow that is possible there, because of the common interface used by the checksum code |
15:18:25 | FromDiscord | <goerge_lsd> (edit) "reaing" => "reading" |
15:18:51 | FromDiscord | <Robyn [She/Her]> In reply to @juancarlospaco "Enum can have string": That doesn't seem to implement it for the JS backend, which is what dawidek wants |
15:18:59 | FromDiscord | <goerge_lsd> I got an idea of a project, to make an overlay fs-like interface, to access file on disk based on their checksum, instead of path |
15:19:18 | FromDiscord | <Robyn [She/Her]> @dawidek.2137 you can emit code for the JS backend specifically if wanted, why not try that? |
15:19:20 | FromDiscord | <goerge_lsd> so you can move things aroun and your app will still work |
15:19:38 | FromDiscord | <goerge_lsd> (edit) "aroun" => "around" | "aroundand your app will still work ... " added "(if it uses such an interface)" |
15:19:55 | FromDiscord | <juancarlospaco> In reply to @chronos.vitaqua "That doesn't seem to": You can use cstring if you want to see the actual literal string, otherwise is an array of int in the JS. |
15:20:12 | FromDiscord | <goerge_lsd> guess I need to wait for the bot with dog head avatar to come back : P |
15:20:13 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "I got an idea": Issue with that is obviously files can change |
15:20:27 | FromDiscord | <Robyn [She/Her]> In reply to @juancarlospaco "You can use cstring": Ah that is a good idea yeah |
15:20:57 | FromDiscord | <goerge_lsd> @Robyn [She/Her] of course, it would need to be run as a deamon, to record when last change was saved, use inotify to track changes on fs etc |
15:21:53 | FromDiscord | <goerge_lsd> but for what I want to use it, files won't really change. Sort of like an IPFS storage, content addressable. Only it would also work locally |
15:22:23 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "<@524288464422830095> of course, it": Fair enough, but I still don't see a practical application of it, since if you're using inotify anyway, you can simply map files to a virtual path using fuse |
15:22:52 | FromDiscord | <goerge_lsd> I don't want to use FUSE though, it's not really portable to windows |
15:23:01 | FromDiscord | <Robyn [She/Her]> Ah it isn't? Didn't know that |
15:23:09 | FromDiscord | <goerge_lsd> there's some fuse-like thing on windows.. dokan ? |
15:23:23 | FromDiscord | <Robyn [She/Her]> Either way, it can still be done without fuse with a custom API that you would've implemented anyway |
15:23:28 | FromDiscord | <goerge_lsd> although i'd like to look into your idea as well, didn't consider this |
15:23:58 | FromDiscord | <goerge_lsd> but let's say daemon didn't run while some change to FS was done, and you renamed a file.. |
15:24:16 | FromDiscord | <goerge_lsd> can you still access that file based on a known.. file node id or whatever it's called |
15:24:19 | * | beholders_eye joined #nim |
15:24:30 | FromDiscord | <goerge_lsd> inode |
15:25:19 | FromDiscord | <Robyn [She/Her]> I have no idea, but if you could, wouldn't that still make a checksum-based API for file lookup useless? |
15:26:04 | FromDiscord | <goerge_lsd> I guess it would for this use case |
15:26:11 | FromDiscord | <goerge_lsd> well, no, it wouldn't |
15:26:23 | FromDiscord | <goerge_lsd> you'd ideally want to map known files with already existing stuff on your disk |
15:26:40 | FromDiscord | <saint.___.> In reply to @sys64 "Is it possible to": Ya you can! Although it's not the best atm |
15:26:58 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "you'd ideally want to": Fair enough |
15:36:20 | * | beholders_eye quit (Read error: Connection reset by peer) |
15:36:29 | * | def- quit (Quit: -) |
15:38:07 | FromDiscord | <goerge_lsd> so back to the original issue, any design ideas on how to make a single pass file read, multiple checksums compute ? |
15:40:56 | FromDiscord | <goerge_lsd> looks like checksum algos can be run sequantlly on the input data? |
15:41:11 | FromDiscord | <goerge_lsd> https://github.com/nim-lang/checksums/blob/7ff0b762332d2591bbeb65df9bb86d52ea44ec01/src/checksums/md5.nim#L312 |
15:41:51 | * | beholders_eye joined #nim |
15:43:28 | FromDiscord | <goerge_lsd> `proc md5Update(c: var MD5Context, input: openArray[uint8]) =`↵`proc update(ctx: var Sha1State, data: openArray[char]) =` |
15:43:57 | FromDiscord | <goerge_lsd> naming inconsistencies, data type inconsistencies.. or is `openArray[uint8]` perfectly equivalent to `openArray[char]`? don't think so |
15:47:45 | FromDiscord | <threefour> I imagine they'd use the 8 bits the same way though. |
15:49:15 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @saint.___. "Ya you can! Although": And does it still work well? |
16:13:28 | * | def- joined #nim |
16:15:02 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=jBJIZLdg |
16:15:48 | FromDiscord | <goerge_lsd> kinda ambiguous if you wanna import it |
16:18:50 | FromDiscord | <goerge_lsd> can you rename it somehow ? |
16:20:39 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "naming inconsistencies, data type": A char is just a byte, and a byte is just a uint8 in Nim |
16:21:33 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=lwJOWgEx |
16:21:40 | FromDiscord | <goerge_lsd> this works, but can it be done in a shorter way ? |
16:21:49 | FromDiscord | <goerge_lsd> not needing a separate import maybe |
16:23:33 | FromDiscord | <juancarlospaco> In reply to @goerge_lsd "naming inconsistencies, data type": https://github.com/nim-lang/Nim/blob/daad06bd07ff11cc2b0c74b604ff82899e923d59/lib/system/basic_types.nim#L22 |
16:24:44 | FromDiscord | <goerge_lsd> anyway, how would you suggest defining an object that can hold various hash digests/checksums ? |
16:26:58 | FromDiscord | <juancarlospaco> Use a simpler hash for file checksums, like just a CRC. |
16:27:29 | FromDiscord | <goerge_lsd> bcrypt digest is array of uint8, md5 is uint8, sha1 is uint8, sha2 is array of char, sha3 also array of char |
16:27:31 | FromDiscord | <juancarlospaco> Implement with that, then you can scale up complexities. |
16:27:44 | FromDiscord | <goerge_lsd> @juancarlospaco thanks but that's not what I want to implement |
16:28:28 | FromDiscord | <goerge_lsd> I want to make a small lib that can hash different algos in one run |
16:35:09 | * | def- quit (Quit: -) |
16:35:37 | * | lucasta quit (Quit: Leaving) |
16:37:22 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=QQfNvnas |
16:37:40 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=eFPWVKrv |
16:37:52 | FromDiscord | <goerge_lsd> I think this would need the object holding the value to be generic, no ? |
16:53:24 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=grTFOmeJ |
16:53:45 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "anyway, how would you": You could use a case object if wanted |
16:54:07 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "bcrypt digest is array": Why not just store them all as `seq[byte]`? |
16:54:26 | * | def- joined #nim |
16:54:47 | FromDiscord | <goerge_lsd> sent a code paste, see https://paste.rs/hGgDx |
16:55:02 | FromDiscord | <goerge_lsd> (edit) "https://paste.rs/sIGMW" => "https://play.nim-lang.org/#pasty=jemzHsUg" |
16:55:45 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=wPnuibSo |
16:56:38 | FromDiscord | <goerge_lsd> In reply to @chronos.vitaqua "Why not just store": I was just showing how the code is in the checksums module.. very inconsistent naming |
16:56:43 | FromDiscord | <goerge_lsd> (edit) "In reply to @chronos.vitaqua "Why not just store": I was just showing how the code is in the checksums module.. very inconsistent naming ... " added "and types used" |
16:57:06 | FromDiscord | <goerge_lsd> (edit) "used" => "used. Maybe different devs worked on it and there was no consensus on the common interface" |
16:57:46 | FromDiscord | <Robyn [She/Her]> That could be a possibility, yeah |
16:57:58 | FromDiscord | <Robyn [She/Her]> You could make your own wrapper over those interfaces, perhaps? |
16:58:31 | FromDiscord | <goerge_lsd> not a big problem at the moment, I think |
16:59:04 | FromDiscord | <goerge_lsd> In reply to @chronos.vitaqua "You could use a": yes but I can have an arbitrary numbers of types of checksums stored there, variant objects don't help here ? |
16:59:24 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=TviSTpJV |
17:00:15 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "yes but I can": Not sure what you mean, I don't use hashing algorithms so I don't know the specifics besides different types being annoying |
17:00:54 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=YqVHxzBX |
17:01:57 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=kxuLKlyJ |
17:04:46 | FromDiscord | <goerge_lsd> well, I guess, but that doesn't help my problem.. how to store arbitrary number of them |
17:05:38 | FromDiscord | <goerge_lsd> also how to "cast" a `distinct string` as `string`? |
17:05:51 | FromDiscord | <goerge_lsd> `Path` type doesn't have a `$` proc, so annoying |
17:07:33 | FromDiscord | <goerge_lsd> repr ? |
17:08:34 | FromDiscord | <odexine> `string` |
17:12:14 | FromDiscord | <goerge_lsd> maybe I should use a table instead of object, to store `key: HashType`, `value: seq[byte]` ? |
17:13:03 | FromDiscord | <goerge_lsd> although that is kind of overkill for jus 11 possible key values |
17:14:00 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=qjPZPTxb |
17:14:36 | * | Guest8054 joined #nim |
17:14:49 | * | def- quit (Quit: -) |
17:15:02 | * | def-- joined #nim |
17:15:26 | * | def-- is now known as def- |
17:20:05 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=zaAwQbfe |
17:23:13 | * | xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1 - https://znc.in) |
17:29:41 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=QUqcDKaO |
17:29:58 | FromDiscord | <@@prestosilver> got a stupid question, are all refs the same size (like pointers) or do they store more than just a pointer and gc stuff |
17:30:16 | FromDiscord | <@@prestosilver> like is it safe to do something like this |
17:31:31 | FromDiscord | <griffith1deadly> In reply to @prestosilver "got a stupid question,": ref itself just pointer, but managed |
17:31:42 | FromDiscord | <griffith1deadly> so sizeof(ref) == sizeof(ptr) |
17:31:44 | FromDiscord | <@@prestosilver> o ok |
17:32:07 | FromDiscord | <@@prestosilver> good thing you knew that bc idk how to write the example i was gonna give lmao |
17:32:21 | FromDiscord | <Robyn [She/Her]> In reply to @griffith1deadly "so sizeof(ref) == sizeof(ptr)": It's `pointer` not `ptr` but yeah |
17:32:47 | FromDiscord | <griffith1deadly> In reply to @chronos.vitaqua "It's `pointer` not `ptr`": in that context u also can't use ref |
17:32:53 | FromDiscord | <griffith1deadly> (edit) "ref" => "`ref`" |
17:33:00 | FromDiscord | <@@prestosilver> essentially i just wanted make an enum array of refs, but i need to mix types is that possible even lol |
17:33:13 | FromDiscord | <@@prestosilver> without inheratance bc that would break stuff in this contexrt |
17:33:16 | FromDiscord | <@@prestosilver> (edit) "contexrt" => "context" |
17:33:36 | FromDiscord | <@@prestosilver> like mixed refs |
17:33:56 | FromDiscord | <@@prestosilver> eh might be cleaner to just use an object, ignore that |
17:35:12 | FromDiscord | <Robyn [She/Her]> In reply to @griffith1deadly "in that context u": True, it'd be `ref object` |
17:35:36 | FromDiscord | <Robyn [She/Her]> In reply to @prestosilver "essentially i just wanted": Enum array of refs? What do you mean? |
17:35:53 | FromDiscord | <Robyn [She/Her]> In reply to @prestosilver "eh might be cleaner": Have you looked at object variants? Might fit the usecase |
17:36:30 | FromDiscord | <griffith1deadly> i love Nim so much that I use it to write the backend for my thesis, despite all the pain of using nimsuggest :nim1: |
17:37:25 | FromDiscord | <Robyn [She/Her]> Nim is a great language :) |
17:39:01 | FromDiscord | <@@prestosilver> yea, its hard to explain without just explaining the whole thing, basically writing a hardcoded plugin management library (essentially dlc but for programs) and I wanted a way of storing a global reference to each plugin (a .so/.dll library) instance in the main program, I already have a enum with each plugin id but I need a better way of storing the refs to each plugin. |
17:39:17 | FromDiscord | <@@prestosilver> I think inheratance might endup being the way to go |
17:39:26 | FromDiscord | <@@prestosilver> (edit) "endup being" => "have to be" |
17:40:19 | FromDiscord | <Robyn [She/Her]> In reply to @prestosilver "yea, its hard to": A table of ref objects could work fine here as long as you remember to cast them to the appropriate type for each object |
17:40:45 | FromDiscord | <@@prestosilver> is ref object a valid thing outside of object definitions |
17:40:51 | FromDiscord | <Robyn [She/Her]> You can store `ref object` I believe, not sure how safe it is though |
17:41:03 | FromDiscord | <Robyn [She/Her]> In reply to @prestosilver "is ref object a": Yeah it is, it's used in generics often, for example |
17:41:09 | FromDiscord | <@@prestosilver> ah |
17:41:12 | FromDiscord | <@@prestosilver> might try that |
17:41:21 | FromDiscord | <Robyn [She/Her]> Good luck! |
17:41:36 | FromDiscord | <griffith1deadly> In reply to @chronos.vitaqua "Nim is a great": but nimsuggest.. |
17:41:42 | FromDiscord | <@@prestosilver> In reply to @chronos.vitaqua "Good luck!": lol im gonna need it |
17:42:06 | FromDiscord | <mikaelashipha> Hey guys, I'm kinda new to the language and wanted to start with it, but having trouble of finding text editor for it |
17:42:07 | FromDiscord | <griffith1deadly> In reply to @griffith1deadly "but nimsuggest..": even vs intellisence better |
17:42:11 | FromDiscord | <Robyn [She/Her]> In reply to @griffith1deadly "but nimsuggest..": Yeah it probably needs a rewrite |
17:42:24 | FromDiscord | <Robyn [She/Her]> In reply to @mikaelashipha "Hey guys, I'm kinda": Have you tried Visual Studio Code? It's my go to |
17:42:40 | FromDiscord | <mikaelashipha> Yea, no.. anything but vs code |
17:42:43 | FromDiscord | <griffith1deadly> visual studio code & sublime text |
17:43:06 | FromDiscord | <mikaelashipha> I checked sublime lsp language servers and didn't saw nim there |
17:43:14 | FromDiscord | <mikaelashipha> Is there support for it in sublime? |
17:43:18 | FromDiscord | <abaer> vscodium is what i use. |
17:43:36 | FromDiscord | <Robyn [She/Her]> In reply to @mikaelashipha "Is there support for": There's Nimline but idk how up-to-date it is |
17:44:34 | FromDiscord | <mikaelashipha> So currently it's only vs code? |
17:44:46 | FromDiscord | <griffith1deadly> https://github.com/nim-lang/langserver?tab=readme-ov-file#sublime-text |
17:45:41 | FromDiscord | <Robyn [She/Her]> In reply to @mikaelashipha "So currently it's only": There's plugins for multiple editors ofc, but afaik most here use VSC↵Here's the official Sublime plugin for Nim: https://github.com/nim-lang/NimLime |
17:46:14 | FromDiscord | <abaer> Pretty sure vscodium also has an extension for nim as well. |
17:46:56 | FromDiscord | <Robyn [She/Her]> In reply to @abaer "Pretty sure vscodium also": It's the same one used for VSC, it's just not on the OpenVSX registry |
17:46:56 | FromDiscord | <mikaelashipha> In reply to @chronos.vitaqua "There's plugins for multiple": Hmmm, for some reason the sublime lsp language support list didn't mention this, well give it a shot |
17:47:26 | FromDiscord | <Robyn [She/Her]> Good luck! |
17:47:35 | * | def- quit (Quit: -) |
17:47:46 | * | def- joined #nim |
17:47:49 | FromDiscord | <abaer> Yeah. Hate the damn ide but geany lacks most functionality to sanely manage and code large projects.↵(@Robyn [She/Her]) |
17:48:01 | FromDiscord | <mikaelashipha> I just came here base on people's recommendation about cli languages and it seems nim is suitable one too |
17:48:50 | FromDiscord | <mikaelashipha> Im really into cli programming and I don't really like the popular options and rather to use less popular ones and less known languages |
17:49:05 | FromDiscord | <Robyn [She/Her]> In reply to @abaer "Yeah. Hate the damn": That's unfortunate, oh well |
17:49:24 | FromDiscord | <Robyn [She/Her]> In reply to @mikaelashipha "Im really into cli": Understandable, you may find libraries like cligen pretty nice in that case |
17:50:00 | FromDiscord | <Robyn [She/Her]> https://github.com/c-blake/cligen |
17:50:06 | FromDiscord | <nnsee> In reply to @mikaelashipha "Im really into cli": welcome! |
17:50:13 | FromDiscord | <Robyn [She/Her]> There's also argparse and parseopt |
17:50:36 | FromDiscord | <nnsee> Nim is very powerful for cli programming, I highly recommend cligen as well |
17:51:48 | FromDiscord | <mikaelashipha> Before that, while u guys are here might I ask them right now, nim is compiled language right? It produces binary and executable? |
17:52:06 | FromDiscord | <mikaelashipha> Also does it have an option for cross compiling like go and zig? |
17:52:12 | FromDiscord | <sOkam! 🫐> In reply to @mikaelashipha "Before that, while u": yes |
17:52:14 | FromDiscord | <nnsee> yes and yes |
17:52:17 | FromDiscord | <griffith1deadly> In reply to @mikaelashipha "Also does it have": u can use zigcc as compiler |
17:52:23 | FromDiscord | <mikaelashipha> Or it's more of traditional approach of compiling on target os? |
17:52:26 | FromDiscord | <sOkam! 🫐> In reply to @mikaelashipha "Also does it have": yes, but tricky. I created `confy` for that reason, if you want to take a look |
17:52:29 | FromDiscord | <sOkam! 🫐> it cross compiles easily |
17:53:10 | FromDiscord | <mikaelashipha> As long as it makes the cross compiling easy and I can simply produce windows binary or Mac or vice versa |
17:53:12 | FromDiscord | <sOkam! 🫐> confy uses the `zigcc` package, but automates the process. otherwise you can also use zigcc in your nimble file |
17:53:25 | FromDiscord | <sOkam! 🫐> In reply to @mikaelashipha "As long as it": yes, definitely doable. I do it all the time |
17:53:58 | FromDiscord | <mikaelashipha> In reply to @mikaelashipha "Or it's more of": I mean windows binary on Mac and vice versa |
17:54:29 | FromDiscord | <sOkam! 🫐> In reply to @mikaelashipha "Or it's more of": it uses GCC or CLANG, and it provides tools to define the CPU and OS. but then you need a backend to cross compile the resulting backend easily↵that is what the zigcc package simplifies, as you may know from zig |
17:54:42 | FromDiscord | <mikaelashipha> In reply to @heysokam "yes, definitely doable. I": Then I guess I'm officially a nim user |
17:54:53 | FromDiscord | <sOkam! 🫐> so definitely not the "traditional" way you might be thinking from C |
17:55:39 | FromDiscord | <sOkam! 🫐> In reply to @mikaelashipha "Then I guess I'm": welcome aboard! nim is great for many many reasons. you will see for yourself 🙂 |
17:56:14 | FromDiscord | <sOkam! 🫐> the cleanliness of the syntax, even with big messy codebases, is just 🤤 |
17:56:58 | FromDiscord | <mikaelashipha> In reply to @heysokam "the cleanliness of the": I will be the judge of that 😛 |
17:57:13 | FromDiscord | <sOkam! 🫐> fair point 🙂 |
17:57:25 | FromDiscord | <the_real_hypno> https://tenor.com/view/wolf-of-wall-street-jordan-belfort-leonardo-di-caprio-one-of-us-jonah-hill-gif-5441859 |
17:57:38 | FromDiscord | <sOkam! 🫐> but yea, its really hard to make nim look ugly/unreadable, even when actively trying |
17:58:01 | FromDiscord | <the_real_hypno> In reply to @heysokam "but yea, its really": Hold my beer |
17:58:49 | FromDiscord | <sOkam! 🫐> In reply to @the_real_hypno "Hold my beer": relax, warrior. its already done. any of my codebases will trigger the hell out of everyone here 😂 |
17:58:53 | FromDiscord | <sOkam! 🫐> hahaha |
17:59:07 | FromDiscord | <abaer> i assure you as a terrible programmer i can make nim look ugly and like an 8 year old first learned how to type on a keyboard.↵(@sOkam! 🫐) |
17:59:15 | FromDiscord | <the_real_hypno> Na just kidding, the editor will make me suffer big times 😅 |
17:59:19 | FromDiscord | <Robyn [She/Her]> The Nim compiler is not having fun with ADT enums and my code... Oof |
17:59:51 | FromDiscord | <abaer> have you tried asking nicely and offering a blood sacrifice?↵(@Robyn [She/Her]) |
18:00:09 | FromDiscord | <sOkam! 🫐> ^ also try rebooting your computer first |
18:00:15 | FromDiscord | <sOkam! 🫐> it fixes all |
18:00:19 | FromDiscord | <sOkam! 🫐> :kappa: |
18:00:35 | FromDiscord | <the_real_hypno> You just gotta give Araq a Schnitzel |
18:00:41 | FromDiscord | <the_real_hypno> No blood needed |
18:02:09 | FromDiscord | <morgan> so i have a proc which takes a ptr cstring (ptr ptr char in the c code it interfaces with). i need to set the internal pointer to that of a constant. would i be able to do that just by giving the constants the byref pragma or should i make it take ptr ptr char instead or what's the best way to do that? |
18:02:56 | FromDiscord | <Robyn [She/Her]> In reply to @abaer "have you tried asking": Nimsuggest |
18:03:10 | * | def- quit (Quit: -) |
18:03:11 | FromDiscord | <Robyn [She/Her]> Rebooting VSC fixes it until I edit the code again |
18:03:21 | FromDiscord | <Robyn [She/Her]> It's like, a sticky error in Nimsuggest |
18:03:24 | FromDiscord | <morgan> closing and reopening the window has worked for me |
18:03:36 | FromDiscord | <morgan> but i did just killall nimsuggest and restart it |
18:03:39 | FromDiscord | <the_real_hypno> In reply to @morganalyssa "so i have a": You sure about the ptr cstring? |
18:03:53 | FromDiscord | <Robyn [She/Her]> In reply to @morganalyssa "closing and reopening the": Yeah but I'm in the process of editing the code and pkill isn't enough here |
18:04:11 | FromDiscord | <morgan> In reply to @the_real_hypno "You sure about the": i am working with c library code, and its comments say to do that |
18:04:58 | FromDiscord | <the_real_hypno> No clue about the code but my spiderman sense tells me it wants cstring[0].addr |
18:05:20 | FromDiscord | <morgan> oh that looks like it might do it |
18:05:57 | FromDiscord | <the_real_hypno> And it would be ptr char then, which would make more sense |
18:06:03 | FromDiscord | <the_real_hypno> Atleast with the given info |
18:06:08 | FromDiscord | <morgan> prob will be a bit before i can run it and test it |
18:06:31 | FromDiscord | <morgan> sent a code paste, see https://play.nim-lang.org/#pasty=zcLqpVAC |
18:06:49 | FromDiscord | <the_real_hypno> I feel you, since i started interfering with C i start crying if someone uses strings |
18:07:13 | FromDiscord | <the_real_hypno> Uh, it actually is ptr ptr char |
18:07:16 | FromDiscord | <morgan> im writing an abstraction layer (offbeat) and inside that i do use normal strings |
18:07:43 | FromDiscord | <morgan> isn't ptr char the same as cstring? |
18:07:52 | FromDiscord | <morgan> or is cstring const ptr char? |
18:07:54 | FromDiscord | <Robyn [She/Her]> Not in Nim, iirc |
18:07:58 | FromDiscord | <the_real_hypno> It is |
18:08:03 | FromDiscord | <the_real_hypno> Well |
18:08:09 | FromDiscord | <Robyn [She/Her]> It's `UncheckedArray[cchar]` or something |
18:08:31 | FromDiscord | <the_real_hypno> Cstring[0].addr is a pointer to the first char of the array |
18:08:38 | FromDiscord | <morgan> yeah |
18:08:41 | FromDiscord | <Robyn [She/Her]> In reply to @the_real_hypno "It is": It is with even worse type safety :p |
18:08:41 | FromDiscord | <the_real_hypno> But thats ptr char |
18:08:45 | FromDiscord | <the_real_hypno> Not ptr otr |
18:08:54 | FromDiscord | <the_real_hypno> (edit) "otr" => "ptr" |
18:09:18 | FromDiscord | <morgan> i wrote it as ptr cstring |
18:09:33 | FromDiscord | <the_real_hypno> Ye would be correct |
18:09:45 | FromDiscord | <morgan> sent a code paste, see https://play.nim-lang.org/#pasty=UURBCEKG |
18:09:53 | FromDiscord | <the_real_hypno> Somehow my brains wants to advice ptr cstring[0].addr |
18:10:00 | FromDiscord | <the_real_hypno> With a cast |
18:10:20 | FromDiscord | <the_real_hypno> But i wouldn't listen to that fluffy piece of meat |
18:10:26 | FromDiscord | <morgan> well later on when everything else is in enough to test i can see if that satisfies it or not |
18:11:09 | FromDiscord | <dawidek.2137> is there a type for a js array in std/jsffi? |
18:11:14 | FromDiscord | <dawidek.2137> or wherevr |
18:14:23 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=CrwfOGOG |
18:16:21 | FromDiscord | <Robyn [She/Her]> Nimsuggest is hating my code so much right now |
18:16:26 | FromDiscord | <morgan> ah cool thanks |
18:16:42 | FromDiscord | <Robyn [She/Her]> It refuses to launch, it keeps crashing |
18:18:43 | FromDiscord | <Robyn [She/Her]> Ah it hated my union 😔 |
18:18:47 | FromDiscord | <Robyn [She/Her]> Is it a union? |
18:18:58 | FromDiscord | <Robyn [She/Her]> `Identifier | NumLit` (both are `distinct AstNode` |
18:19:01 | FromDiscord | <Robyn [She/Her]> (edit) "AstNode`" => "AstNode`)" |
18:22:58 | * | def- joined #nim |
18:31:27 | FromDiscord | <Robyn [She/Her]> Ugh, native support would be so much better for ADT enums |
18:32:27 | FromDiscord | <goerge_lsd> there is no native support ? |
18:32:33 | FromDiscord | <goerge_lsd> (edit) "no" => "non" |
18:33:43 | FromDiscord | <Robyn [She/Her]> Yeah, via libraries such as https://github.com/metagn/skinsuit or https://github.com/beef331/fungus |
18:34:38 | FromDiscord | <Robyn [She/Her]> They have some limitations though, I was using `fungus` because it looked much nicer, but unfortunately it's a bit painful because it uses a macro for the syntax, which doesn't work with Nim type sections |
18:35:09 | FromDiscord | <Robyn [She/Her]> I wrote a macro to join a type section and ADT enum from `fungus` into one, but it's not working that great |
18:38:21 | FromDiscord | <michaelb.eth> In reply to @goerge_lsd "there is non native": discussion here, also in some linked issues: https://github.com/nim-lang/RFCs/issues/548 |
18:38:50 | FromDiscord | <michaelb.eth> for native, I mean |
18:39:01 | FromDiscord | <morgan> welp guess im going back to fixing up this regex https://media.discordapp.net/attachments/371759389889003532/1243996761782227165/image.png?ex=665381c4&is=66523044&hm=bdc3ceb9e8c641f7a905bfa14e476d4e1778605bfec4d8b3c48e26bd62e5e73d& |
18:39:03 | FromDiscord | <goerge_lsd> is this implemented somewhere or just talk ? |
18:39:22 | FromDiscord | <michaelb.eth> In reply to @goerge_lsd "is this implemented somewhere": just talk at this point |
18:40:09 | FromDiscord | <Robyn [She/Her]> https://forum.nim-lang.org/t/10836 This is a forum thread discussing it too |
18:40:15 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "is this implemented somewhere": Just talk, currently |
18:40:25 | FromDiscord | <goerge_lsd> so we gotta wait for nim3 |
18:40:43 | FromDiscord | <goerge_lsd> or nimskull 1.0 ? : ) |
18:41:07 | FromDiscord | <Robyn [She/Her]> Probably would be implemented as an experimental feature in pre-3.0, if there even is a 3.0 planned |
18:44:59 | FromDiscord | <dawidek.2137> sent a code paste, see https://play.nim-lang.org/#pasty=ESxbJniD |
18:45:04 | FromDiscord | <the_real_hypno> In reply to @morganalyssa "welp guess im going": Where is the regex? 🤔 |
18:45:43 | FromDiscord | <Robyn [She/Her]> In reply to @dawidek.2137 "can i force an": Not sure if you can do that, but why not try placing a doc comment in the function instead? |
18:46:24 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=LBNwCjIh |
18:46:51 | FromDiscord | <morgan> In reply to @the_real_hypno "Where is the regex?": in the nim.json in the nim vscode extension |
18:47:09 | FromDiscord | <morgan> the regex to highlight emits with a list of strings and variables |
18:47:33 | FromDiscord | <the_real_hypno> Oooooh, i was trying really hard to find a regex string in your code 🥲 |
18:48:44 | FromDiscord | <morgan> lol sorry |
18:52:20 | FromDiscord | <dawidek.2137> In reply to @chronos.vitaqua "Not sure if you": I want my typescript tooling to recognize the types and putting the comment inside doesn't seem to make it work |
18:52:59 | * | krux02 joined #nim |
18:53:25 | FromDiscord | <goerge_lsd> so, now I need to fix the inconsistency of nim's checksums module when it comes to byte type used (char or uint). Any ideas ? |
18:53:52 | FromDiscord | <goerge_lsd> I want to use a single proc to upate any kind Hash context with buffer data, which can be openArray[char] or uint8 |
18:54:24 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=vLUrpbbK |
18:57:40 | FromDiscord | <sOkam! 🫐> In reply to @morganalyssa "so i have a": `cstringArray` |
18:59:12 | FromDiscord | <goerge_lsd> hm what about variant objects with same variable name, were they experimental or planned for future? |
18:59:29 | FromDiscord | <morgan> In reply to @heysokam "`cstringArray`": no it only points to one |
18:59:30 | FromDiscord | <sOkam! 🫐> (edit) "`cstringArray`" => "`cstringArray`↵if its not an array of `char `, then please specify the C type you want to generate" |
18:59:39 | FromDiscord | <sOkam! 🫐> oh, i just edited it |
18:59:48 | FromDiscord | <sOkam! 🫐> so whats the type you want in C? no nim syntax |
19:00:38 | FromDiscord | <morgan> sent a code paste, see https://play.nim-lang.org/#pasty=QbxNqPMq |
19:01:21 | FromDiscord | <sOkam! 🫐> is that `char const `, `char const ` or `char const`? |
19:01:36 | FromDiscord | <morgan> that is exactly what is in the c code |
19:01:39 | FromDiscord | <sOkam! 🫐> remember that right-const-rule is fucky |
19:02:24 | FromDiscord | <sOkam! 🫐> In reply to @morganalyssa "that is exactly what": if im not mistaken, thats `char const ` |
19:02:40 | FromDiscord | <sOkam! 🫐> which would be indeed `ptr cstring` |
19:03:04 | FromDiscord | <sOkam! 🫐> but if you want the `const` part mandatory... then you might need to wrap it and use that instead |
19:03:12 | FromDiscord | <sOkam! 🫐> let me search, i had issues with this before. sec |
19:04:11 | FromDiscord | <sOkam! 🫐> @morgan https://github.com/heysokam/wgpu/blob/b88fb2dcf80eda0f94b77c407bf6b3ba6afb95a5/src/wgpu/types.nim#L10-L13 |
19:04:44 | * | def- quit (Quit: -) |
19:04:52 | FromDiscord | <sOkam! 🫐> that's the only way to be truly compatible with C. cstring does not map well sometimes |
19:05:11 | * | def- joined #nim |
19:05:36 | FromDiscord | <sOkam! 🫐> then you do `ptr CString` and it will be mapped to `const char` |
19:06:26 | FromDiscord | <morgan> i so far haven't had issues with cstring anywhere but i'll try to remember it if i do |
19:08:13 | * | def- quit (Client Quit) |
19:08:57 | * | def- joined #nim |
19:08:57 | FromDiscord | <sOkam! 🫐> In reply to @morganalyssa "i so far haven't": you won't if you dont set the C compiler to strict mode. if you do, then coercing `char ` to `char const ` won't be enough |
19:09:09 | FromDiscord | <morgan> ah |
19:09:48 | FromDiscord | <morgan> do i gain anything from strict mode? |
19:11:08 | FromDiscord | <sOkam! 🫐> type safety and UB protection. and if you ever use `zigcc`, it comes with all of that enabled |
19:11:35 | FromDiscord | <morgan> ah ok |
19:14:42 | * | krux02_ joined #nim |
19:17:12 | * | krux02 quit (Ping timeout: 260 seconds) |
19:17:12 | * | beholders_eye quit (Read error: Connection reset by peer) |
19:17:50 | FromDiscord | <Elegantbeef> @goerge_lsd you can do `data: openArray[byte or char]` |
19:18:11 | FromDiscord | <goerge_lsd> I was just thinking about you Beef, if you maybe want some homework 😄 |
19:19:08 | FromDiscord | <goerge_lsd> ok, so I read from file (buffer) as `string`.. what's the best way to conver this to a type that fits in `openArray[byte or char]` ? |
19:19:20 | FromDiscord | <goerge_lsd> (edit) "conver" => "convert" |
19:19:38 | FromDiscord | <Elegantbeef> string is implicitly convertible |
19:19:45 | FromDiscord | <Elegantbeef> `openArray[char]` accepts `string` |
19:20:51 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=kXpduHZj |
19:21:09 | FromDiscord | <goerge_lsd> it matched it to cstring ? |
19:21:39 | FromDiscord | <Elegantbeef> `uint8` is not char |
19:22:21 | FromDiscord | <goerge_lsd> yeah but what can I do about that.. checksums lib has incosistent data types :\ |
19:22:32 | FromDiscord | <goerge_lsd> some use uint8, others char |
19:22:36 | FromDiscord | <Elegantbeef> `string` to `openArray[uint8]` requires explicit conversion using `str.toOpenArrayByte(0, str.high)` |
19:22:45 | FromDiscord | <goerge_lsd> alright then |
19:22:48 | FromDiscord | <Elegantbeef> PR to fix it to use `openArray[char or uint8]` |
19:23:01 | * | beholders_eye joined #nim |
19:23:05 | FromDiscord | <goerge_lsd> @ElegantBeef , what I am trying to do, is write a module that can hash a file or data in a single run, to multiple hasing algos. |
19:23:18 | FromDiscord | <goerge_lsd> Can you take a look and tell me if the code so far makes sense, or could have been done better |
19:24:19 | FromDiscord | <goerge_lsd> https://play.nim-lang.org/#pasty=XEOVPJbw |
19:24:32 | * | xet7 quit (Quit: Leaving) |
19:26:54 | FromDiscord | <goerge_lsd> of course ieally it would be multi threaded, but trying to figure it out for single thread before doing that |
19:27:01 | FromDiscord | <goerge_lsd> (edit) "ieally" => "ideally" |
19:28:00 | FromDiscord | <Elegantbeef> Personally I do not like the usage of the object variant as it means it's not arbitrary hash procedures |
19:28:35 | FromDiscord | <goerge_lsd> what would ElegantBeef do ? |
19:29:04 | FromDiscord | <Elegantbeef> Probably use a tuple of tuples |
19:29:29 | FromDiscord | <Elegantbeef> `((Sha128Context, sha128HashProc), (Md5Context, md5HashProc))` |
19:29:38 | FromDiscord | <Elegantbeef> Then iterate over those doing `hashProc(ctx, data)` |
19:29:54 | FromDiscord | <goerge_lsd> I thought of literally everything but tuples lol |
19:30:50 | FromDiscord | <Elegantbeef> Tuples are just lovely |
19:33:06 | * | xet7 joined #nim |
19:33:50 | FromDiscord | <the_real_hypno> What would ElegantBeef do :kekw: |
19:34:53 | FromDiscord | <goerge_lsd> blah, but `toOpenArrayByte` is not compatible with `openArray[char]` |
19:35:15 | FromDiscord | <Elegantbeef> Right |
19:35:21 | FromDiscord | <Elegantbeef> Just use `openArray[byte or char]` |
19:35:24 | FromDiscord | <Elegantbeef> Or just byte |
19:36:05 | FromDiscord | <goerge_lsd> well I am using that in the proc param, but the hash functions expect either openArray[uint8] or openArray[char] |
19:36:12 | FromDiscord | <goerge_lsd> (edit) "openArray[uint8]" => "`openArray[uint8]`" | "openArray[char]" => "`openArray[char]`" |
19:37:05 | FromDiscord | <goerge_lsd> this is what I hate in nim, this string,byte,uint8 nonsense.. files should be seq of uint8, not char or strings |
19:37:35 | FromDiscord | <Elegantbeef> You're complaining about a non issue |
19:37:49 | FromDiscord | <goerge_lsd> Yeah, skill issue |
19:38:04 | FromDiscord | <goerge_lsd> I think in Go you don't have this problem |
19:38:10 | FromDiscord | <Elegantbeef> You can cast between to get `openArray[char]` |
19:38:43 | FromDiscord | <goerge_lsd> cast at parameter when calling the hash update function ? |
19:38:58 | FromDiscord | <goerge_lsd> default to a type, and cast to the other when needed |
19:41:03 | * | xutaxkamay joined #nim |
19:41:50 | Guest8054 | exit |
19:41:54 | Guest8054 | quite |
19:42:46 | Guest8054 | sorry I failed. |
19:42:49 | * | Guest8054 quit (Quit: WeeChat 4.1.1) |
19:43:46 | FromDiscord | <the_real_hypno> No problem |
19:47:09 | FromDiscord | <Elegantbeef> But yea I'd do something like https://play.nim-lang.org/#pasty=OmczhayR |
19:51:17 | FromDiscord | <Elegantbeef> Actually probably can do `field.Y is char` |
19:54:32 | FromDiscord | <Robyn [She/Her]> Hey Beef, any clue why https://play.nim-lang.org/#pasty=JKIiSPmF causes this error?↵`/home/chronos/Projects/Napkins/src/napkinspkg/parser/types.nim(30, 37) Error: undeclared identifier: 'AstNode'`↵Relevant line is `ProtoIDPair = tuple[proto: ref AstNode, packet: ref AstNode]`, I can't figure out a minimal reproducible example though... |
19:55:18 | FromDiscord | <Elegantbeef> `--expandMacro:adtEnum` |
19:55:58 | FromDiscord | <Elegantbeef> Actually sorry |
19:56:03 | FromDiscord | <Elegantbeef> `--expandMacro: join` |
19:56:14 | FromDiscord | <Elegantbeef> I love that you're asking me to debug your macros, as if I do not have enough |
19:57:17 | FromDiscord | <the_real_hypno> What would ElegantBeef do! |
19:57:51 | FromDiscord | <Robyn [She/Her]> Lol |
19:58:37 | FromDiscord | <Robyn [She/Her]> It's not printing out the AST :/ |
19:58:43 | FromDiscord | <griffith1deadly> you are a macros god |
19:58:47 | FromDiscord | <griffith1deadly> beef |
20:02:10 | FromDiscord | <Elegantbeef> Well robyn time to stop playing around with `join` and use https://play.nim-lang.org/#pasty=CLcBwHxi |
20:02:13 | FromDiscord | <Elegantbeef> type section macro time |
20:13:35 | FromDiscord | <Robyn [She/Her]> I had to step away for a bit so I couldn't modify my macro to print the AST |
20:14:09 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "Well robyn time to": Oh damn, that'd actually be nice |
20:14:13 | FromDiscord | <Robyn [She/Her]> Issue however: |
20:14:16 | FromDiscord | <Robyn [She/Her]> No converters? |
20:15:14 | FromDiscord | <Robyn [She/Her]> And I'm pretty sure it can't define multiple types at once (the enum and the type itself) |
20:15:39 | FromDiscord | <goerge_lsd> `array[char]` to `seq[uint8]` ? |
20:18:08 | FromDiscord | <Robyn [She/Her]> In reply to @goerge_lsd "`array[char]` to `seq[uint8]` ?": You can do `@myArray` to get a `seq[char]` if wanted |
20:18:15 | FromDiscord | <goerge_lsd> that I already knew.. |
20:18:40 | FromDiscord | <Robyn [She/Her]> Then what's the problem? Have you not done `seq[char or uint8` like Beef suggested? |
20:18:50 | FromDiscord | <the_real_hypno> Are you to talking about different topics? |
20:18:58 | FromDiscord | <the_real_hypno> (edit) "to" => "two" |
20:19:33 | FromDiscord | <goerge_lsd> this is different part of the code. I am doing a finalize proc to get the digests, but haven't decided how to store the result yet, so i am reverting to seq[uint8] for everything to check if it's the correct checksum |
20:19:55 | FromDiscord | <goerge_lsd> sent a code paste, see https://play.nim-lang.org/#pasty=DhAKBKhb |
20:20:22 | FromDiscord | <Robyn [She/Her]> So you want to convert a char array to a uint8 seq? |
20:20:27 | FromDiscord | <goerge_lsd> indeed |
20:21:38 | FromDiscord | <Elegantbeef> You can define multiple types at once Robyn |
20:22:21 | FromDiscord | <the_real_hypno> Isnt char defined as uint8? |
20:22:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=WQYQpxTw |
20:22:33 | FromDiscord | <Elegantbeef> No |
20:22:42 | FromDiscord | <Elegantbeef> char is a distinct type to `uint8` |
20:23:09 | FromDiscord | <sOkam! 🫐> In reply to @the_real_hypno "Isnt char defined as": char is `int8` |
20:23:18 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=UiguJgfV |
20:23:30 | FromDiscord | <Robyn [She/Her]> This just requires an explicit conversion |
20:23:44 | FromDiscord | <Robyn [She/Her]> Though casting can be done, it's not advised for reasons I can't remember |
20:24:11 | FromDiscord | <Elegantbeef> No `char` is `char` 😄 |
20:24:42 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "You just need to": Oh damn, I didn't know that! Does this also define `Circle` in a new scope? And can you define templates and converters like this? |
20:25:37 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#pasty=vtQkqgYF |
20:25:42 | FromDiscord | <griffith1deadly> `copyMem` |
20:26:09 | * | def- quit (Quit: -) |
20:26:49 | * | def- joined #nim |
20:27:52 | FromDiscord | <Robyn [She/Her]> Copy mem doesn't work on the JS backend though, so that's something to keep in mind |
20:28:46 | FromDiscord | <Elegantbeef> Yes you can robyn |
20:29:21 | FromDiscord | <Elegantbeef> The issue is that generics do not work as one would intend |
20:30:06 | FromDiscord | <the_real_hypno> `char↵Built-in 8 bit character type (unsigned). ` |
20:30:22 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "The issue is that": Oh? What do you mean? |
20:30:39 | FromDiscord | <Elegantbeef> They do not work |
20:30:50 | FromDiscord | <Robyn [She/Her]> Ah |
20:30:52 | FromDiscord | <Elegantbeef> Generics defined like the above just explode |
20:32:07 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=xrKKFQyk |
20:32:23 | FromDiscord | <Elegantbeef> No it just explodes 😄 |
20:33:40 | FromDiscord | <the_real_hypno> Ok, for real, i totally get that it probably is a distinct type but uint8 and char is still the same!? |
20:33:45 | FromDiscord | <Elegantbeef> https://github.com/beef331/constructor/pull/14 refer to this |
20:38:30 | FromDiscord | <the_real_hypno> ` cuchar {.importc: "unsigned char", nodecl, deprecated: "use `char` or `uint8` instead".} = char` |
20:39:05 | FromDiscord | <the_real_hypno> char or uint8 aren't distinct? |
20:39:34 | FromDiscord | <Elegantbeef> They are |
20:39:37 | FromDiscord | <Elegantbeef> They're magic |
20:39:56 | FromDiscord | <the_real_hypno> Is that implying distinction? |
20:40:31 | FromDiscord | <Elegantbeef> It means the compiler handles their implementation |
20:41:11 | FromDiscord | <Robyn [She/Her]> https://play.nim-lang.org/#pasty=FrYPjSjn this won't even compile for me |
20:41:20 | FromDiscord | <Robyn [She/Her]> `/home/chronos/test/main.nim(4, 17) Error: expected: ')', but got: 'OptionKind'` |
20:42:11 | FromDiscord | <Elegantbeef> Well yea it has to be done through a macro |
20:42:26 | FromDiscord | <Elegantbeef> or template |
20:42:27 | FromDiscord | <the_real_hypno> Meh. Guess I'll just do what ElegantBeef would do |
20:43:48 | FromDiscord | <Robyn [She/Her]> Ah |
20:50:33 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=tZapwvwy |
20:50:48 | FromDiscord | <Elegantbeef> Depend on your code |
20:51:46 | FromDiscord | <Robyn [She/Her]> My code is in the link |
20:52:14 | FromDiscord | <Elegantbeef> I didn't see it |
20:52:14 | FromDiscord | <Elegantbeef> \:d |
20:52:30 | FromDiscord | <Robyn [She/Her]> Oh! |
20:52:32 | FromDiscord | <Robyn [She/Her]> This works! |
20:52:33 | FromDiscord | <Robyn [She/Her]> https://play.nim-lang.org/#pasty=RuwikRbf |
20:52:43 | FromDiscord | <Elegantbeef> "didnt" |
20:53:44 | FromDiscord | <Elegantbeef> Your code works fine if you do it properly |
20:53:49 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=PBPqTeNL |
20:54:02 | FromDiscord | <Robyn [She/Her]> https://play.nim-lang.org/#pasty=wyqGlYyH |
20:54:11 | FromDiscord | <Robyn [She/Her]> Yeah :P |
20:54:17 | FromDiscord | <Robyn [She/Her]> So then, how does it blow up? |
20:54:55 | FromDiscord | <Elegantbeef> I showed you an example and you just disregarded it |
20:54:56 | FromDiscord | <Elegantbeef> So.... |
20:55:37 | FromDiscord | <Elegantbeef> `constructor.defaults` fails to work with generics |
20:56:17 | FromDiscord | <Robyn [She/Her]> Did some messages get skipped on the bridge? Hold on |
20:58:01 | FromDiscord | <Robyn [She/Her]> No it didn't, I don't know where you showed an example tho |
21:01:02 | FromDiscord | <the_real_hypno> https://github.com/beef331/constructor/pull/14 |
21:01:27 | FromDiscord | <the_real_hypno> He referred this |
21:01:59 | FromDiscord | <the_real_hypno> In reply to @Elegantbeef "https://github.com/beef331/constructor/pull/14 refe": ^ |
21:02:47 | FromDiscord | <goerge_lsd> @ElegantBeef http://marcio.io/2015/07/calculating-multiple-file-hashes-in-a-single-pass/ check this out, quite short code to do this in Go |
21:02:48 | FromDiscord | <Robyn [She/Her]> Aaaah |
21:03:01 | FromDiscord | <Elegantbeef> Cool it's Go |
21:03:12 | FromDiscord | <Elegantbeef> It also is hardcoded hash procedures |
21:03:24 | FromDiscord | <Elegantbeef> Want to add a new has procedure, too bad |
21:03:28 | FromDiscord | <goerge_lsd> yeah, no variable hashes |
21:03:46 | FromDiscord | <Elegantbeef> Using a tuple of objects like I showed is more sensible imo |
21:04:08 | FromDiscord | <goerge_lsd> I didn't quite wrap my mind .. care to add a runnable example to that code ? :\ |
21:04:31 | FromDiscord | <Elegantbeef> Given I do not know how hash functions generally work... I can try |
21:05:51 | * | def- quit (Quit: -) |
21:06:03 | FromDiscord | <goerge_lsd> well i had no idea as well, but by looking at their runnableExamples, i could see that you can add varying amounts of data to an already computed context, and it will give the right result, once finalized |
21:06:29 | FromDiscord | <goerge_lsd> they all have the same interface in that regard |
21:06:45 | FromDiscord | <goerge_lsd> init/update n times/finalize |
21:06:54 | * | def- joined #nim |
21:09:49 | * | def- quit (Client Quit) |
21:10:44 | FromDiscord | <goerge_lsd> https://play.nim-lang.org/#pasty=mXuzWCFH |
21:10:55 | FromDiscord | <goerge_lsd> well, the results are correct.. time to beautify code |
21:11:02 | FromDiscord | <goerge_lsd> then thread it |
21:11:30 | FromDiscord | <Robyn [She/Her]> I'm gonna name my lib `cordyceps` and make the pragma `spore` :) |
21:13:01 | * | def- joined #nim |
21:21:00 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=jSCyLynh |
21:21:05 | FromDiscord | <Elegantbeef> there you go @goerge_lsd |
21:22:46 | FromDiscord | <Elegantbeef> I do realise now you do not want to run them on top of each other, but that's also easy to do |
21:25:08 | FromDiscord | <goerge_lsd> are you sure this is absolutely the most elegant nim, given the circumstances ? : D |
21:25:15 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=auPItMgE |
21:25:19 | * | def- quit (Quit: -) |
21:25:25 | FromDiscord | <Elegantbeef> It's quite elegant as it does not rely on maintaining an object upstream |
21:25:35 | * | def- joined #nim |
21:25:39 | FromDiscord | <Elegantbeef> As such you can just define a bunch of these `consts` and use them |
21:27:02 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=xrTtnvrE made it even cleaner |
21:27:25 | FromDiscord | <Elegantbeef> The simple fact is that `checksums` is not written to be generic so this is required |
21:28:39 | FromDiscord | <goerge_lsd> hm but your code does not do the hashing in chunks.. |
21:30:43 | FromDiscord | <Elegantbeef> I also value reusable code more than specialised code |
21:30:43 | FromDiscord | <Elegantbeef> Having arbitrary support for hash procedures is just great |
21:30:45 | FromDiscord | <Elegantbeef> What? |
21:30:45 | FromDiscord | <Elegantbeef> You asked for an example |
21:30:45 | FromDiscord | <Elegantbeef> If you want to make it more elaborate, do that |
21:30:46 | FromDiscord | <Elegantbeef> Is it so hard to add a `finishProc` and to invoke that at the end of `hashIt` |
21:30:46 | FromDiscord | <Elegantbeef> Methinks not |
21:33:13 | FromDiscord | <goerge_lsd> finishProc to the Hasher Object |
21:33:39 | FromDiscord | <Elegantbeef> technically we could remove `Hasher` and just use generic procedures |
21:33:39 | FromDiscord | <Elegantbeef> That involves shadowing all of the procedures into a single shape |
21:33:39 | FromDiscord | <Elegantbeef> Which you're practically doing now |
21:34:59 | FromDiscord | <goerge_lsd> not sure I follow, remove Hasher ? |
21:35:25 | FromDiscord | <goerge_lsd> procedures are already generic |
21:35:46 | FromDiscord | <Elegantbeef> No they're not |
21:39:51 | FromDiscord | <goerge_lsd> well, if you think that's more elegant, would like to see a sample : P |
21:40:20 | FromDiscord | <goerge_lsd> can't get as elegant as that Go code though, most likely, we don't have generic writeres and multiplexers |
21:40:28 | FromDiscord | <Elegantbeef> Ok final thing I will contribute |
21:40:29 | FromDiscord | <goerge_lsd> (edit) "writeres" => "writers" |
21:40:29 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=MikNqHxj |
21:40:39 | FromDiscord | <Elegantbeef> Paint the rest of the owl thanks |
21:41:49 | FromDiscord | <Elegantbeef> I mean I think this code is more elegant as it does not rely on runtime interfaces, but ymmv |
21:43:30 | FromDiscord | <Elegantbeef> Could also use a macro so you could take in `"bleh".hashIt(tuple[md5: Md5Context, sha1: Sha1State])` then get back a `tuple[md5: string, sha1: string]` |
21:43:47 | FromDiscord | <Elegantbeef> Then you can do `echo "bleh".hashIt(tuple[md5: Md5Context, sha1: Sha1State]).md5` |
21:44:32 | FromDiscord | <Elegantbeef> But this works with arbitrary field names and types so is wonderful all without having to hoist data to dynamically dispatch |
21:44:41 | FromDiscord | <Elegantbeef> Which I find more elegant 😛 |
21:45:12 | FromDiscord | <goerge_lsd> never touched macros :\ |
21:45:48 | FromDiscord | <Elegantbeef> Well this would be a very simple one 😄 |
21:49:45 | FromDiscord | <sOkam! 🫐> simple macros are a lie. they don't exist |
21:49:56 | FromDiscord | <Elegantbeef> They really do |
21:50:14 | FromDiscord | <sOkam! 🫐> they are always like santa, big fat and full of surprises |
21:55:06 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=zGIesieb |
21:55:56 | FromDiscord | <Elegantbeef> Now now sokam this is simple https://play.nim-lang.org/#pasty=PTRHJVnH |
21:56:25 | FromDiscord | <Elegantbeef> Technically we can use `typetraits.isNamedTuple` to remove the error from the macro |
21:57:31 | FromDiscord | <Elegantbeef> \To finish this off we could even remove the string conversion, and emit a `tuple[name: typeof(state.finish())]` |
21:57:47 | FromDiscord | <Elegantbeef> Which means no pointless allocations! |
21:58:24 | FromDiscord | <Elegantbeef> I did forget to do `static: i = 0` at the start of `hashIt` |
22:00:55 | FromDiscord | <goerge_lsd> don't understand the macro version, and previous one with overloaded procs.. doesn't look so great to me |
22:01:20 | FromDiscord | <goerge_lsd> anyway, what thread lib would you use to pass the buffer to each thread handling a hash function ? |
22:01:20 | FromDiscord | <Elegantbeef> Well you're blind to the glory that is generic interfaces and reusable code |
22:01:51 | FromDiscord | <Elegantbeef> The benefit of the overloaded procs is you can use any hash procedure that you want without having to make a PR or fork the library this comes from |
22:02:04 | FromDiscord | <Elegantbeef> It's endlessly extensible without relying on runtime dispatch |
22:02:31 | FromDiscord | <goerge_lsd> I think you have to pass the pointer to it, that would be safe since it's read only, wait for all threads to.. yield? or how do you call it, finish work without kiling the thread ? |
22:02:33 | FromDiscord | <Elegantbeef> The tuple version simply emits a tuple instead of an array |
22:25:32 | * | beholders_eye quit (Read error: Connection reset by peer) |
22:28:18 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "Which means no pointless": Rustacean energy |
22:31:21 | * | beholders_eye joined #nim |
22:33:40 | FromDiscord | <zumi.dxy> Is there any way I can do "subsets" of cases? https://play.nim-lang.org/#pasty=lVWEaruF |
22:37:30 | FromDiscord | <polylokh_39446> rejected in <https://github.com/nim-lang/Nim/issues/11086> |
22:38:18 | FromDiscord | <polylokh_39446> but also, an example of a subrange in that |
22:39:58 | FromDiscord | <polylokh_39446> <https://play.nim-lang.org/#pasty=zERWJZzL> |
22:40:26 | FromDiscord | <polylokh_39446> requires the subrange to be continuous though |
22:44:14 | FromDiscord | <zumi.dxy> aight, I've got this now: https://play.nim-lang.org/#pasty=mXOBMvrd |
22:44:43 | FromDiscord | <zumi.dxy> can I extract the "range" out of the type it's contained in? |
22:45:05 | FromDiscord | <zumi.dxy> hmm... |
22:45:13 | FromDiscord | <polylokh_39446> what do you mean by extract? |
22:45:26 | FromDiscord | <Robyn [She/Her]> Can you not do `of {A, B, C}: ...`? |
22:45:55 | FromDiscord | <zumi.dxy> In reply to @zumi.dxy "can I extract the": ok almost forgot about this https://play.nim-lang.org/#pasty=NuOFQikj |
22:46:11 | FromDiscord | <Robyn [She/Her]> What you're asking is confusing tbh |
22:46:41 | FromDiscord | <polylokh_39446> the likeliest problem to come up with code like this is that it doesn't work with non-contiguous values |
22:48:47 | FromDiscord | <zumi.dxy> In reply to @chronos.vitaqua "What you're asking is": I like my exhaustive case checks and would like to not use dodgy if-else inside of a case covering multiple values↵like I have a `of A, B, C:`, so I know `D` and `E` won't ever be touched |
22:49:28 | FromDiscord | <zumi.dxy> so my code will assume likewise, but I just have an `if…else`↵but what if I add `D` to that `of`-clause? |
22:49:48 | FromDiscord | <zumi.dxy> I want that to be checked |
22:50:11 | FromDiscord | <zumi.dxy> like "you added `D` to that case but you didn't account for it" |
22:50:21 | FromDiscord | <Robyn [She/Her]> You could use `else`? |
22:50:41 | FromDiscord | <Elegantbeef> I would do explict range cases and `assert false` |
22:51:11 | FromDiscord | <Robyn [She/Her]> https://play.nim-lang.org/#pasty=FSbXktqx |
22:51:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=DJEFazEG |
22:52:42 | FromDiscord | <Elegantbeef> Could even do `of A..pred(E)` and `succ(D) .. TheWholeSet.high` |
22:52:53 | FromDiscord | <Elegantbeef> Whoops `pred(D)` |
22:58:46 | FromDiscord | <zumi.dxy> In reply to @polylokh_39446 "the likeliest problem to": and casting `something` to a set instead of a range doesn't seem to work 🤔 |
22:59:28 | FromDiscord | <polylokh_39446> casting preserves memory layout and sets are completely differently laid out |
22:59:46 | FromDiscord | <zumi.dxy> https://play.nim-lang.org/#pasty=hVjvJTAf |
23:00:45 | FromDiscord | <Elegantbeef> `range[D..E](something)` |
23:01:00 | FromDiscord | <polylokh_39446> you might raise an issue to remove the need for the assert falses there. Type inference has been improved in this direction before, for discriminated unions |
23:01:44 | FromDiscord | <Elegantbeef> Well araq will probably say "Until NIR is used ...." |
23:01:46 | FromDiscord | <zumi.dxy> In reply to @Elegantbeef "`range[D..E](something)`": yeah that's for continuous types↵I can handle that tbh |
23:02:00 | FromDiscord | <zumi.dxy> In reply to @polylokh_39446 "you might raise an": This could use an RFC even |
23:02:13 | FromDiscord | <zumi.dxy> but I have no clue on how to make a good one |
23:03:01 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/RFCs/issues/429 |
23:03:53 | FromDiscord | <zumi.dxy> ah, there it is↵scope narrowing |
23:04:05 | FromDiscord | <zumi.dxy> yeah that's what I meant |
23:08:45 | FromDiscord | <Robyn [She/Her]> Uuuuh how do I rename an identifier? `myIdent.strval = "a"` doesn't work |
23:08:57 | FromDiscord | <Elegantbeef> `myIdent = ident"a"` |
23:09:07 | FromDiscord | <Robyn [She/Her]> I don't want to create a new identifier because I'm purposefully relying on ref semantics |
23:09:15 | FromDiscord | <Elegantbeef> So then dereference it? |
23:09:29 | FromDiscord | <Robyn [She/Her]> Wait I can do that? |
23:09:41 | FromDiscord | <Elegantbeef> Why not? |
23:09:42 | FromDiscord | <Robyn [She/Her]> So `myIdent[] = (ident"a")[]`? |
23:09:51 | FromDiscord | <Robyn [She/Her]> I just didn't think of it honestly |
23:10:16 | FromDiscord | <Elegantbeef> pointer emulation is sorta a surprise from the NimVm |
23:10:38 | FromDiscord | <Elegantbeef> I had `ptr array[..., proc]` working with the VM and was amazed |
23:11:29 | FromDiscord | <Robyn [She/Her]> It's pretty neat honestly |
23:21:55 | FromDiscord | <Robyn [She/Her]> Micros probably has some useful stuff I should look into |
23:40:43 | * | xet7 quit (Ping timeout: 256 seconds) |
23:42:49 | FromDiscord | <Elegantbeef> I wish it was more complete but there is some nice stuff |