00:26:24 | * | derpydoo joined #nim |
00:28:31 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4sxv |
00:29:11 | FromDiscord | <sOkam!> I can always write them as some distinct uint or something. but wondering if there is a cleaner way to achieve it |
00:29:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxw |
00:29:41 | FromDiscord | <sOkam!> right but then you lose the name qualifier of the enum with pure |
00:29:54 | FromDiscord | <sOkam!> not a bad idea though 🤔 |
00:30:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxx |
00:31:09 | * | MadcapJake joined #nim |
00:31:30 | FromDiscord | <sOkam!> good one |
00:45:24 | FromDiscord | <Ayy Lmao> Is there a way to suppress a compiler hint for like one line of code? Like `Hint: conversion from X to itself is pointless` |
00:45:47 | FromDiscord | <Ayy Lmao> Does converting something to itself have any overhead? |
00:45:55 | FromDiscord | <Elegantbeef> `--hint[HintName]: off` |
00:45:59 | FromDiscord | <Elegantbeef> Nah it's a type system thing |
00:47:00 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "`--hint[HintName]: off`": Is there a way to do that for a specific block of code? |
00:47:10 | FromDiscord | <Elegantbeef> `{.hint[Name]: off` |
00:47:19 | FromDiscord | <Ayy Lmao> Oh cool, I'll try it |
00:48:14 | FromDiscord | <Ayy Lmao> Nice, seems to work, thanks! |
00:57:22 | * | MadcapJake quit (Ping timeout: 252 seconds) |
01:10:15 | * | GreaseMonkey quit (Ping timeout: 260 seconds) |
01:10:48 | * | greaser|q joined #nim |
01:18:24 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxA |
01:18:49 | FromDiscord | <Ayy Lmao> Where it takes a cstring and a start and end position. |
01:19:39 | FromDiscord | <Rika> Context, position tuple, string |
01:19:44 | * | greaser|q quit (Changing host) |
01:19:44 | * | greaser|q joined #nim |
01:19:47 | * | greaser|q is now known as GreaseMonkey |
01:19:52 | * | nanxiao joined #nim |
01:19:57 | FromDiscord | <Rika> Wait, I don’t understand the last two arguments |
01:20:28 | FromDiscord | <Ayy Lmao> So the function only draws a single line, and to be more efficient for drawing multiple lines it allows you to draw a substring of a string. |
01:20:45 | FromDiscord | <Ayy Lmao> So ideally I would maintain that optimization for drawing multiple lines. |
01:21:33 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxB |
01:21:36 | FromDiscord | <Ayy Lmao> A more complete snippet from the header. |
01:21:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxC |
01:22:13 | FromDiscord | <huantian> Wouldn’t it be the addr of the last element |
01:22:15 | FromDiscord | <huantian> Not 1 |
01:22:21 | FromDiscord | <Elegantbeef> Yea meant `^1` |
01:23:01 | FromDiscord | <Ayy Lmao> I need to experiment but the data might need to be index by rune |
01:23:33 | FromDiscord | <Ayy Lmao> Can I pass a string to an openArray? I haven't tried that before. |
01:23:40 | FromDiscord | <Elegantbeef> Yes |
01:23:51 | FromDiscord | <Elegantbeef> Seq, array, and string's convert implicitly to openarray |
01:24:21 | FromDiscord | <Elegantbeef> You can also convert a pointer to an open array like i showed yesterday |
01:24:37 | FromDiscord | <Elegantbeef> It's just the best data type, use it or i'll find you |
01:24:45 | FromDiscord | <Ayy Lmao> So how would I go about passing a substring of a larger string to this? |
01:24:59 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "It's just the best": Obviously I need to mess around with them more haha |
01:25:13 | FromDiscord | <Elegantbeef> `myString.toOpenArray(3, 4)` |
01:25:35 | FromDiscord | <Ayy Lmao> And I'm guessing that avoids copying? |
01:25:42 | FromDiscord | <Elegantbeef> Yes |
01:26:13 | FromDiscord | <Ayy Lmao> Awesome, I'll give it a try, although I might run into unicode problems possibly. |
01:26:52 | FromDiscord | <huantian> Doesn’t the c code run into Unicode problems? |
01:27:48 | FromDiscord | <Elegantbeef> Yes |
01:27:52 | FromDiscord | <Elegantbeef> It takes a `char` if it is supposed to be unicode aware make it clear |
01:28:16 | FromDiscord | <Elegantbeef> It's probably just incrementing the pointer until `\0` or it hits the pointer you give it |
01:28:35 | FromDiscord | <Elegantbeef> As such if you give it an arbitrary point in the string it's going to error if a unicode rune |
01:29:02 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "It's probably just incrementing": I think that's what it does. It's been a minute since I've messed around with unicode so I'll need to think about how to make a nice interface that takes that into account. |
01:36:17 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxD |
01:38:21 | FromDiscord | <Rika> That last one makes no sense |
01:43:12 | FromDiscord | <Ayy Lmao> I have no idea why, I've ran into it before though. oa[^1].unsafeAddr gives the error `Error: expression has no address` and oa[oa.len - 1].unsafeAddr works. |
01:45:48 | FromDiscord | <sOkam!> how do you map a `Type const variable` in nim? is `ptr variable` enough, or how do you represent the const part? |
01:46:16 | FromDiscord | <sOkam!> (edit) "`ptr variable`" => "`var variable :ptr Type`" |
01:46:35 | FromDiscord | <Ayy Lmao> casting to a cstring is getting rid of the warnings for me. |
01:47:46 | FromDiscord | <Ayy Lmao> In reply to @sOkam! "how do you map": For binding to c? I've always just ignored it and done ptr Type |
01:49:53 | FromDiscord | <sOkam!> praying that nothing breaks 🙏 |
01:50:24 | FromDiscord | <Rika> In reply to @sOkam! "how do you map": You can’t represent constant pointers in Nim iirc |
01:50:47 | FromDiscord | <sOkam!> if I want to map a C struct in a binding/wrapper, do I just declare an object with the same fields as the C struct for binding it? |
01:50:52 | FromDiscord | <Rika> Or rather you can’t have the content of a pointer be non variable in Nim |
01:51:00 | * | ltriant quit (Ping timeout: 268 seconds) |
01:52:47 | FromDiscord | <Rika> I forgor 💀 the word immutable |
01:54:42 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxE |
01:56:13 | FromDiscord | <exelotl> In reply to @Rika "Or rather you can’t": Yeah and from the other end, making data be constant while being able to take a pointer to it is also tricky in Nim... Which is annoying for GBA development 🥴 |
01:56:14 | FromDiscord | <huantian> In reply to @Ayy Lmao "casting to a cstring": By this you mean just like .cstring, not `cast` right |
01:56:32 | FromDiscord | <Ayy Lmao> In reply to @huantian "By this you mean": only casting worked, .cstring didn't |
01:56:33 | FromDiscord | <huantian> Though maybe you can just make the function take a ptr char instead of cstring |
01:57:08 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxF |
01:57:57 | FromDiscord | <Ayy Lmao> It is working, but I somehow need to pass data[data.len] as the endpoint but I can't because it is bounds checked. |
01:59:25 | FromDiscord | <Ayy Lmao> Maybe trying to get nim strings to implicitly convert nicely is silly though because I don't think I will be using this function directly much. |
02:00:04 | * | ltriant joined #nim |
02:03:14 | FromDiscord | <huantian> Hm can you just add one to your pointer? Or is that cursed lmao |
02:04:22 | FromDiscord | <Ayy Lmao> I guess I can try, are nim strings null terminated? |
02:06:35 | FromDiscord | <Ayy Lmao> I don't remember how to do pointer arithmetic in nim |
02:09:22 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4sxI |
02:09:36 | * | ltriant quit (Ping timeout: 248 seconds) |
02:10:55 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxJ |
02:10:55 | FromDiscord | <Elegantbeef> `type MyObject = ptr object` |
02:11:07 | FromDiscord | <Elegantbeef> Opaque pointers are opaque pointers |
02:11:30 | FromDiscord | <Elegantbeef> The entire point is to remove the implementation details cause users do not need them |
02:12:05 | FromDiscord | <Ayy Lmao> Elegantbeef I need your help oh wise one |
02:12:17 | FromDiscord | <sOkam!> gotchu, thenks |
02:12:36 | FromDiscord | <Elegantbeef> I'm not wise |
02:13:50 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxL |
02:14:13 | FromDiscord | <Elegantbeef> What? |
02:14:41 | FromDiscord | <Ayy Lmao> The function wants the pointer after as the end point |
02:14:52 | FromDiscord | <Ayy Lmao> So it's drawing my strings one character short |
02:15:33 | FromDiscord | <Ayy Lmao> If nim strings are null terminated then it's ok to do that right? |
02:15:44 | FromDiscord | <Elegantbeef> well `openarray[char]` is not null terminated |
02:16:24 | FromDiscord | <Elegantbeef> If it's stopping at `\0` or the pointer you should be able to do `cast[cstring](cast[uint64](data[^1].addr) + 1)` |
02:16:24 | FromDiscord | <Ayy Lmao> Is there some way to get around this and still have implicitly convertible nim strings? |
02:16:32 | FromDiscord | <Elegantbeef> That should still work and be safe |
02:16:38 | FromDiscord | <sOkam!> why is `csize` deprecated, and replaced with `csize_t`? 😕 |
02:16:45 | FromDiscord | <Ayy Lmao> Ah that's how, I forgot how to do pointer math in nim |
02:16:51 | FromDiscord | <sOkam!> like... why? any reasonable reason? |
02:17:38 | FromDiscord | <Elegantbeef> No clue read the PR that added deprecation there |
02:17:54 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "If it's stopping at": Also, any idea why data[^1].unsafeAddr tells me `Error: expression has no address` and data[data.len - 1].unsafeAddr doesn't? |
02:18:13 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/pull/12497 |
02:18:42 | FromDiscord | <michaelb.eth> sent a code paste, see https://paste.rs/FAZ |
02:19:14 | FromDiscord | <Elegantbeef> Likely cause of how `[^1]` is operated, no clue really |
02:19:47 | * | nanxiao quit (Quit: Client closed) |
02:19:55 | FromDiscord | <huantian> In reply to @Ayy Lmao "I guess I can": Btw yeah |
02:20:30 | FromDiscord | <Elegantbeef> Like i said though `openArray[char]` accepts `seq`, `string`, and `array` |
02:21:05 | FromDiscord | <Elegantbeef> So you can do `drawText(... ['h', 'e', 'l', 'l', 'o']` |
02:21:19 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4sxN |
02:21:23 | FromDiscord | <Elegantbeef> Which is not null terminated, but uses the whole "draw until the end of PTR" |
02:21:40 | FromDiscord | <sOkam!> In reply to @Elegantbeef "https://github.com/nim-lang/Nim/pull/12497": ok, reasonable. ty ✍️ |
02:21:40 | FromDiscord | <Elegantbeef> Use distincts + convertes |
02:21:49 | * | nanxiao joined #nim |
02:22:57 | FromDiscord | <Elegantbeef> converters\ |
02:24:21 | FromDiscord | <michaelb.eth> @sOkam! not sure if it would be helpful for you, but nim-stew's byteutils has `string.fromBytes` and `.toBytes` which have proved useful to me on many occasions |
02:25:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxO |
02:25:50 | FromDiscord | <Elegantbeef> It's not ideal cause you need to do `{Some(Some.AlsoSecond), First}` |
02:26:36 | FromDiscord | <Elegantbeef> But `{First, Some.AlsoSecond}` will "work" but show `Second` instead of `AlsoSecond` |
02:27:18 | FromDiscord | <michaelb.eth> I'm not sure I understand your last two sentences, may have the wrong context in mind |
02:27:37 | FromDiscord | <Elegantbeef> https://github.com/beef331/micros/blob/master/tests/test1.nim#L129-L149 is another idea i've had 😄 |
02:27:54 | FromDiscord | <Elegantbeef> I mean that it's a distinct type which means if you want `set[Some]` you need to convert it to `Some` |
02:28:02 | FromDiscord | <michaelb.eth> ah I see |
02:28:26 | FromDiscord | <Elegantbeef> `${First, Some.AlsoSecond} == "{First, Second}"` |
02:29:21 | FromDiscord | <Elegantbeef> Personally i just avoid any C style enum shite |
02:30:01 | FromDiscord | <michaelb.eth> meaning your find Nim's enums problematic in general? |
02:30:14 | FromDiscord | <Elegantbeef> I find C enums problematic |
02:30:23 | FromDiscord | <Ayy Lmao> Is data.toOpenArray(0, 5) different than data[0..<5]? |
02:30:28 | FromDiscord | <Elegantbeef> Yes |
02:30:31 | FromDiscord | <Elegantbeef> The latter makes a sequence |
02:30:35 | FromDiscord | <Elegantbeef> Which is a copy |
02:30:40 | FromDiscord | <Ayy Lmao> Darn |
02:30:45 | FromDiscord | <Ayy Lmao> I guess it makes sense |
02:30:52 | FromDiscord | <Elegantbeef> The former is a view into the collection |
02:31:06 | FromDiscord | <Elegantbeef> Nim doesnt have a borrow checker so the latter cannot really be a `openArray` |
02:31:26 | FromDiscord | <Elegantbeef> you can always if you want implement a `{}` template to make openArraying less ugly |
02:32:08 | FromDiscord | <Ayy Lmao> I don't think I will be interfacing with this function much but I am curious about how you would go about doing that. |
02:32:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxQ |
02:32:53 | FromDiscord | <Elegantbeef> replace `{}` with whatever syntax you prefer \: |
02:33:31 | FromDiscord | <Ayy Lmao> What exactly are Slice and HSlice? |
02:33:42 | FromDiscord | <Elegantbeef> Builtin types |
02:33:54 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#HSlice |
02:34:26 | FromDiscord | <Elegantbeef> believe it or not `a[b..c]` is done in Nim's userspace |
02:34:33 | FromDiscord | <Elegantbeef> As is `a[^1]` |
02:34:39 | FromDiscord | <Elegantbeef> There is no explicit compiler support there |
02:35:03 | FromDiscord | <Ayy Lmao> Interesting, I was always curious about how those things worked. |
02:36:56 | * | ltriant joined #nim |
02:41:36 | * | ltriant quit (Ping timeout: 248 seconds) |
02:41:50 | FromDiscord | <michaelb.eth> @ElegantBeef have you ever considered putting together a Nim cheatsheet? |
02:42:15 | FromDiscord | <michaelb.eth> you know, so one day if you're dead, your knowledge can live on? |
02:42:34 | FromDiscord | <Elegantbeef> I was promised chatgpt would be here to help with that |
02:42:58 | FromDiscord | <Elegantbeef> At the point i make a "cheatsheet" i should just write a book |
02:43:38 | FromDiscord | <michaelb.eth> from what I've observed, you seem to have the knowledge to write a good one! |
02:45:36 | FromDiscord | <Mr Gandolfio> In reply to @Elegantbeef "At the point i": I'd read your book 👀 |
02:46:24 | termer | Elegantbeef knows an absurd amount about Nim |
02:46:39 | FromDiscord | <Elegantbeef> What a useless trait to have |
02:51:28 | FromDiscord | <Elegantbeef> Thinking about it, it's like having the ability to say how many jellybeans are inside of any jar |
02:59:23 | * | rez joined #nim |
03:00:15 | FromDiscord | <michaelb.eth> it's not useless to those who value the insights, right? |
03:01:10 | FromDiscord | <michaelb.eth> sent a code paste, see https://paste.rs/Os4 |
03:01:22 | FromDiscord | <michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4sxW" => "https://play.nim-lang.org/#ix=4sxV" |
03:01:26 | FromDiscord | <Elegantbeef> It's a converter we defined |
03:02:33 | FromDiscord | <Yardanico> In reply to @michaelb.eth "where does `toBase` come": converters are converters because they can be called automatically by the compiler |
03:03:06 | FromDiscord | <michaelb.eth> I've used / experimented with converters previously, but I don't recall seeing `toBase` |
03:03:15 | FromDiscord | <michaelb.eth> probably remembering incorrectly |
03:03:20 | FromDiscord | <Yardanico> not sure what do you mean |
03:03:23 | FromDiscord | <Yardanico> converter names don't matter at all |
03:03:27 | FromDiscord | <Yardanico> their signature is what matters |
03:03:35 | FromDiscord | <Elegantbeef> `toBase` is just the name we gave the proceure |
03:03:39 | FromDiscord | <Yardanico> you could name it MYMAGICALTHING and it'll work exactly the same |
03:03:47 | FromDiscord | <Elegantbeef> if you really want you can do `Some.AlsoSecond.toBase` |
03:03:58 | FromDiscord | <Elegantbeef> It's just a nice name that you can use to invoke it if you want to |
03:04:57 | FromDiscord | <michaelb.eth> ah, I get it now |
03:05:44 | * | ltriant joined #nim |
03:08:30 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4sy0 |
03:10:17 | FromDiscord | <Yardanico> do you mean a warning for converting to itself or something else? because casting itself is dangerous, it's different from type conversion |
03:10:46 | FromDiscord | <michaelb.eth> it's a warning about doing a type conversion for an enum with holes (the code above doesn't have holes, but my use case does) |
03:10:52 | FromDiscord | <Elegantbeef> Probably needs to be `Faked[Second](Second.ord))` |
03:11:11 | FromDiscord | <Elegantbeef> Seems like it's a 'bug' |
03:11:28 | FromDiscord | <michaelb.eth> given the nature of the "hack" (it's all behind the scenes), I'm okay with the cast |
03:12:00 | FromDiscord | <michaelb.eth> In reply to @Elegantbeef "Seems like it's a": probably not, I didn't give enough context for my actual use case, i.e. enum with holes |
03:13:16 | FromDiscord | <Elegantbeef> You're converting from the enum to the enum |
03:13:24 | FromDiscord | <Elegantbeef> It's clearly a bug that the check doesnt see if it's distinct base is the same |
03:15:32 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/63b4b3c5b8c930ffc271c5e4e1a446e8616b2571/compiler/sempass2.nim#L1273 yea i think `abstractInst` does not include `tyDistinct` |
03:23:34 | FromDiscord | <Elegantbeef> I say that then realise it doesnt check if the target is the same type |
03:43:58 | FromDiscord | <morgan> anyone familiar with boxy know if there's an easy way to give it a tilesheet and have it let me use each tile? if not i'll use a splitter i wrote a while back and split it to individual tiles to let boxy put them back together |
03:44:05 | * | rez quit (Quit: much snoozes...) |
03:44:36 | FromDiscord | <morgan> gonna do some ui stuff and i feel like putting them in one image to draw |
03:44:51 | FromDiscord | <morgan> eventually i should port that python code to nim |
03:45:44 | FromDiscord | <morgan> then i could import the base image and a tile definition file and then instead of exporting to png have some way to give that directly to boxy and update all the keys |
03:47:12 | * | nanxiao quit (Quit: Client closed) |
03:51:15 | FromDiscord | <morgan> that might actually be a quicker thing to finish than this project lol |
03:52:37 | FromDiscord | <morgan> i wanted to write a genetic algorithm thing to make analog circuits that approximate some function and couldn't get ngspice to work (i ran into so many issues) and decided i'd rather write my own than run into a wall any longer |
04:35:41 | * | arkurious quit (Quit: Leaving) |
04:35:42 | * | derpydoo quit (Quit: derpydoo) |
04:38:49 | * | derpydoo joined #nim |
04:48:46 | * | nanxiao joined #nim |
05:16:24 | * | casaca quit (Ping timeout: 250 seconds) |
05:18:06 | * | casaca joined #nim |
05:35:21 | * | advesperacit joined #nim |
05:54:38 | * | azimut quit (Ping timeout: 255 seconds) |
06:02:29 | * | kenran joined #nim |
06:06:30 | * | nanxiao quit (Quit: Client closed) |
06:28:56 | * | nanxiao joined #nim |
06:47:43 | * | Notxor joined #nim |
06:48:52 | * | PMunch joined #nim |
06:50:44 | FromDiscord | <HitBlast> Is there a way to get the data for each proc without actually calling the `retrieveServerData()` proc every time? I know there are pragmas / macros which can be used like Python decorators but I'm new to Nim so I can't really figure out. :P https://media.discordapp.net/attachments/371759389889003532/1092340391451308094/Screenshot_2023-04-03_at_12.47.25_PM.png |
06:52:37 | FromDiscord | <Elegantbeef> Actually parse the json inside `retrieveServerData` then just access it |
06:56:50 | FromDiscord | <HitBlast> In reply to @Elegantbeef "Actually parse the json": How can I do so? |
06:58:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syt |
07:10:42 | FromDiscord | <HitBlast> sent a code paste, see https://play.nim-lang.org/#ix=4syy |
07:12:08 | FromDiscord | <HitBlast> sent a code paste, see https://play.nim-lang.org/#ix=4syz |
07:13:37 | FromDiscord | <Elegantbeef> I'm going to say there is 0 reason to use a macro here |
07:16:18 | FromDiscord | <Rika> In reply to @HitBlast "Looks neat, but what": I don’t understand, you want to do a network call every time you call a function? |
07:16:27 | FromDiscord | <Elegantbeef> rapidly |
07:16:52 | FromDiscord | <Rika> What does that even mean in this context |
07:21:40 | FromDiscord | <Elegantbeef> Rapidly |
07:23:27 | FromDiscord | <huantian> What probably could be cool is a macro that given a ServerInfo object (that has a port, ip, field etc) to generate the procs that make the web request and json parsing automatically |
07:23:47 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4syF |
07:25:19 | FromDiscord | <Elegantbeef> I mean a generic procedure is enough huan 😄 |
07:26:45 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4syG |
07:27:10 | FromDiscord | <huantian> Then you can just do `myServer.fetchServerData.await.port` |
07:27:22 | FromDiscord | <huantian> And it’ll do the request each time you want it |
07:27:31 | FromDiscord | <huantian> (edit) "want it" => "get the port" |
07:27:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syH |
07:28:10 | FromDiscord | <Elegantbeef> There we go a generic solution that works without writing a macro manually |
07:28:37 | * | def- quit (Quit: -) |
07:29:35 | FromDiscord | <Elegantbeef> Or we can just live in the year 2023 and use std/jsonutils |
07:29:36 | FromDiscord | <Elegantbeef> Or use jsony |
07:29:36 | FromDiscord | <Elegantbeef> Or use jason |
07:29:37 | FromDiscord | <Elegantbeef> Or use .... |
07:30:06 | * | def- joined #nim |
07:30:42 | FromDiscord | <huantian> @HitBlast i hope you don’t think we’re making fun of you lol, just a tad confused on what you’re looking for haha |
07:31:05 | FromDiscord | <Elegantbeef> I'm mostly making fun of huan |
07:33:08 | * | def- quit (Client Quit) |
07:33:33 | FromDiscord | <HitBlast> In reply to @huantian "<@867993514917654588> i hope you": xD I ain't thinking that way so not a biggie |
07:33:50 | FromDiscord | <HitBlast> I was searching for a method which didn't require me to call retrieveServerData() every time |
07:33:52 | * | kenran quit (Ping timeout: 268 seconds) |
07:34:20 | FromDiscord | <HitBlast> (edit) "call" => "type" | "typeretrieveServerData() every ... timeupdate" added "time, but at the same" | "retrieveServerData() everytime, but at the sametime ... " added "update the server instead of keeping it static" |
07:34:25 | FromDiscord | <HitBlast> (edit) "I was searching for a method which didn't require me to type retrieveServerData() every time, but at the same time update the server ... instead" added "data" |
07:36:54 | FromDiscord | <Rika> If, when using a function, you do something before it over and over again, that something should ought to be done in the function |
07:36:59 | FromDiscord | <Rika> (edit) removed "should" |
07:47:10 | FromDiscord | <huantian> In reply to @HitBlast "Is there a way": I think then that other than parsing the json into a proper Nim object in your retrieveServerData, the amount of code saved by an abstraction is not worth it compared to the complexity of the abstraction |
07:47:50 | FromDiscord | <huantian> Unless you have to do this for like 10+ fields maybe |
07:48:56 | FromDiscord | <huantian> Since what you’re essentially doing is aliasing `server.retrieveServerData.await.ip` to `server.ip.await` |
08:03:15 | * | kenran joined #nim |
08:04:19 | FromDiscord | <HitBlast> In reply to @huantian "Unless you have to": well yeah that's the problem here |
08:19:39 | FromDiscord | <huantian> Perhaps a macro would work then? Idk beef do you have thoughts or are you asleep yet |
08:24:12 | FromDiscord | <Elegantbeef> A dot operator macro would work, but it's like "why" |
08:24:32 | FromDiscord | <Elegantbeef> A macro here just adds complexity with negligible benefits |
08:25:54 | * | nanxiao quit (Quit: Client closed) |
08:26:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syW |
08:26:32 | FromDiscord | <Elegantbeef> Now you do `server.field[: int]("ip")` problem solved 😄 |
08:30:44 | FromDiscord | <huantian> But like your static typing it’s gone! |
08:30:59 | * | nanxiao joined #nim |
08:31:06 | FromDiscord | <huantian> Well kinda ish |
08:32:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syX |
08:32:24 | FromDiscord | <Elegantbeef> Whoops no need for the generic parameter |
08:32:30 | FromDiscord | <Elegantbeef> But this is all just cursed |
08:33:37 | FromDiscord | <Elegantbeef> Technically an async procedure should be made in the dot operator case that is returned, that way you can `await` or `waitfor` it |
08:36:32 | * | def- joined #nim |
09:02:46 | NimEventer | New thread by cmc: Generic initialization procedure with default type, see https://forum.nim-lang.org/t/10064 |
09:18:48 | * | ltriant quit (Ping timeout: 265 seconds) |
09:18:57 | * | ltriant joined #nim |
09:26:40 | * | derpydoo quit (Ping timeout: 260 seconds) |
09:46:47 | FromDiscord | <kcvinker> I have a variable like this.↵`result.mFmtStr = "%.2f"`↵How do I pass this `mFmtStr` to `fmt` function ? |
09:48:04 | PMunch | I don't think you can, fmt is compile-time IIRC |
09:48:59 | * | nanxiao quit (Quit: Client closed) |
09:49:08 | FromDiscord | <kcvinker> Then what is the equivalent of `sprintf` in nim ? |
09:49:37 | * | vsantana joined #nim |
09:52:27 | PMunch | Well you can use sprintf |
09:53:35 | PMunch | Or if you don't actually change it at runtime you could have the format string be a static element of your object |
09:53:52 | PMunch | Hard to tell what the best path is without knowing what you're actually trying to achieve |
09:54:39 | PMunch | I mean if you only need to format floats then there's formatFloat in strutils |
09:55:16 | FromDiscord | <kcvinker> In reply to @PMunch "Or if you don't": I'll choose first option. Because, I am not sure about the second case |
09:55:56 | * | vsantana left #nim (#nim) |
09:56:05 | PMunch | What are you formatting? |
09:59:28 | FromDiscord | <kcvinker> A float value |
10:00:03 | PMunch | Then formatFloat from strutils is probably your plan |
10:00:27 | FromDiscord | <kcvinker> In reply to @PMunch "Then formatFloat from strutils": Thank you |
10:03:28 | FromDiscord | <turbo> sent a code paste, see https://play.nim-lang.org/#ix=4sza |
10:06:03 | PMunch | Templates are hygenic, so the `arg` in the template isn't `arg` outside of the template |
10:06:15 | PMunch | To fix this you need to mark it as `inject`-ed like this: https://play.nim-lang.org/#ix=4szc |
10:08:31 | FromDiscord | <turbo> Ah, that works, thx |
10:46:25 | * | jmdaemon quit (Ping timeout: 252 seconds) |
10:58:28 | * | kenran quit (Remote host closed the connection) |
11:04:16 | * | kenran joined #nim |
11:18:36 | * | derpydoo joined #nim |
12:06:44 | FromDiscord | <luteva> how can i get the currently used memory in bytes? |
12:08:44 | PMunch | https://nim-lang.org/docs/system.html#getOccupiedMem |
12:08:59 | PMunch | Or getTotalMem I guess |
12:34:04 | * | kenran` joined #nim |
12:35:35 | * | kenran quit (Ping timeout: 246 seconds) |
13:24:13 | advesperacit | is there a way to release some unused memory held back to the os, or is the only way to compile with -d:useMalloc? |
13:33:09 | PMunch | I believe you'd have to use -d:useMalloc |
13:33:18 | PMunch | Why is this a problem for you though? |
13:42:06 | advesperacit | I don't know if it's an actual problem, but it makes me uncomfortable when 2GB is claimed by a process that will only use about 400MB of that for the next 10 minutes |
13:44:23 | advesperacit | is the nim process aware of the general OS memory situation or is it all left to the oomkiller to sort out? I mean, will the process relinquish some memory if the free memory starts to run out |
13:44:39 | * | kenran` quit (Remote host closed the connection) |
14:12:22 | * | PMunch quit (Quit: Leaving) |
14:13:37 | * | xet7 joined #nim |
14:17:46 | FromDiscord | <kcvinker> I am using `formatValue` function to convert a float value to string. So far so good. But sometimes I want to display the text without a decimal point and fraction digits. For example, `75.00` to `75`. How to do it ? |
14:18:26 | FromDiscord | <Andreas> In reply to @kcvinker "I am using `formatValue`": round / convert to int |
14:20:12 | FromDiscord | <kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4sA3 |
14:21:10 | FromDiscord | <kcvinker> The question is , when user wants to display an int, what kind of format string should I use ? |
14:24:30 | FromDiscord | <kcvinker> In reply to @Andreas "round / convert to": If I convert it to int, I think I should need to use another formatting function. Because, formatValue accepts a float. |
14:26:27 | FromDiscord | <Andreas> In reply to @kcvinker "If I convert it": yea, you have two cases now, maybe use an if-stmt |
14:27:57 | * | azimut joined #nim |
14:28:08 | * | arkurious joined #nim |
14:44:53 | NimEventer | New thread by ringabout: My Nim Development Weekly Report (4/2), see https://forum.nim-lang.org/t/10065 |
14:45:32 | NimEventer | New post on r/nim by cmnews08: Want to get started with nim, where is the best source for an easy tutorial?, see https://reddit.com/r/nim/comments/12ammp7/want_to_get_started_with_nim_where_is_the_best/ |
15:37:50 | * | rez joined #nim |
15:38:25 | * | rez quit (Client Quit) |
15:41:47 | * | arkurious quit (Ping timeout: 256 seconds) |
15:54:27 | * | arkurious joined #nim |
15:54:29 | * | arkurious quit (Remote host closed the connection) |
16:25:56 | FromDiscord | <Ayy Lmao> Is there a way to do `runeLen` or `toRunes` on an `openArray[char]` without copying it into a string? |
16:33:48 | Amun-Ra | that's would not make much sense… do you mean openArray[byte]? |
16:33:54 | Amun-Ra | that* |
16:34:42 | Amun-Ra | I mean utf-8 octets are bytes, not chars |
16:37:23 | FromDiscord | <Ayy Lmao> Hmmm, well I have this function I am passing openArray[char] to so I can implicitly convert nim strings. Maybe I should be using openArray[byte] though? |
16:38:53 | Amun-Ra | looks like runeLen works on strings only |
16:39:36 | Amun-Ra | I'm not a fan of using string as char/byte container |
16:40:41 | FromDiscord | <Ayy Lmao> The reason I am doing it is to pass to a function in a c library without making a copy of the string. |
16:41:39 | Amun-Ra | look at runeLen and rewrite it |
16:42:08 | Amun-Ra | just change string to openArray[char] and it would work |
16:42:35 | FromDiscord | <Ayy Lmao> I might actually end up not needing to count the runes for what I am doing but I will try that if I find that I need to. |
16:54:06 | FromDiscord | <morgan> In reply to @PMunch "Or getTotalMem I guess": at first i read this as getTotalMen and was confused lmao |
17:13:09 | FromDiscord | <michaelb.eth> openArray[byte], openArray[char], openArray[uint8]… in practice is there much difference? |
17:13:54 | * | rockcavera joined #nim |
17:14:29 | Amun-Ra | byte is uint8 |
17:15:38 | Amun-Ra | diff. between byte and char is semantic |
17:16:22 | FromDiscord | <michaelb.eth> https://nim-lang.org/docs/system.html#char |
17:16:31 | FromDiscord | <michaelb.eth> 8 bit, unsigned |
17:17:16 | FromDiscord | <michaelb.eth> So you can .uint8 or .byte or vice versa, at least I haven’t had any problems doing so |
17:17:30 | FromDiscord | <michaelb.eth> But I may be missing something subtle |
17:18:39 | Amun-Ra | https://play.nim-lang.org/#ix=4sAI |
17:20:21 | FromDiscord | <michaelb.eth> Sure, but I meant that if you’re e.g. looping over an array/seq of char you can convert to .uint8 trivially |
17:20:51 | Amun-Ra | yes, char is just a distinct type for representing characters instead of values; it has similar range to byte |
17:21:19 | Amun-Ra | s/of values/of octets/ |
17:28:18 | FromDiscord | <Hourglass [She/Her]> Anyone have recommendations for documenting a websocket API I'm making? |
17:29:54 | FromDiscord | <Phil> Documenting in what sense? |
17:30:09 | FromDiscord | <Phil> Style of documentation? Tooling to use? |
17:30:43 | FromDiscord | <Hourglass [She/Her]> Tooling is what I'm looking for specifically |
17:31:16 | FromDiscord | <Phil> Nimibook is my go to for having examples that compile |
17:31:34 | FromDiscord | <Hourglass [She/Her]> Hm |
17:31:37 | FromDiscord | <Phil> It's a kind of extra testing layer in a sense |
17:32:00 | FromDiscord | <Phil> And the entire "book" setup is very helpful with structuring |
17:32:20 | FromDiscord | <Hourglass [She/Her]> Yeah makes sense, thanks Phil |
17:32:45 | FromDiscord | <Hourglass [She/Her]> I was more looking for something kinda like OpenAPI? |
17:36:20 | FromDiscord | <michaelb.eth> websocket is a pretty dumb pipe compared to http (with its set of verbs and req/resp paradigm)↵↵How would you describe the websocket api you’ve made, is it req/resp? or what exactly |
17:38:31 | FromDiscord | <michaelb.eth> json-rpc for example is transport agnostic, so an api described in its terms can be used over websocket or plain http or Unix domain sockets or whatever really |
17:39:12 | FromDiscord | <michaelb.eth> (edit) removed "really" |
18:16:56 | FromDiscord | <Hourglass [She/Her]> I'd be sending events that have happened, for example |
18:17:13 | FromDiscord | <Hourglass [She/Her]> Oh yeah, any recommendations for simple REST APIs? |
18:32:33 | NimEventer | New thread by guzba: Nim in production #2: 100k+ WebSocket connections on one small VM, lots of CPU and RAM to spare, see https://forum.nim-lang.org/t/10066 |
18:33:05 | * | Notxor quit (Quit: Leaving) |
18:37:06 | * | Notxor joined #nim |
18:41:12 | * | progranner joined #nim |
19:23:26 | * | jmdaemon joined #nim |
20:12:27 | * | LyndsySimon joined #nim |
20:34:53 | * | Jjp137 quit (Quit: Leaving) |
20:39:25 | * | Jjp137 joined #nim |
20:51:33 | * | Notxor quit (Remote host closed the connection) |
20:55:53 | * | advesperacit quit () |
21:17:32 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
22:45:38 | * | derpydoo quit (Quit: derpydoo) |
23:15:22 | * | Jjp137 quit (Quit: Leaving) |
23:19:06 | FromDiscord | <jmgomez> Where is codegenDecl defined in the src of the compiler? Cant find it |
23:20:44 | FromDiscord | <Elegantbeef> It's magic |
23:20:53 | FromDiscord | <Elegantbeef> So probably `mCodgenDecl` |
23:21:45 | FromDiscord | <Elegantbeef> Ah it's a pragma right, so it's it's not m |
23:22:16 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/31d3606fe82855dc63cb59fa509577ba1c3a3b86/compiler/pragmas.nim#L1117 |
23:23:57 | FromDiscord | <jmgomez> oh god, it's worst of what I thought nvm. Thanks though! |
23:24:36 | FromDiscord | <jmgomez> sent a code paste, see https://paste.rs/nY7 |
23:25:11 | FromDiscord | <jmgomez> just wanted to check out how difficult could it be to implement it for types |
23:25:34 | FromDiscord | <jmgomez> as you like to say, night impossible ;P |
23:26:31 | FromDiscord | <Elegantbeef> Nigh! |
23:26:51 | FromDiscord | <jmgomez> right XD |
23:27:06 | FromDiscord | <jmgomez> (edit) "night" => "nigh" |
23:27:36 | FromDiscord | <Elegantbeef> I feel like in the case of types it's just best to use emit then import them |
23:27:54 | * | progranner joined #nim |
23:29:28 | FromDiscord | <jmgomez> yes, that's what Im doing for the vfunc stuff |
23:30:11 | FromDiscord | <jmgomez> at some point I want to implement fields though (they are just functions for now) and not sure if there will be edge cases |
23:30:59 | FromDiscord | <jmgomez> I guess as long as not using ref types all is good |
23:34:42 | * | Jjp137 joined #nim |
23:36:28 | FromDiscord | <Elegantbeef> Though it shouldnt be too hard to implement codegendecl for types, but it's up to you if you want to venture down that path |
23:40:58 | FromDiscord | <jmgomez> Checking the old (1.6.12) version of the compiler the hook roughly seem to follow genProc but in genTypeInfo |
23:41:36 | FromDiscord | <jmgomez> I need to keep going with NUE and try to dont get too sidetracked but will revisit it in a few months I guess |
23:47:55 | * | progranner quit (Ping timeout: 276 seconds) |
23:52:51 | * | progranner joined #nim |
23:59:28 | * | progranner quit (Ping timeout: 248 seconds) |