<< 20-12-2021 >>

00:00:13*tk quit (Quit: Well, this is unexpected.)
00:00:39*tk joined #nim
00:32:12*krux02 quit (Remote host closed the connection)
01:03:17*noeontheend quit (Ping timeout: 240 seconds)
01:12:23*noeontheend joined #nim
01:16:23*syl quit (Quit: ZNC 1.8.2 - https://znc.in)
01:17:01*syl joined #nim
01:58:06*noeontheend quit (Ping timeout: 268 seconds)
02:26:43FromDiscord<TryAngle> hmm I ran into a "weird issue"↵my goal↵implement something that requires division of two numbers but I want it for float and ints
02:28:32FromDiscord<TryAngle> I think a quick fix is implementing a "unified" div ↵or a div for floats lol
02:29:15FromDiscord<TryAngle> is there a reason that there is no `div` for floats?
02:29:48FromDiscord<Rika> because it makes no sense?
02:32:41*rockcavera joined #nim
02:32:41*rockcavera quit (Changing host)
02:32:41*rockcavera joined #nim
02:33:12FromDiscord<impbox [ftsf]> because there is `/` for floats
02:33:20FromDiscord<TryAngle> In reply to @Rika "because it makes no": o_O ↵I might misunderstand the intention of div
02:33:45FromDiscord<TryAngle> In reply to @impbox "because there is `/`": yes but `/` for ints produces floats
02:33:48FromDiscord<Rika> integer division when you do not want floats
02:34:00FromDiscord<impbox [ftsf]> `div` computes integer division
02:34:10FromDiscord<impbox [ftsf]> i guess you might want integer division of floats
02:34:14FromDiscord<Rika> there are scenarios where you do not want float division
02:34:28FromDiscord<impbox [ftsf]> and float division of ints
02:34:37FromDiscord<impbox [ftsf]> but both would use internal conversions
02:35:09FromDiscord<impbox [ftsf]> but you could define them if you want them
02:35:17FromDiscord<TryAngle> In reply to @impbox "i guess you might": I want to write an algorithm that works for ints aswell as for floats that requires a division that produces the respective type
02:35:17FromDiscord<impbox [ftsf]> but their use case is pretty niche
02:35:36FromDiscord<impbox [ftsf]> @TryAngle you can use `when x is SomeFloat:`
02:35:40FromDiscord<impbox [ftsf]> to use / else div
02:35:42FromDiscord<Rika> In reply to @TryAngle "I want to write": when T is int: ...div... elif T is float: .../...
02:36:06FromDiscord<TryAngle> ah true that works 🤔
02:36:13FromDiscord<impbox [ftsf]> but you might want to use / in either case and convert to float and back for ints
02:36:18FromDiscord<impbox [ftsf]> depending on your requirements
02:39:37*neurocyte0132889 quit (Ping timeout: 240 seconds)
02:41:55FromDiscord<TryAngle> ok I guess I add "div" for floats lol
02:58:34FromDiscord<Rosen> you want it to return a int or a float?
02:59:34FromDiscord<Rika> In reply to @TryAngle "I want to write": this
02:59:39FromDiscord<Rika> ints for int, floats for float
02:59:57FromDiscord<Rika> In reply to @TryAngle "ok I guess I": i would highly suggest not doing this if you are releasing this as a library
03:05:38FromDiscord<TryAngle> In reply to @Rika "i would highly suggest": hmm ok I reconsider this then, I thought div would be same type while / is a conventient way to write fractions lol
03:05:52FromDiscord<TryAngle> (edit) "div" => "`div`" | "/" => "`/`"
03:06:06FromDiscord<Rika> well it isnt
03:06:29FromDiscord<Rika> what function are you making that needs int -> int and float -> float and ALSO does division?
03:06:42FromDiscord<TryAngle> when I want to use something like fmod from c (modulo for floats)↵nim has nothing like that right?↵so the simplest thing would just use importc progma?
03:07:39FromDiscord<leorize> @TryAngle\: I suppose you're looking for this? https://nim-lang.github.io/Nim/math#floorMod%2CT%2CT
03:08:09FromDiscord<Elegantbeef> nah `math.mod` is `fmod`
03:08:26FromDiscord<Elegantbeef> Like it's `fmod` imported from C's `math.h` 😀
03:08:38FromDiscord<Rika> speaking of which it's strange that we dont have fused divmod
03:09:52FromDiscord<TryAngle> I wanted to implement gcd and lcm↵I didn't know it was in std/math already lol
03:10:08FromDiscord<TryAngle> In reply to @leorize "<@147447489316913152>\: I suppose you're": just saw after I clicked on this link
03:10:17FromDiscord<Rika> please use the search box xd
03:10:21FromDiscord<Rika> saves a lot of time
03:10:26FromDiscord<Rika> <-- speaking from experience
03:10:37FromDiscord<TryAngle> I thought yeah this would be in std/algorithms if it was there
03:10:49FromDiscord<TryAngle> pressed control + f and didn't find
03:11:03FromDiscord<TryAngle> totally forgot std/math exists o_O
03:11:25FromDiscord<TryAngle> In reply to @Rika "please use the search": will do in futurel ol
03:40:13*arkurious quit (Quit: Leaving)
04:06:02*supakeen quit (Quit: WeeChat 3.4)
04:06:32*supakeen joined #nim
04:15:20*rockcavera quit (Remote host closed the connection)
04:29:56FromDiscord<huantian> hey, what times.parse format do I use to parse this? `2019-11-12T16:37:40.000Z`↵The main part I'm not sure about is the .000Z at the end
04:30:18FromDiscord<huantian> is that miliseconds or utc offset
04:33:51FromDiscord<huantian> I think actually `"yyyy-MM-dd'T'HH:mm:ss'.'fffz"` should be correct
04:36:18FromDiscord<Rika> Milliseconds
04:36:23FromDiscord<Rika> Z denotes offset
04:36:56FromDiscord<Rika> https://en.m.wikipedia.org/wiki/List_of_UTC_time_offsets
04:42:18FromDiscord<huantian> Thank 🙏
04:52:23FromDiscord<Rika> I think this should be useful maybe
04:52:24FromDiscord<Rika> https://en.m.wikipedia.org/wiki/ISO_8601
04:54:18*noeontheend joined #nim
04:57:55FromDiscord<huantian> ah cool
05:13:09*Gustavo6046 joined #nim
06:30:57*noeontheend quit (Ping timeout: 240 seconds)
07:17:44FromDiscord<Michal58> I feel like it should be possible to return a proc without the return keyword.
07:21:24FromDiscord<Elegantbeef> What do you mean?
07:24:17*PMunch joined #nim
07:27:39FromDiscord<Michal58> sent a code paste, see https://play.nim-lang.org/#ix=3IV0
07:28:20FromDiscord<Elegantbeef> Ah i dont use lambdas so make sense why this hasnt bothered me
07:28:32FromDiscord<Elegantbeef> Yea i mean it should be an R val so it should be returned
07:30:12FromDiscord<Elegantbeef> Seems it's a parse error afaict
07:31:03FromDiscord<Michal58> In reply to @Elegantbeef "Seems it's a parse": yeah, it doesn't parse
07:31:29FromDiscord<Michal58> it is possible to return a proc as the last expression just not in the way like above
07:31:49FromDiscord<Michal58> sent a code paste, see https://play.nim-lang.org/#ix=3IV2
07:31:51FromDiscord<Elegantbeef> Yea i know
07:31:59FromDiscord<Elegantbeef> I know this bug, it just doesnt bother me
07:32:09FromDiscord<Elegantbeef> you can also do `result =`
07:41:06FromDiscord<Elegantbeef> Do you know if there is an issue made?
08:06:35*Gustavo6046 quit (Quit: Leaving)
08:07:21*neurocyte0132889 joined #nim
08:07:21*neurocyte0132889 quit (Changing host)
08:07:21*neurocyte0132889 joined #nim
08:11:25*xet7 quit (Quit: Leaving)
08:20:35FromDiscord<Michal58> I don't
08:20:50FromDiscord<Michal58> I wanted to ask here first before making it
08:52:05FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVq
08:53:36FromDiscord<KatrinaKitten> (edit) "https://play.nim-lang.org/#ix=3IVq" => "https://play.nim-lang.org/#ix=3IVr"
08:57:04FromDiscord<Elegantbeef> What is `Parser[T]`?
08:58:20FromDiscord<KatrinaKitten> It's a `proc(input: string): ParseResult[T]`, where `ParseResult` is just an `object`.
08:58:27FromDiscord<Elegantbeef> Ok
09:03:35*Vladar joined #nim
09:05:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVt
09:06:56FromDiscord<KatrinaKitten> No, it still gives the same `undeclared identifier: 'input'` error.
09:07:11FromDiscord<Elegantbeef> `nim -v`?
09:07:45FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVu
09:08:03FromDiscord<Elegantbeef> I mean the above work fine for me, so we'll need more i guess
09:09:24FromDiscord<KatrinaKitten> Here's a playground link for the full actual file. https://play.nim-lang.org/#ix=3IVv
09:10:19FromDiscord<Elegantbeef> Oh there is a second step of indirection
09:10:35FromDiscord<KatrinaKitten> The `s` func on its own seems to work, but `|` creates a compilation error because `input` isn't declared.
09:13:54FromDiscord<Elegantbeef> Well i removed some of what made it less readable to me but seems if you pass the type as a parameter instead of use it like a generic it seems to work https://play.nim-lang.org/#ix=3IVw
09:14:13FromDiscord<Elegantbeef> I also added `{.dirty.}` which makes the template not hygenic, but for this example it seems fine
09:15:45FromDiscord<KatrinaKitten> Hmm, very odd. That error is resolved now, need to do some finegling to clean up other issues now but I should be able to work it out now I'm past that roadblock. Thanks!
09:16:01FromDiscord<Elegantbeef> No problem
09:16:59FromDiscord<Elegantbeef> I think i see why with dirty one needs to pass a typedesc as a parameter, since it's dirty the T isnt injected as a symbol i assume
09:17:31FromDiscord<Elegantbeef> Nope that's not right 😀
09:17:45FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVx
09:17:56FromDiscord<KatrinaKitten> After a little playing it works just fine continuing to use `{.inject.}` instead of `{.dirty.}`, so long as it's a `typedesc` instead of a generic.
09:18:10FromDiscord<Elegantbeef> Odd
09:18:22FromDiscord<Elegantbeef> I need to find the mechanism that causes this and see how easy it is to fix
09:26:30*Lord_Nightmare quit (Ping timeout: 260 seconds)
09:26:32FromDiscord<Elegantbeef> Ah i've got it!
09:27:17FromDiscord<Elegantbeef> It's actually a generic issue not a template issue
09:29:35FromDiscord<Elegantbeef> Oh methinks i see the issue, it's attempting to semantically check this call and as such `echo(input)` fails as the generic messes with the logic
09:29:51FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVy
09:30:10FromDiscord<KatrinaKitten> Interesting 🤔
09:32:55FromDiscord<qb> Elegantbeef is a great nim support bot 😄
09:33:16FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVz
09:33:20FromDiscord<qb> Are you `ba0f3` on github btw?
09:33:28FromDiscord<Elegantbeef> We can actually make your code work
09:33:30FromDiscord<Elegantbeef> Me?
09:33:34FromDiscord<qb> Yups
09:33:44FromDiscord<Elegantbeef> Nah beef331
09:33:53FromDiscord<qb> Alright
09:34:19FromDiscord<Elegantbeef> Line 38 katrina https://play.nim-lang.org/#ix=3IVA
09:34:31FromDiscord<Elegantbeef> Forces `input` to remain open until the instantiation of the generic
09:35:02FromDiscord<Elegantbeef> I dont think it's possible to constrain like that
09:35:41FromDiscord<Elegantbeef> It makes 100% sense now why it errors and i think it's technically "right" though i dont know
09:36:56FromDiscord<Elegantbeef> Actually i'm wrong
09:36:59FromDiscord<Elegantbeef> You can constrain them
09:37:10FromDiscord<Elegantbeef> `[X, Y; Z: X or Y`
09:37:23FromDiscord<Elegantbeef> Or `X | Y` if you're a degenerate that likes farts or some jovial insult
09:37:56FromDiscord<KatrinaKitten> Ahhh the `;`, that makes sense. `mixin` seems to have the desired effect in this case, but I'm guessing is less typesafe?
09:38:40FromDiscord<Elegantbeef> Well `mixin` will allow selecting any variables into the scope
09:38:54FromDiscord<Elegantbeef> It's not a typesafe thing as a selecting of symbols
09:39:27FromDiscord<Elegantbeef> So basically when you instantiate a generic with `mixin` in it'll be capable of selecting any in scope, but it should always pick the one in the template
09:39:42FromDiscord<KatrinaKitten> Cool!
09:40:37FromDiscord<Elegantbeef> I'm apparently wrong, it'll crash if there is another input in scope
09:40:53FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVD
09:41:07FromDiscord<Elegantbeef> Oh wait i'm dumb
09:41:20FromDiscord<Elegantbeef> There we go
09:41:22FromDiscord<Elegantbeef> That runs
09:41:22FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVE
09:41:38FromDiscord<Elegantbeef> The input before was erroring since forcing the symbol open made it go "Yep this really doesnt work
09:44:39FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVF
09:45:10FromDiscord<KatrinaKitten> Typecasts being there or not makes no apparent difference.
09:45:12FromDiscord<Elegantbeef> Ah maybe instantiating types with the parameters doesnt work
09:46:30FromDiscord<Elegantbeef> Uhh you wrote a custom `as`?
09:47:02FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVG
09:47:17FromDiscord<KatrinaKitten> Ah, no, that was just my offhand guess. The documentation is a pain to search through.
09:47:27FromDiscord<Elegantbeef> Nah it's just `Parser[V] (t)`
09:47:37FromDiscord<Elegantbeef> Space isnt required that's me being dumb
09:47:44FromDiscord<Elegantbeef> Any form of call works for it
09:48:18FromDiscord<Elegantbeef> I have a hypothesis for the issue so give me a moment
09:49:06FromDiscord<KatrinaKitten> That gives the same error, even if I wrap it in `cast`. I'm guessing the issue is I'm trying to get it to infer the generics and it's freaking out at `V` not having an explicitly inferable definition, even though it has a constraint that should be inferable.
09:49:49FromDiscord<KatrinaKitten> I.e. I'm calling it as `doThing(<params>)` not `doThing[<types>](<params>)`.
09:50:03FromDiscord<KatrinaKitten> (edit) "`doThing[<types>](<params>)`." => "`doThing[<types>](<params>)`, in part because of operator syntax."
09:50:44FromDiscord<Elegantbeef> Hmm
09:50:52FromDiscord<Elegantbeef> Nah i dont think so
09:51:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVI
09:51:42FromDiscord<Elegantbeef> Can you pass the full file again?
09:52:34FromDiscord<KatrinaKitten> Ah, see, I don't have any parameters that use `V` in their type. https://play.nim-lang.org/#ix=3IVJ
09:53:01FromDiscord<KatrinaKitten> It's only used in the output type and as a parameter to the `createParserTo` template, not in any of the input parameter types.
09:53:02FromDiscord<Elegantbeef> Yea that's the issue
09:53:32FromDiscord<Elegantbeef> You can just do `Parser[T or U]` i think
09:53:54FromDiscord<KatrinaKitten> That would work, but I also
09:54:19FromDiscord<KatrinaKitten> That would work, but on passing `T or U` to `createParserTo`, it complains that it's getting a type node rather than a `typedesc`.
09:54:34FromDiscord<Elegantbeef> I meant just as the return type
09:55:06FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVK
09:55:28FromDiscord<Elegantbeef> Ah yea just do `Parser` than
09:55:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IVL
09:57:11FromDiscord<KatrinaKitten> Hmm... Let me play around a little and see if I can get it to work along those lines.
09:57:12FromDiscord<Elegantbeef> You cant really constrain return types that well
09:57:21FromDiscord<KatrinaKitten> If not, `mixin` may have to do, which is fine.
09:57:49FromDiscord<Elegantbeef> And btw `cast` is a lowlevel bit for bit cast
09:57:55FromDiscord<Elegantbeef> So it's almost never what you want
09:58:48FromDiscord<Elegantbeef> !eval echo cast[float](256)
09:58:50NimBot1.264808053353591e-321
09:58:55FromDiscord<Elegantbeef> damn bridge
09:58:58FromDiscord<Elegantbeef> Wait it worked 😀
09:59:16FromDiscord<Elegantbeef> that's `echo cast[float](256)` since it got destroyed
09:59:58FromDiscord<KatrinaKitten> Yeah, it doesn't like me trying to work around it that way since I need to wrap that entire body in a template call, rather than just the result.
10:04:23FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IVN
10:04:44FromDiscord<KatrinaKitten> (edit) "https://play.nim-lang.org/#ix=3IVN" => "https://play.nim-lang.org/#ix=3IVO"
10:06:42FromDiscord<Elegantbeef> Yea it's too late for me to think about this
10:06:55FromDiscord<KatrinaKitten> Mood. Thanks for all the help, I should probably head to bed myself.
10:07:12FromDiscord<Elegantbeef> I can only say "probably give up the idea of constraining result"
10:07:22FromDiscord<Elegantbeef> Just make it a `Parser` and call it a day there
10:07:40FromDiscord<Elegantbeef> It's a generic so it can only return 1 possible type at a time
10:08:17FromDiscord<KatrinaKitten> Yeah, I may just have to make it so combinators like `|` can't combine parsers which return differing types.
10:08:49FromDiscord<Elegantbeef> I mean if you want to combine them you'd just need to use a tagged union
10:08:53FromDiscord<Elegantbeef> Or as Nim calls them object variants
10:09:10FromDiscord<Elegantbeef> Anyway i'm out
11:09:40NimEventerNew Nimble package! flower - A pure Nim bloom filter., see https://github.com/dizzyliam/flower
11:18:25*xet7 joined #nim
12:06:01*supakeen quit (Quit: WeeChat 3.4)
12:06:30*supakeen joined #nim
12:50:15Amun-RaI like seeing "The `.raises` requirements differ." without disclosing any details
13:40:08*rockcavera joined #nim
13:40:09*rockcavera quit (Changing host)
13:40:09*rockcavera joined #nim
14:00:10*arkurious joined #nim
14:11:38Amun-Rais there alternative that'd work here? https://play.nim-lang.org/#ix=3IWK
14:13:59FromDiscord<Yardanico> i don't think so
14:14:04FromDiscord<Yardanico> one alternative you can do is create a compile time seq
14:14:08FromDiscord<Yardanico> and then convert it into an array
14:16:13Amun-Rathanks
14:16:13FromDiscord<tbrekalo> what could I try to build over a weekend to get a grasp on nim's metaprogramming? something with a heavy macro/template use?
14:27:09FromDiscord<haxscramper> In reply to @tbrekalo "what could I try": DSL for some repetitive task you have to do
14:27:15FromDiscord<haxscramper> Or just html generator DSL
14:30:21FromDiscord<exelotl> `use` keyword is a fun exercise: https://youtu.be/QM1iUe6IofM?t=2470
14:34:04FromDiscord<tbrekalo> Okay; thanks; Will try something like that 🙂
14:38:50FromDiscord<sigmasd> sent a code paste, see https://play.nim-lang.org/#ix=3IWZ
14:42:15FromDiscord<haxscramper> `when t is int`, `elif t is string`
14:43:32FromDiscord<sigmasd> That's nice, thanks!
15:00:53Amun-RaI'm trying to convert seq to array (compile time) and I hit compiler error: https://play.nim-lang.org/#ix=3IX6
15:38:45FromDiscord<sigmasd> sent a code paste, see https://play.nim-lang.org/#ix=3IXp
15:44:10FromDiscord<SolitudeSF> you can write a for loop macro for that
16:00:43FromDiscord<sigmasd> sent a code paste, see https://play.nim-lang.org/#ix=3IXx
16:08:30FromDiscord<sigmasd> replacing r with r = newStmtList() seems to work
16:14:52*noeontheend joined #nim
16:19:10*noeontheend quit (Remote host closed the connection)
16:26:05FromDiscord<sigmasd> sent a code paste, see https://play.nim-lang.org/#ix=3IXJ
16:27:16arkanoidIs nim forum broken?
16:28:44nrds<Prestige99> It's up for me
16:30:45FromDiscord<SolitudeSF> try `ident Extra`
16:30:57FromDiscord<SolitudeSF> in quotes ofc
16:40:41FromDiscord<sigmasd> `proc \`ident Extra\` ()=\` is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:40:55FromDiscord<sigmasd> proc `ident Extra` ()=↵is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:41:02FromDiscord<sigmasd> proc \`ident Extra\` ()=↵is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:41:07FromDiscord<sigmasd> `proc `ident Extra` ()=`↵is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:41:11FromDiscord<sigmasd> proc `ident Extra` ()=↵is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:41:18FromDiscord<sigmasd> proc \`ident Extra\` ()=↵is accepted by the compiler but its seems to ignore the extra and only quote the ident
16:43:17FromDiscord<SolitudeSF> well, you are already in a macro, you can always construct new identifier
16:45:30FromDiscord<sigmasd> nice! ident(fmt( works
16:49:32*PMunch quit (Quit: Leaving)
16:49:55*xet7 quit (Quit: Leaving)
17:11:43FromDiscord<kevin> Is there a preferred way to check if a seq is empty?
17:11:59FromDiscord<kevin> Python has `if(not myList):`
17:12:23FromDiscord<Rika> if sq.len == 0
17:12:41FromDiscord<kevin> gotcha. Wasnt' sure if there was a simpler way, thanks
17:13:14FromDiscord<Rika> nim isnt a supporter of "truthiness"
17:13:32FromDiscord<kevin> damn thats unlucky
17:14:24nrds<Prestige99> I think it's easier to read
17:17:21nrds<Prestige99> Truthiness can be very different between languages (see JavaScript) so I like that we just check the length in this case
17:17:50nrds<Prestige99> E.g. in js if (myList) would be true if the array were empty
17:18:13FromDiscord<retkid> oii
17:18:34FromDiscord<retkid> i forget, how do i safe a hex string to a encoded file
17:18:44FromDiscord<retkid> like, not as text but as the binary of the file itself
17:22:06FromDiscord<retkid> i got it
17:22:13FromDiscord<retkid> (edit) "i got ... itas" added "it, had to parse" | "it, had to parseit ... " added "as a hex string <3"
17:28:53FromDiscord<retkid> when i convert ints to hex im getting leading 0s?
17:28:58FromDiscord<retkid> why/
17:29:00FromDiscord<retkid> (edit) "why/" => "why?"
17:46:33FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3IXZ
17:46:37FromDiscord<hmmm> someone told me by I forgot 🤔
17:48:53*tiorock joined #nim
17:48:53*tiorock quit (Changing host)
17:48:53*tiorock joined #nim
17:48:53*rockcavera is now known as Guest3200
17:48:53*Guest3200 quit (Killed (zirconium.libera.chat (Nickname regained by services)))
17:48:53*tiorock is now known as rockcavera
17:48:59nrds<Prestige99> var mySeq
17:49:09FromDiscord<hmmm> ye ok but why
17:49:11FromDiscord<Rosen> declare it as var seq[string] to have the mutations persist out of the scope of the function, or make a var copy if you want to only mutate it in the function
17:50:51FromDiscord<IsaacPaul> In reply to @retkid "i forget, how do": Translate the string to a byte array and write that to a file
17:51:37nrds<Prestige99> @hmmm variables are immutable by default
17:52:20FromDiscord<hmmm> yea but why, does Araq hates mutable variables or there is some important reason for it
17:53:03FromDiscord<IsaacPaul> In reply to @retkid "when i convert ints": https://nim-lang.org/docs/strutils.html#toHex%2CT↵The second parameter in toHex is the length
17:54:19FromDiscord<IsaacPaul> In reply to @hmmm "yea but why, does": immutable reduces cognitive load of the developer. You know that data can't change so you don't have to worry about it.
17:54:43FromDiscord<hmmm> hmm, this seems like a good reason
17:55:57*neurocyte0132889 quit (Ping timeout: 240 seconds)
18:01:01*xet7 joined #nim
18:06:57FromDiscord<jfmonty2> fighting with the compiler about static generics\: https://play.nim-lang.org/#ix=3IY0
18:07:12FromDiscord<jfmonty2> this compiles and runs just fine, in particular it is correctly choosing the type for `len` based on `Size`
18:08:03FromDiscord<jfmonty2> but as soon as I try to define a proc that takes a `FixedSeq` as a parameter, it spits out a compile error "Cannot generate code for\: Size"
18:12:36nrds<Prestige99> Don't you need to provide the generics?
18:12:41nrds<Prestige99> e.g. proc doSomething(s: FixedSeq[8, int]) =
18:14:03nrds<Prestige99> although the defeats the purpose
18:14:09nrds<Prestige99> s/the/that/
18:16:13nrds<Prestige99> https://play.nim-lang.org/#ix=3IY7
18:17:22nrds<Prestige99> For some reason it semes to be printing uint8 on line 23 for me, but then uint16 on line 25 🤔
18:17:29nrds<Prestige99> @jfmonty2 ^
18:20:24FromDiscord<Abi> sent a code paste, see https://play.nim-lang.org/#ix=3IYb
18:20:43FromDiscord<Abi> (edit) "https://play.nim-lang.org/#ix=3IYb" => "https://play.nim-lang.org/#ix=3IYc"
18:21:25FromDiscord<Yardanico> but splitLines returns either a seq[string] if it's a func or a string if it's an iterator
18:21:30FromDiscord<jfmonty2> Right, that's intentional because the size is 256 the second time↵(<@709044657232936960_nrds=5b=49=52=43=5d>)
18:21:33FromDiscord<Abi> (edit) "https://play.nim-lang.org/#ix=3IYc" => "https://play.nim-lang.org/#ix=3IYe"
18:21:39FromDiscord<Yardanico> if you want to call `pairs` on something it needs to have that function defined for it obviously
18:21:45FromDiscord<Yardanico> and there's no pairs for seq[string] or string
18:22:03FromDiscord<Yardanico> ah i see what you mean
18:22:14FromDiscord<Yardanico> yeah it's because in this case nim thinks splitLines is an iterator or something
18:22:20FromDiscord<Abi> In reply to @Yardanico "and there's no pairs": https://nim-lang.org/docs/iterators.html#pairs.i%2Cseq%5BT%5D ?
18:22:42FromDiscord<Yardanico> yeah that's the general pairs
18:22:50nrds<Prestige99> @jfmonty2 oh I didn't see you were echoing fs and not fs2
18:22:56*neurocyte0132889 joined #nim
18:22:56*neurocyte0132889 quit (Changing host)
18:22:56*neurocyte0132889 joined #nim
18:22:57FromDiscord<Abi> which should apply to `seq[string]`, I'd have thought
18:23:25FromDiscord<Yardanico> well in your case it's weird
18:23:31FromDiscord<Yardanico> splitLines returns seq[string] _once_
18:23:45FromDiscord<Yardanico> and yeah i think it doesn't work in 2nd case because nim takes splitLines iterator overload
18:23:56FromDiscord<Yardanico> instead of the seq[string] overload
18:24:05FromDiscord<Abi> this is what I assumed, but I thought I'd check
18:24:10FromDiscord<Yardanico> just saying - if you need indexes, just use std/enumerate for iterators :)
18:24:12FromDiscord<krisppurg> Has anyone used jsony?#
18:24:18FromDiscord<Yardanico> @Solitude has
18:24:20FromDiscord<krisppurg> (edit) "jsony?#" => "jsony?"
18:24:22FromDiscord<Yardanico> In reply to @0xAb1 "this is what I": https://nim-lang.org/docs/enumerate.html
18:24:34FromDiscord<Abi> that's weird though, I feel like it should have worked like in part two
18:24:51FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3IYj
18:25:07FromDiscord<Yardanico> and this is more efficient too
18:25:11FromDiscord<Abi> gahhh i never liked `enumerate` in Python, it's always felt somewhat cumbersome lol
18:25:19FromDiscord<Yardanico> since you don't need to preallocate a new seq for storing split strings
18:25:27FromDiscord<Abi> either way - ty for your help!
18:26:01FromDiscord<Abi> (edit) "it" => "part two" | removed "like in part two"
18:29:06*neurocyte0132889 quit (Ping timeout: 256 seconds)
18:32:48*krux02__ joined #nim
18:36:50*neurocyte0132889 joined #nim
18:36:50*neurocyte0132889 quit (Changing host)
18:36:50*neurocyte0132889 joined #nim
18:36:56FromDiscord<exelotl> In reply to @IsaacPaul "immutable reduces cognitive load": I like this succinct explanation ^^
18:42:14FromDiscord<krisppurg> sent a code paste, see https://play.nim-lang.org/#ix=3IYk
18:42:19FromDiscord<krisppurg> sorry for huge message
18:43:38FromDiscord<theangryepicbanana> it probably expects an array of flags rather than a number representing a bitset
18:43:47FromDiscord<theangryepicbanana> (edit) "a bitset" => "bitflags"
18:44:11*tiorock joined #nim
18:44:11*tiorock quit (Changing host)
18:44:11*tiorock joined #nim
18:44:11*rockcavera quit (Killed (strontium.libera.chat (Nickname regained by services)))
18:44:11*tiorock is now known as rockcavera
18:44:48FromDiscord<Yardanico> In reply to @krisppurg "So, I was looking": i think it's fair to just ping treeform or open an issue in jsony so he can respond quicker
18:45:38FromDiscord<Yardanico> also I don't understand why do you use `JsonNode` if you want to use jsony and have better performance
18:46:00FromDiscord<Yardanico> ah, to change public_flags later I guess
18:48:37FromDiscord<krisppurg> @treeform
18:50:49FromDiscord<krisppurg> In reply to @Yardanico "also I don't understand": well if I do also change it to string, I would have to go through parts where I call `.newUser` on other files and it would be a long tedious process to change since they are called commonly.
18:51:02FromDiscord<Yardanico> have you tried packedjson at least though?
18:51:03FromDiscord<krisppurg> (edit) "In reply to @Yardanico "also I don't understand": well if I do also change it to string, I would have to go through parts where I call `.newUser` on other files and it would be a long tedious process to change ... since" added "the json to string"
18:51:07FromDiscord<krisppurg> packedjson?
18:51:10FromDiscord<Yardanico> yes?
18:51:16FromDiscord<Yardanico> https://github.com/Araq/packedjson
18:51:47FromDiscord<Yardanico> also why specifically optimize json? is that the slowest part of dimscord?
18:52:25FromDiscord<krisppurg> not just optimising but to shorten objects.nim
18:52:36FromDiscord<krisppurg> since it is getting repetitive and long
18:52:49FromDiscord<Yardanico> i thought you were already using json.to?
18:53:07FromDiscord<krisppurg> json.to is not the best
18:53:12FromDiscord<krisppurg> I do use at some
18:53:18FromDiscord<krisppurg> (edit) "I do use at some ... " added "parts of the code"
18:53:24FromDiscord<Yardanico> In reply to @krisppurg "json.to is not the": you can create custom procs for some types too
18:53:35FromDiscord<krisppurg> wdym
18:53:37FromDiscord<Yardanico> https://nim-lang.org/docs/jsonutils.html
18:53:41FromDiscord<Yardanico> if you mean you can'
18:53:46FromDiscord<Yardanico> (edit) "can'" => "can't use it with set[Type]"
18:56:05FromDiscord<treeform> In reply to @krisppurg "<@!107140179025735680>": Give me a small example and i'll figure it out. I think set[Foo] expects [1,2,3] not 6. But one can write a custom hook for set[UserFlags] thats bit based?
18:58:19FromDiscord<treeform> I need sample of your json and your nim object
19:00:08FromDiscord<krisppurg> bare with me in a sec
19:00:19*noeontheend joined #nim
19:01:03FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=3IYu
19:01:27FromDiscord<treeform> I can write one for you if you provide the more info
19:02:08FromDiscord<krisppurg> https://play.nim-lang.org/#ix=3IYv
19:02:17FromDiscord<krisppurg> here is minimal example
19:10:32FromDiscord<retkid> alright so
19:10:52FromDiscord<retkid> im generating around 37324800000 or 37 billion random numbers between 0 and 255
19:11:03FromDiscord<retkid> is there anyway to speed that up?
19:12:14FromDiscord<retkid> well holy shit my computer doesn't have enough space for this data
19:15:23nrds<Prestige99> Could do it in parallel but idk what your use case is
19:15:57FromDiscord<retkid> i guess
19:16:02FromDiscord<retkid> race conditions be crazy tho
19:16:18nrds<Prestige99> What race conditions?
19:16:32FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=3IYx
19:16:35FromDiscord<treeform> But am not sure your cast to flags it correct
19:16:42FromDiscord<treeform> how is it supposed to work?
19:16:59FromDiscord<treeform> set is an array to nim? you can't just cast a number to it?
19:17:00FromDiscord<retkid> anyway, the nim side of the equation is the least bottlenecked
19:17:47FromDiscord<treeform> In reply to @krisppurg "https://play.nim-lang.org/#ix=3IYv": https://play.nim-lang.org/#ix=3IYz
19:18:17FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3IYA
19:18:27FromDiscord<hmmm> oh noes it didn't format! 😦
19:19:07FromDiscord<treeform> In reply to @krisppurg "https://play.nim-lang.org/#ix=3IYv": I don't think your flag format can be decomposed like this. You have flags=256 but your enums are not power of 2, so they can't be packed into an integer C style...
19:19:15FromDiscord<krisppurg> In reply to @treeform "how is it supposed": user flags is bitwise.
19:19:23FromDiscord<treeform> but your enums are not?
19:19:28FromDiscord<krisppurg> they are
19:19:39FromDiscord<krisppurg> just doesn't look like it
19:20:03FromDiscord<krisppurg> ufHouseBravery is the same as saying 2^6
19:20:08FromDiscord<krisppurg> (edit) "ufHouseBravery ... is" added "= 6"
19:20:24FromDiscord<treeform> ufNone is 0, ufDiscordEmployee is 1, ufPartneredServerOwner is 2, ufHypesquadEvents, is 3
19:20:34FromDiscord<krisppurg> well technically yes
19:20:42FromDiscord<treeform> 2^6 is 64 ?
19:20:46FromDiscord<treeform> not 6
19:20:52FromDiscord<krisppurg> yes
19:21:23FromDiscord<krisppurg> if you do cast[uint]({ufHouseBravery})
19:21:40FromDiscord<treeform> well you are casting a set which is an array?
19:21:46FromDiscord<Solitude> its not an array
19:22:02FromDiscord<Solitude> bitarray i guess
19:22:38FromDiscord<Solitude> whats wrong with doing that? thats the data he expects
19:22:54FromDiscord<treeform> if it works it works, I just did not know sets worked like this
19:23:17*neurocyte0132889 quit (Ping timeout: 240 seconds)
19:24:22*Gustavo6046 joined #nim
19:24:35FromDiscord<treeform> the more you know!
19:24:37FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=3IYE
19:24:45FromDiscord<treeform> Then the code I posted earlier is correct.
19:24:54FromDiscord<treeform> https://play.nim-lang.org/#ix=3IYz
19:27:01*joshbaptiste quit (Ping timeout: 245 seconds)
19:28:52FromDiscord<krisppurg> also treeform is there any other examples for your jsony library? I've read your readme btw
19:28:53*joshbaptiste joined #nim
19:29:00FromDiscord<krisppurg> (edit) "your" => "the"
19:30:06FromDiscord<krisppurg> and what does the argument `i` in `parseHook` supposed to represent?
19:34:02FromDiscord<retkid> whats this thing with genetic tyes?
19:34:21FromDiscord<retkid> nvm
19:34:28FromDiscord<retkid> misnomer
19:36:34FromDiscord<krisppurg> @treeform?
19:43:05FromDiscord<Solitude> current position of parser
19:43:19FromDiscord<Solitude> @krisppurg
19:43:44FromDiscord<krisppurg> something like how many chars left?
19:43:55FromDiscord<Solitude> something like which character is next
19:44:05FromDiscord<treeform> In reply to @krisppurg "and what does the": index in into the string, just pass it through
19:45:29FromDiscord<krisppurg> alright
19:48:36*Lord_Nightmare joined #nim
19:59:56*Onionhammer quit (Quit: Ping timeout (120 seconds))
20:00:14*Onionhammer joined #nim
20:05:53*Vladar quit (Quit: Leaving)
20:08:22*neurocyte0132889 joined #nim
20:08:22*neurocyte0132889 quit (Changing host)
20:08:22*neurocyte0132889 joined #nim
20:08:37*noeontheend quit (Ping timeout: 240 seconds)
20:16:47FromDiscord<krisppurg> In reply to @treeform "I got everything to": wait what what if flags in json were strings like `"512"` or `"256"`
20:17:05FromDiscord<treeform> then parse it as a string and cast?
20:17:18FromDiscord<krisppurg> in parseHook?
20:18:03FromDiscord<treeform> yeah, here you go: https://play.nim-lang.org/#ix=3IYR
20:18:26*noeontheend joined #nim
20:18:33FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=3IYT
20:18:56FromDiscord<treeform> basically says when you need a `set[UserFlags]`, parse it as a string first, then cast/parseInt it.
20:19:01FromDiscord<krisppurg> Well I want it as parseBiggestInt, but thanks I got the gist of it I think
20:19:11FromDiscord<treeform> yeah that would work
20:20:30FromDiscord<treeform> For json its very common to encode things in strings
20:20:49FromDiscord<treeform> timestamps, urls, addresses, emails etc....
20:21:04FromDiscord<treeform> so you can parse then as a string, then convert to a richer type
20:23:46FromDiscord<krisppurg> interesting
20:26:18FromDiscord<hmmm> jsony is gud stuff treeformy, I was amazed when the first time I used it it worked at first try and been a fan ever since 💪
20:36:36*rockcavera quit (Ping timeout: 256 seconds)
21:03:57*noeontheend quit (Ping timeout: 240 seconds)
21:07:55*neurocyte0132889 quit (Read error: Connection reset by peer)
21:11:29FromDiscord<treeform> In reply to @hmmm "jsony is gud stuff": Thanks!
21:22:44FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IZe
21:23:15FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3IZe" => "https://play.nim-lang.org/#ix=3IZf"
21:23:18*rockcavera joined #nim
21:23:18*rockcavera quit (Changing host)
21:23:18*rockcavera joined #nim
21:23:39FromDiscord<konsumlamm> `B.T` doesn't really make sense
21:24:03*tiorock joined #nim
21:24:03*tiorock quit (Changing host)
21:24:03*tiorock joined #nim
21:24:03*rockcavera quit (Killed (strontium.libera.chat (Nickname regained by services)))
21:24:03*tiorock is now known as rockcavera
21:24:08FromDiscord<konsumlamm> the `type T` in the definition of `B` just means that `T` is the type implementing the concept
21:24:38FromDiscord<konsumlamm> it's not an associated type or anything like that
21:24:39*tiorock joined #nim
21:24:39*tiorock quit (Changing host)
21:24:39*tiorock joined #nim
21:24:39*rockcavera is now known as Guest2035
21:24:39*Guest2035 quit (Killed (zirconium.libera.chat (Nickname regained by services)))
21:24:39*tiorock is now known as rockcavera
21:25:09FromDiscord<TryAngle> ah I see↵🤔 ↵do concepts have associated types somehow?
21:27:43*tiorock joined #nim
21:27:43*tiorock quit (Changing host)
21:27:43*tiorock joined #nim
21:27:43*rockcavera is now known as Guest2812
21:27:43*tiorock is now known as rockcavera
21:28:53*rockcavera quit (Remote host closed the connection)
21:31:01*Guest2812 quit (Ping timeout: 240 seconds)
21:32:40FromDiscord<Elegantbeef> I dont know what an associated type is, but you can make concepts generic
21:44:18*rockcavera joined #nim
21:44:18*rockcavera quit (Changing host)
21:44:18*rockcavera joined #nim
21:46:57FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IZl
21:47:45FromDiscord<KatrinaKitten> Everywhere I've thought of either doesn't register it as connected to `eof`, ignores it entirely (like this example), or errors.
21:50:19FromDiscord<KatrinaKitten> The only way I can get it to work is if I separate it into an `eofImpl` and document the `let eof = eofImpl` instead, which is okay I guess, but a little annoying.
21:51:39FromDiscord<Elegantbeef> Yea if you want docgen to work with it i dont think you can simply cause any usage of doc comments will be taken by the parser template
21:52:00FromDiscord<KatrinaKitten> Fair enough, `impl` it is. Not the end of the world haha
21:52:28FromDiscord<Elegantbeef> Nim doc comments are taken as AST which means templates just eat them
21:53:59FromDiscord<tandy> why cant u use waitFor with asyncjs?
21:54:23*sagax quit (Ping timeout: 250 seconds)
21:55:48*geek_ joined #nim
22:00:53*noeontheend joined #nim
22:11:51FromDiscord<Elegantbeef> [tandy](https://matrix.to/#/@tandy1000:matrix.org)\: waitfor isnt implemented in asyncjs afaik
22:11:57FromDiscord<Elegantbeef> Which is why
22:12:05FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IZs
22:12:55FromDiscord<tandy> hmmm
22:13:47FromDiscord<tandy> is there any way to interact with results of async procs in a non-async proc/
22:28:05NimEventerNew thread by Sixte: F-bound polymorphism in C++ and(?) Nim , see https://forum.nim-lang.org/t/8728
23:08:28FromDiscord<KatrinaKitten> Is there a way to mark a `{.deprecated.}` a symbol, but only outside of the module it's defined in? For example, for something used internally which is exposed "just in case", but shouldn't be used if it can be avoided.
23:08:37FromDiscord<KatrinaKitten> (edit) "`{.deprecated.}` a symbol," => " symbol `{.deprecated.}`,"
23:10:19FromDiscord<Elegantbeef> You could make it a template that has a macro that emits a warning used from outside the module
23:11:48FromDiscord<KatrinaKitten> It's already a macro, so that's one thing down; how would I check whether it's in the same module?
23:13:54FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IZB
23:17:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IZC
23:17:43FromDiscord<Elegantbeef> Probably want another parameter for `warningMessage`
23:18:17FromDiscord<Elegantbeef> But that's the basic idea, what `someTemplate` does is what your macro needs to emit, and since your macro is emitting the code you might even be able to get the symbol and pass that node as a parameter to `warning`
23:18:25FromDiscord<KatrinaKitten> You know what I think I might do, I may just separate it into an internal and external version, only export the latter, and put the warning in there.
23:18:41FromDiscord<Elegantbeef> "Fuck you beef" 😛
23:18:58FromDiscord<KatrinaKitten> That's a very cool solution, don't get me wrong XD Just seems like overkill
23:20:59FromDiscord<Elegantbeef> Oh i guess you can also use instantiation info
23:23:09FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/mQb
23:23:15FromDiscord<KatrinaKitten> Aye, that seems like a good solution 🙂
23:23:22FromDiscord<Elegantbeef> A much less overkill version 😀
23:25:59*kayabaNerve joined #nim
23:26:50FromDiscord<Elegantbeef> Gotta give bad solutions then good solutions
23:26:56FromDiscord<Elegantbeef> That way people dont ever trust your code
23:33:12FromDiscord<inv> Question about arc: does it correct the `var a = b` with arc will reuse b ?
23:33:29FromDiscord<inv> (edit) "Question about arc:" => "Q:"
23:34:11FromDiscord<inv> In reply to @inv "Q: does it correct": if so, it is clear that fix is to use, for example deepCopy, but should I expect that code for refc does not work with arc in the case ?
23:35:17*geek_ quit (Ping timeout: 240 seconds)
23:38:31FromDiscord<Elegantbeef> Arc can do many optimizations so it's probably it reuses b
23:41:05FromDiscord<KatrinaKitten> sent a code paste, see https://play.nim-lang.org/#ix=3IZH
23:41:07FromDiscord<Elegantbeef> probable even, Arc/Orc will behave differently to the other GCs
23:41:37FromDiscord<KatrinaKitten> (edit) "https://play.nim-lang.org/#ix=3IZH" => "https://play.nim-lang.org/#ix=3IZI"
23:42:22FromDiscord<Elegantbeef> Are you sure it doesnt work?
23:42:35FromDiscord<inv> In reply to @Elegantbeef "probable even, Arc/Orc will": Yep, it is clear that logic behind it is not the same, but is it ok that arc does not work on the same code like refc?
23:42:44FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3IZL
23:42:55FromDiscord<Elegantbeef> Yes it's ok unless you rely on the GC's collection methods
23:43:04FromDiscord<Elegantbeef> Arc is deterministic so it's so much better for many things
23:45:58FromDiscord<KatrinaKitten> In reply to @Elegantbeef "Are you sure ": Yep, even in the playground example you sent it doesn't turn off the warning as expected.
23:46:32FromDiscord<KatrinaKitten> Er, nvm, that one is working I think?
23:46:38FromDiscord<inv> In reply to @Elegantbeef "Yes it's ok unless": sorry, did not get "it is ok that it does not work" or "it is ok that it works" 🙂 In my case it is simple var a = b and some code after it
23:46:44FromDiscord<inv> (edit) "In reply to @Elegantbeef "Yes it's ok unless": sorry, did not get "it is ok that it does not work" or "it is ok that it works" 🙂 In my case it is simple var a = b and some ... code" added "simple"
23:47:10FromDiscord<inv> (edit) "that" => "-" | "-it ... works"" added "should"
23:47:15FromDiscord<inv> (edit) "works"" => "work""
23:47:40FromDiscord<KatrinaKitten> Got it! I needed to put them inside the proc where I was using the macro, rather than around the entire proc. Works like a charm now.
23:48:22FromDiscord<KatrinaKitten> Thanks again for the help, beef!
23:51:47FromDiscord<inv> @ElegantBeef I will prepare minimal example later, was trying to understand is it correct behaviour or not
23:58:22*Gustavo6046 quit (Remote host closed the connection)