<< 03-04-2023 >>

00:26:24*derpydoo joined #nim
00:28:31FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4sxv
00:29:11FromDiscord<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:13FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxw
00:29:41FromDiscord<sOkam!> right but then you lose the name qualifier of the enum with pure
00:29:54FromDiscord<sOkam!> not a bad idea though 🤔
00:30:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxx
00:31:09*MadcapJake joined #nim
00:31:30FromDiscord<sOkam!> good one
00:45:24FromDiscord<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:47FromDiscord<Ayy Lmao> Does converting something to itself have any overhead?
00:45:55FromDiscord<Elegantbeef> `--hint[HintName]: off`
00:45:59FromDiscord<Elegantbeef> Nah it's a type system thing
00:47:00FromDiscord<Ayy Lmao> In reply to @Elegantbeef "`--hint[HintName]: off`": Is there a way to do that for a specific block of code?
00:47:10FromDiscord<Elegantbeef> `{.hint[Name]: off`
00:47:19FromDiscord<Ayy Lmao> Oh cool, I'll try it
00:48:14FromDiscord<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:24FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxA
01:18:49FromDiscord<Ayy Lmao> Where it takes a cstring and a start and end position.
01:19:39FromDiscord<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:57FromDiscord<Rika> Wait, I don’t understand the last two arguments
01:20:28FromDiscord<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:45FromDiscord<Ayy Lmao> So ideally I would maintain that optimization for drawing multiple lines.
01:21:33FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxB
01:21:36FromDiscord<Ayy Lmao> A more complete snippet from the header.
01:21:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxC
01:22:13FromDiscord<huantian> Wouldn’t it be the addr of the last element
01:22:15FromDiscord<huantian> Not 1
01:22:21FromDiscord<Elegantbeef> Yea meant `^1`
01:23:01FromDiscord<Ayy Lmao> I need to experiment but the data might need to be index by rune
01:23:33FromDiscord<Ayy Lmao> Can I pass a string to an openArray? I haven't tried that before.
01:23:40FromDiscord<Elegantbeef> Yes
01:23:51FromDiscord<Elegantbeef> Seq, array, and string's convert implicitly to openarray
01:24:21FromDiscord<Elegantbeef> You can also convert a pointer to an open array like i showed yesterday
01:24:37FromDiscord<Elegantbeef> It's just the best data type, use it or i'll find you
01:24:45FromDiscord<Ayy Lmao> So how would I go about passing a substring of a larger string to this?
01:24:59FromDiscord<Ayy Lmao> In reply to @Elegantbeef "It's just the best": Obviously I need to mess around with them more haha
01:25:13FromDiscord<Elegantbeef> `myString.toOpenArray(3, 4)`
01:25:35FromDiscord<Ayy Lmao> And I'm guessing that avoids copying?
01:25:42FromDiscord<Elegantbeef> Yes
01:26:13FromDiscord<Ayy Lmao> Awesome, I'll give it a try, although I might run into unicode problems possibly.
01:26:52FromDiscord<huantian> Doesn’t the c code run into Unicode problems?
01:27:48FromDiscord<Elegantbeef> Yes
01:27:52FromDiscord<Elegantbeef> It takes a `char` if it is supposed to be unicode aware make it clear
01:28:16FromDiscord<Elegantbeef> It's probably just incrementing the pointer until `\0` or it hits the pointer you give it
01:28:35FromDiscord<Elegantbeef> As such if you give it an arbitrary point in the string it's going to error if a unicode rune
01:29:02FromDiscord<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:17FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxD
01:38:21FromDiscord<Rika> That last one makes no sense
01:43:12FromDiscord<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:48FromDiscord<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:16FromDiscord<sOkam!> (edit) "`ptr variable`" => "`var variable :ptr Type`"
01:46:35FromDiscord<Ayy Lmao> casting to a cstring is getting rid of the warnings for me.
01:47:46FromDiscord<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:53FromDiscord<sOkam!> praying that nothing breaks 🙏
01:50:24FromDiscord<Rika> In reply to @sOkam! "how do you map": You can’t represent constant pointers in Nim iirc
01:50:47FromDiscord<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:52FromDiscord<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:47FromDiscord<Rika> I forgor 💀 the word immutable
01:54:42FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxE
01:56:13FromDiscord<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:14FromDiscord<huantian> In reply to @Ayy Lmao "casting to a cstring": By this you mean just like .cstring, not `cast` right
01:56:32FromDiscord<Ayy Lmao> In reply to @huantian "By this you mean": only casting worked, .cstring didn't
01:56:33FromDiscord<huantian> Though maybe you can just make the function take a ptr char instead of cstring
01:57:08FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxF
01:57:57FromDiscord<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:25FromDiscord<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:14FromDiscord<huantian> Hm can you just add one to your pointer? Or is that cursed lmao
02:04:22FromDiscord<Ayy Lmao> I guess I can try, are nim strings null terminated?
02:06:35FromDiscord<Ayy Lmao> I don't remember how to do pointer arithmetic in nim
02:09:22FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4sxI
02:09:36*ltriant quit (Ping timeout: 248 seconds)
02:10:55FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxJ
02:10:55FromDiscord<Elegantbeef> `type MyObject = ptr object`
02:11:07FromDiscord<Elegantbeef> Opaque pointers are opaque pointers
02:11:30FromDiscord<Elegantbeef> The entire point is to remove the implementation details cause users do not need them
02:12:05FromDiscord<Ayy Lmao> Elegantbeef I need your help oh wise one
02:12:17FromDiscord<sOkam!> gotchu, thenks
02:12:36FromDiscord<Elegantbeef> I'm not wise
02:13:50FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4sxL
02:14:13FromDiscord<Elegantbeef> What?
02:14:41FromDiscord<Ayy Lmao> The function wants the pointer after as the end point
02:14:52FromDiscord<Ayy Lmao> So it's drawing my strings one character short
02:15:33FromDiscord<Ayy Lmao> If nim strings are null terminated then it's ok to do that right?
02:15:44FromDiscord<Elegantbeef> well `openarray[char]` is not null terminated
02:16:24FromDiscord<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:24FromDiscord<Ayy Lmao> Is there some way to get around this and still have implicitly convertible nim strings?
02:16:32FromDiscord<Elegantbeef> That should still work and be safe
02:16:38FromDiscord<sOkam!> why is `csize` deprecated, and replaced with `csize_t`? 😕
02:16:45FromDiscord<Ayy Lmao> Ah that's how, I forgot how to do pointer math in nim
02:16:51FromDiscord<sOkam!> like... why? any reasonable reason?
02:17:38FromDiscord<Elegantbeef> No clue read the PR that added deprecation there
02:17:54FromDiscord<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:13FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/pull/12497
02:18:42FromDiscord<michaelb.eth> sent a code paste, see https://paste.rs/FAZ
02:19:14FromDiscord<Elegantbeef> Likely cause of how `[^1]` is operated, no clue really
02:19:47*nanxiao quit (Quit: Client closed)
02:19:55FromDiscord<huantian> In reply to @Ayy Lmao "I guess I can": Btw yeah
02:20:30FromDiscord<Elegantbeef> Like i said though `openArray[char]` accepts `seq`, `string`, and `array`
02:21:05FromDiscord<Elegantbeef> So you can do `drawText(... ['h', 'e', 'l', 'l', 'o']`
02:21:19FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4sxN
02:21:23FromDiscord<Elegantbeef> Which is not null terminated, but uses the whole "draw until the end of PTR"
02:21:40FromDiscord<sOkam!> In reply to @Elegantbeef "https://github.com/nim-lang/Nim/pull/12497": ok, reasonable. ty ✍️
02:21:40FromDiscord<Elegantbeef> Use distincts + convertes
02:21:49*nanxiao joined #nim
02:22:57FromDiscord<Elegantbeef> converters\
02:24:21FromDiscord<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:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxO
02:25:50FromDiscord<Elegantbeef> It's not ideal cause you need to do `{Some(Some.AlsoSecond), First}`
02:26:36FromDiscord<Elegantbeef> But `{First, Some.AlsoSecond}` will "work" but show `Second` instead of `AlsoSecond`
02:27:18FromDiscord<michaelb.eth> I'm not sure I understand your last two sentences, may have the wrong context in mind
02:27:37FromDiscord<Elegantbeef> https://github.com/beef331/micros/blob/master/tests/test1.nim#L129-L149 is another idea i've had 😄
02:27:54FromDiscord<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:02FromDiscord<michaelb.eth> ah I see
02:28:26FromDiscord<Elegantbeef> `${First, Some.AlsoSecond} == "{First, Second}"`
02:29:21FromDiscord<Elegantbeef> Personally i just avoid any C style enum shite
02:30:01FromDiscord<michaelb.eth> meaning your find Nim's enums problematic in general?
02:30:14FromDiscord<Elegantbeef> I find C enums problematic
02:30:23FromDiscord<Ayy Lmao> Is data.toOpenArray(0, 5) different than data[0..<5]?
02:30:28FromDiscord<Elegantbeef> Yes
02:30:31FromDiscord<Elegantbeef> The latter makes a sequence
02:30:35FromDiscord<Elegantbeef> Which is a copy
02:30:40FromDiscord<Ayy Lmao> Darn
02:30:45FromDiscord<Ayy Lmao> I guess it makes sense
02:30:52FromDiscord<Elegantbeef> The former is a view into the collection
02:31:06FromDiscord<Elegantbeef> Nim doesnt have a borrow checker so the latter cannot really be a `openArray`
02:31:26FromDiscord<Elegantbeef> you can always if you want implement a `{}` template to make openArraying less ugly
02:32:08FromDiscord<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:36FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4sxQ
02:32:53FromDiscord<Elegantbeef> replace `{}` with whatever syntax you prefer \:
02:33:31FromDiscord<Ayy Lmao> What exactly are Slice and HSlice?
02:33:42FromDiscord<Elegantbeef> Builtin types
02:33:54FromDiscord<Elegantbeef> https://nim-lang.org/docs/system.html#HSlice
02:34:26FromDiscord<Elegantbeef> believe it or not `a[b..c]` is done in Nim's userspace
02:34:33FromDiscord<Elegantbeef> As is `a[^1]`
02:34:39FromDiscord<Elegantbeef> There is no explicit compiler support there
02:35:03FromDiscord<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:50FromDiscord<michaelb.eth> @ElegantBeef have you ever considered putting together a Nim cheatsheet?
02:42:15FromDiscord<michaelb.eth> you know, so one day if you're dead, your knowledge can live on?
02:42:34FromDiscord<Elegantbeef> I was promised chatgpt would be here to help with that
02:42:58FromDiscord<Elegantbeef> At the point i make a "cheatsheet" i should just write a book
02:43:38FromDiscord<michaelb.eth> from what I've observed, you seem to have the knowledge to write a good one!
02:45:36FromDiscord<Mr Gandolfio> In reply to @Elegantbeef "At the point i": I'd read your book 👀
02:46:24termerElegantbeef knows an absurd amount about Nim
02:46:39FromDiscord<Elegantbeef> What a useless trait to have
02:51:28FromDiscord<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:15FromDiscord<michaelb.eth> it's not useless to those who value the insights, right?
03:01:10FromDiscord<michaelb.eth> sent a code paste, see https://paste.rs/Os4
03:01:22FromDiscord<michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4sxW" => "https://play.nim-lang.org/#ix=4sxV"
03:01:26FromDiscord<Elegantbeef> It's a converter we defined
03:02:33FromDiscord<Yardanico> In reply to @michaelb.eth "where does `toBase` come": converters are converters because they can be called automatically by the compiler
03:03:06FromDiscord<michaelb.eth> I've used / experimented with converters previously, but I don't recall seeing `toBase`
03:03:15FromDiscord<michaelb.eth> probably remembering incorrectly
03:03:20FromDiscord<Yardanico> not sure what do you mean
03:03:23FromDiscord<Yardanico> converter names don't matter at all
03:03:27FromDiscord<Yardanico> their signature is what matters
03:03:35FromDiscord<Elegantbeef> `toBase` is just the name we gave the proceure
03:03:39FromDiscord<Yardanico> you could name it MYMAGICALTHING and it'll work exactly the same
03:03:47FromDiscord<Elegantbeef> if you really want you can do `Some.AlsoSecond.toBase`
03:03:58FromDiscord<Elegantbeef> It's just a nice name that you can use to invoke it if you want to
03:04:57FromDiscord<michaelb.eth> ah, I get it now
03:05:44*ltriant joined #nim
03:08:30FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4sy0
03:10:17FromDiscord<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:46FromDiscord<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:52FromDiscord<Elegantbeef> Probably needs to be `Faked[Second](Second.ord))`
03:11:11FromDiscord<Elegantbeef> Seems like it's a 'bug'
03:11:28FromDiscord<michaelb.eth> given the nature of the "hack" (it's all behind the scenes), I'm okay with the cast
03:12:00FromDiscord<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:16FromDiscord<Elegantbeef> You're converting from the enum to the enum
03:13:24FromDiscord<Elegantbeef> It's clearly a bug that the check doesnt see if it's distinct base is the same
03:15:32FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/63b4b3c5b8c930ffc271c5e4e1a446e8616b2571/compiler/sempass2.nim#L1273 yea i think `abstractInst` does not include `tyDistinct`
03:23:34FromDiscord<Elegantbeef> I say that then realise it doesnt check if the target is the same type
03:43:58FromDiscord<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:36FromDiscord<morgan> gonna do some ui stuff and i feel like putting them in one image to draw
03:44:51FromDiscord<morgan> eventually i should port that python code to nim
03:45:44FromDiscord<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:15FromDiscord<morgan> that might actually be a quicker thing to finish than this project lol
03:52:37FromDiscord<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:44FromDiscord<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:37FromDiscord<Elegantbeef> Actually parse the json inside `retrieveServerData` then just access it
06:56:50FromDiscord<HitBlast> In reply to @Elegantbeef "Actually parse the json": How can I do so?
06:58:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syt
07:10:42FromDiscord<HitBlast> sent a code paste, see https://play.nim-lang.org/#ix=4syy
07:12:08FromDiscord<HitBlast> sent a code paste, see https://play.nim-lang.org/#ix=4syz
07:13:37FromDiscord<Elegantbeef> I'm going to say there is 0 reason to use a macro here
07:16:18FromDiscord<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:27FromDiscord<Elegantbeef> rapidly
07:16:52FromDiscord<Rika> What does that even mean in this context
07:21:40FromDiscord<Elegantbeef> Rapidly
07:23:27FromDiscord<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:47FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=4syF
07:25:19FromDiscord<Elegantbeef> I mean a generic procedure is enough huan 😄
07:26:45FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=4syG
07:27:10FromDiscord<huantian> Then you can just do `myServer.fetchServerData.await.port`
07:27:22FromDiscord<huantian> And it’ll do the request each time you want it
07:27:31FromDiscord<huantian> (edit) "want it" => "get the port"
07:27:47FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syH
07:28:10FromDiscord<Elegantbeef> There we go a generic solution that works without writing a macro manually
07:28:37*def- quit (Quit: -)
07:29:35FromDiscord<Elegantbeef> Or we can just live in the year 2023 and use std/jsonutils
07:29:36FromDiscord<Elegantbeef> Or use jsony
07:29:36FromDiscord<Elegantbeef> Or use jason
07:29:37FromDiscord<Elegantbeef> Or use ....
07:30:06*def- joined #nim
07:30:42FromDiscord<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:05FromDiscord<Elegantbeef> I'm mostly making fun of huan
07:33:08*def- quit (Client Quit)
07:33:33FromDiscord<HitBlast> In reply to @huantian "<@867993514917654588> i hope you": xD I ain't thinking that way so not a biggie
07:33:50FromDiscord<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:20FromDiscord<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:25FromDiscord<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:54FromDiscord<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:59FromDiscord<Rika> (edit) removed "should"
07:47:10FromDiscord<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:50FromDiscord<huantian> Unless you have to do this for like 10+ fields maybe
07:48:56FromDiscord<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:19FromDiscord<HitBlast> In reply to @huantian "Unless you have to": well yeah that's the problem here
08:19:39FromDiscord<huantian> Perhaps a macro would work then? Idk beef do you have thoughts or are you asleep yet
08:24:12FromDiscord<Elegantbeef> A dot operator macro would work, but it's like "why"
08:24:32FromDiscord<Elegantbeef> A macro here just adds complexity with negligible benefits
08:25:54*nanxiao quit (Quit: Client closed)
08:26:16FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syW
08:26:32FromDiscord<Elegantbeef> Now you do `server.field[: int]("ip")` problem solved 😄
08:30:44FromDiscord<huantian> But like your static typing it’s gone!
08:30:59*nanxiao joined #nim
08:31:06FromDiscord<huantian> Well kinda ish
08:32:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4syX
08:32:24FromDiscord<Elegantbeef> Whoops no need for the generic parameter
08:32:30FromDiscord<Elegantbeef> But this is all just cursed
08:33:37FromDiscord<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:46NimEventerNew 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:47FromDiscord<kcvinker> I have a variable like this.↵`result.mFmtStr = "%.2f"`↵How do I pass this `mFmtStr` to `fmt` function ?
09:48:04PMunchI don't think you can, fmt is compile-time IIRC
09:48:59*nanxiao quit (Quit: Client closed)
09:49:08FromDiscord<kcvinker> Then what is the equivalent of `sprintf` in nim ?
09:49:37*vsantana joined #nim
09:52:27PMunchWell you can use sprintf
09:53:35PMunchOr if you don't actually change it at runtime you could have the format string be a static element of your object
09:53:52PMunchHard to tell what the best path is without knowing what you're actually trying to achieve
09:54:39PMunchI mean if you only need to format floats then there's formatFloat in strutils
09:55:16FromDiscord<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:05PMunchWhat are you formatting?
09:59:28FromDiscord<kcvinker> A float value
10:00:03PMunchThen formatFloat from strutils is probably your plan
10:00:27FromDiscord<kcvinker> In reply to @PMunch "Then formatFloat from strutils": Thank you
10:03:28FromDiscord<turbo> sent a code paste, see https://play.nim-lang.org/#ix=4sza
10:06:03PMunchTemplates are hygenic, so the `arg` in the template isn't `arg` outside of the template
10:06:15PMunchTo fix this you need to mark it as `inject`-ed like this: https://play.nim-lang.org/#ix=4szc
10:08:31FromDiscord<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:44FromDiscord<luteva> how can i get the currently used memory in bytes?
12:08:44PMunchhttps://nim-lang.org/docs/system.html#getOccupiedMem
12:08:59PMunchOr getTotalMem I guess
12:34:04*kenran` joined #nim
12:35:35*kenran quit (Ping timeout: 246 seconds)
13:24:13advesperacitis 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:09PMunchI believe you'd have to use -d:useMalloc
13:33:18PMunchWhy is this a problem for you though?
13:42:06advesperacitI 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:23advesperacitis 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:46FromDiscord<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:26FromDiscord<Andreas> In reply to @kcvinker "I am using `formatValue`": round / convert to int
14:20:12FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4sA3
14:21:10FromDiscord<kcvinker> The question is , when user wants to display an int, what kind of format string should I use ?
14:24:30FromDiscord<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:27FromDiscord<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:53NimEventerNew thread by ringabout: My Nim Development Weekly Report (4/2), see https://forum.nim-lang.org/t/10065
14:45:32NimEventerNew 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:56FromDiscord<Ayy Lmao> Is there a way to do `runeLen` or `toRunes` on an `openArray[char]` without copying it into a string?
16:33:48Amun-Rathat's would not make much sense… do you mean openArray[byte]?
16:33:54Amun-Rathat*
16:34:42Amun-RaI mean utf-8 octets are bytes, not chars
16:37:23FromDiscord<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:53Amun-Ralooks like runeLen works on strings only
16:39:36Amun-RaI'm not a fan of using string as char/byte container
16:40:41FromDiscord<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:39Amun-Ralook at runeLen and rewrite it
16:42:08Amun-Rajust change string to openArray[char] and it would work
16:42:35FromDiscord<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:06FromDiscord<morgan> In reply to @PMunch "Or getTotalMem I guess": at first i read this as getTotalMen and was confused lmao
17:13:09FromDiscord<michaelb.eth> openArray[byte], openArray[char], openArray[uint8]… in practice is there much difference?
17:13:54*rockcavera joined #nim
17:14:29Amun-Rabyte is uint8
17:15:38Amun-Radiff. between byte and char is semantic
17:16:22FromDiscord<michaelb.eth> https://nim-lang.org/docs/system.html#char
17:16:31FromDiscord<michaelb.eth> 8 bit, unsigned
17:17:16FromDiscord<michaelb.eth> So you can .uint8 or .byte or vice versa, at least I haven’t had any problems doing so
17:17:30FromDiscord<michaelb.eth> But I may be missing something subtle
17:18:39Amun-Rahttps://play.nim-lang.org/#ix=4sAI
17:20:21FromDiscord<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:51Amun-Rayes, char is just a distinct type for representing characters instead of values; it has similar range to byte
17:21:19Amun-Ras/of values/of octets/
17:28:18FromDiscord<Hourglass [She/Her]> Anyone have recommendations for documenting a websocket API I'm making?
17:29:54FromDiscord<Phil> Documenting in what sense?
17:30:09FromDiscord<Phil> Style of documentation? Tooling to use?
17:30:43FromDiscord<Hourglass [She/Her]> Tooling is what I'm looking for specifically
17:31:16FromDiscord<Phil> Nimibook is my go to for having examples that compile
17:31:34FromDiscord<Hourglass [She/Her]> Hm
17:31:37FromDiscord<Phil> It's a kind of extra testing layer in a sense
17:32:00FromDiscord<Phil> And the entire "book" setup is very helpful with structuring
17:32:20FromDiscord<Hourglass [She/Her]> Yeah makes sense, thanks Phil
17:32:45FromDiscord<Hourglass [She/Her]> I was more looking for something kinda like OpenAPI?
17:36:20FromDiscord<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:31FromDiscord<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:12FromDiscord<michaelb.eth> (edit) removed "really"
18:16:56FromDiscord<Hourglass [She/Her]> I'd be sending events that have happened, for example
18:17:13FromDiscord<Hourglass [She/Her]> Oh yeah, any recommendations for simple REST APIs?
18:32:33NimEventerNew 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:06FromDiscord<jmgomez> Where is codegenDecl defined in the src of the compiler? Cant find it
23:20:44FromDiscord<Elegantbeef> It's magic
23:20:53FromDiscord<Elegantbeef> So probably `mCodgenDecl`
23:21:45FromDiscord<Elegantbeef> Ah it's a pragma right, so it's it's not m
23:22:16FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/31d3606fe82855dc63cb59fa509577ba1c3a3b86/compiler/pragmas.nim#L1117
23:23:57FromDiscord<jmgomez> oh god, it's worst of what I thought nvm. Thanks though!
23:24:36FromDiscord<jmgomez> sent a code paste, see https://paste.rs/nY7
23:25:11FromDiscord<jmgomez> just wanted to check out how difficult could it be to implement it for types
23:25:34FromDiscord<jmgomez> as you like to say, night impossible ;P
23:26:31FromDiscord<Elegantbeef> Nigh!
23:26:51FromDiscord<jmgomez> right XD
23:27:06FromDiscord<jmgomez> (edit) "night" => "nigh"
23:27:36FromDiscord<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:28FromDiscord<jmgomez> yes, that's what Im doing for the vfunc stuff
23:30:11FromDiscord<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:59FromDiscord<jmgomez> I guess as long as not using ref types all is good
23:34:42*Jjp137 joined #nim
23:36:28FromDiscord<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:58FromDiscord<jmgomez> Checking the old (1.6.12) version of the compiler the hook roughly seem to follow genProc but in genTypeInfo
23:41:36FromDiscord<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)