<< 15-06-2024 >>

00:22:43FromDiscord<leorize> getTypeInst↵(@Robyn [She/Her])
00:23:19FromDiscord<leorize> using any getType gives you typed ast of the type you want
00:24:05FromDiscord<leorize> which you can use as parameters to other getType\ functions, regardless of whether they support typedesc
00:24:18FromDiscord<Robyn [She/Her]> In reply to @leorize "getTypeInst (<@524288464422830095>)": Thank you, didnt realise this did what i needed aha
00:24:40FromDiscord<leorize> though there's an unwrapping step required to extract the type symbol out of typedesc, but I hope you don't have to think about it
00:25:00FromDiscord<leorize> checkout my union.nim, I have a helper module just for type shenanigans
00:25:35FromDiscord<Robyn [She/Her]> In reply to @leorize "though there's an unwrapping": I have a `typ: typedesc[ref object]` in params if thats what you mean?
00:26:23FromDiscord<leorize> it's when you getType something and you get `nkBracket(typedesc, type)` AST
00:27:04FromDiscord<Robyn [She/Her]> Huh, cant think of a case i ran into that
00:27:38FromDiscord<leorize> union consumes typedesc as input and that happens a ton
00:28:43FromDiscord<Robyn [She/Her]> Sounds painful :p↵Is it because Union lets you do stuff like `A | UnrelatedB` or something? Idk how the lib works
00:28:44FromDiscord<leorize> you will know when it's a problem, so don't worry about it
00:29:15FromDiscord<leorize> yea, in fact it exclusively takes that form as input
00:30:07FromDiscord<Robyn [She/Her]> In reply to @leorize "you will know when": Fair
00:30:23FromDiscord<Robyn [She/Her]> In reply to @leorize "yea, in fact it": Cool, I have memory xD
01:30:15*SchweinDeBurg quit (Quit: WeeChat 4.4.0-dev)
01:30:37*SchweinDeBurg joined #nim
01:40:54*krux02_ joined #nim
01:43:02*krux02 quit (Ping timeout: 268 seconds)
01:47:27*lucasta quit (Quit: Leaving)
01:54:25*xet7 joined #nim
03:46:39NimEventerNew thread by slangmgh: It is annoying that the template doesn't resolve the symbol at template caller., see https://forum.nim-lang.org/t/11762
04:39:25FromDiscord<morgan> i think i should first try to get bgfx working with futhark and then if it works i can spend time later on writing better bindings
06:04:13FromDiscord<albassort> im having a fist fight with rust
06:04:24FromDiscord<Elegantbeef> Good
06:04:29FromDiscord<albassort> im loosing
06:04:35FromDiscord<Elegantbeef> Losing even
06:05:22FromDiscord<albassort> its very hard to create a c array of cstrings. I don't know why they made it so difficult?
06:06:33FromDiscord<Elegantbeef> Ah I joined that club
06:06:33FromDiscord<Elegantbeef> It's cause fuck you
06:07:12FromDiscord<Elegantbeef> https://github.com/beef331/libnimib/blob/master/tests/test.rs#L30-L33
06:07:17FromDiscord<Elegantbeef> A joke imo
06:07:56*krux02_ quit (Remote host closed the connection)
06:08:11FromDiscord<Elegantbeef> Probably just me holding it wrong, but I could not find a cleaner way
06:08:27FromDiscord<leorize> rust is just that verbose
06:09:23FromDiscord<Elegantbeef> Gotta appreciate my `type RealCstring = const c_char;`
06:09:42FromDiscord<leorize> though you did hold it wrong in that particular sample \:p
06:09:49FromDiscord<Elegantbeef> Hey the code compiles
06:10:10FromDiscord<Elegantbeef> Show me a better way and I'll fix it 😄
06:12:05FromDiscord<albassort> Beef your code is horrible here
06:12:19FromDiscord<albassort> this screams "its 2 and im very frustrated"
06:12:29FromDiscord<Elegantbeef> Cool
06:12:31FromDiscord<Elegantbeef> I don't write Rust I wanted a test language
06:13:29FromDiscord<Elegantbeef> Feel free to suggest improvements
06:14:11FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=fEhljEjE
06:14:55FromDiscord<Elegantbeef> That's better how?
06:15:10FromDiscord<Elegantbeef> I leak memory yea, but this is not a real program
06:15:14FromDiscord<Elegantbeef> This is a test to ensure the API works
06:15:19FromDiscord<leorize> beef\: `c"str"` is a `&'static CStr` literal
06:15:43FromDiscord<Elegantbeef> Ok that's actual help
06:15:58FromDiscord<albassort> In reply to @Elegantbeef "I leak memory yea,": we should strive to be pretty :)
06:16:19FromDiscord<albassort> beauty >>> function
06:17:00FromDiscord<Elegantbeef> I sincerely do not understand what you showed achieved with the API I have here
06:18:04FromDiscord<leorize> that's probably not how you should create a cstring array as well
06:19:35FromDiscord<Elegantbeef> That does seem wildly odd
06:19:37FromDiscord<Elegantbeef> Is `mem:forget` like `wasMoved`?
06:20:43FromDiscord<albassort> In reply to @leorize "that's probably not how": its not but im almost there!
06:20:53FromDiscord<albassort> i should have it working in 2 hours
06:21:14FromDiscord<Elegantbeef> Just allocate the size
06:21:17FromDiscord<Elegantbeef> Then set the elements
06:21:22FromDiscord<Elegantbeef> Why use a `Vec`
06:22:13FromDiscord<leorize> rust even have `Box<[CString]>` if you want it
06:22:15FromDiscord<albassort> In reply to @Elegantbeef "Just allocate the size": I would love to do that if any single thread said "Oh! you can alloc a block of memory, cast it to ``mut mut c_char`` then set it
06:22:52FromDiscord<albassort> In reply to @leorize "rust even have `Box<[CString]>`": well, I need to dealloc it and having it in a box might be harder
06:23:09FromDiscord<albassort> im also just trying to get a minimum viable output
06:23:29FromDiscord<leorize> you know that Box is like the barebone stuff, right?
06:23:30FromDiscord<Elegantbeef> Oh god doing it your way leo has brought lifetime annotations in the error messages
06:23:32FromDiscord<Elegantbeef> I'm too far
06:24:34FromDiscord<albassort> In reply to @leorize "you know that Box": I tried with box and also had segfault
06:25:15FromDiscord<Elegantbeef> '------ expected `CStr`, found `&CStr`' ah yes a reference to a cstring 😄
06:26:14FromDiscord<leorize> what did you do lol
06:26:27FromDiscord<leorize> I'll cook it up for you in the playground, wait a lil
06:27:24FromDiscord<Elegantbeef> I changed `RealCstring` to `CStr`
06:27:57FromDiscord<Elegantbeef> and all literals to `c"..."`
06:29:45FromDiscord<Elegantbeef> Nothing made me feel as dumb as attempting to use other languages' FFI
06:30:21FromDiscord<albassort> alright fuck this im gonna put it into ; separated strings
06:30:50FromDiscord<albassort> that way i dont need to worry about deallocing in rust either
06:30:53FromDiscord<Elegantbeef> I thought we should strive to be pretty
06:31:14FromDiscord<albassort> the end user may never know
06:35:55FromDiscord<leorize> beef\: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e75810f03e79230ad109283e42181afe
06:36:14FromDiscord<Elegantbeef> Oh you still need the as\_ptr for this
06:36:40FromDiscord<leorize> yea, `&` implies rust borrowing
06:36:52FromDiscord<Elegantbeef> Well thanks
06:36:53FromDiscord<leorize> which doesn't exist for nim FFI
06:37:27FromDiscord<Elegantbeef> Well yea `&` clearly is wrong since it's likely a reference 😄
06:39:09FromDiscord<Elegantbeef> `thread 'main' panicked at tests/test.rs:29:48:` I trusted you leo! 😄
06:40:04FromDiscord<leorize> I'd need a backtrace \:p
06:40:42FromDiscord<albassort> i dont understand & in rust
06:40:45FromDiscord<albassort> its a bit strange
06:41:18FromDiscord<Elegantbeef> I assume the issue is that it does not find a null inside the string inside `as_cstr` and errors out
06:41:51FromDiscord<albassort> for some reason the new string i made thats joined with ';' doesn't dealloc
06:42:00FromDiscord<albassort> im sure thats fine
06:42:21FromDiscord<albassort> (the other ones dont segfault when i call dealloc on them)
06:42:59FromDiscord<leorize> oh right rust doesn't put nul at the end of strings
06:43:30FromDiscord<Elegantbeef> Yea plus `str` will not have a nul there
06:43:46FromDiscord<Elegantbeef> as it only iterates 0..^1
06:48:26FromDiscord<albassort> yeah all the cstrings rust hands me I cannot dealloc. I'm sure this is fine tho
06:48:49FromDiscord<albassort> probably have to make a rust function to dealloc
06:50:10FromDiscord<leorize> beef\: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9cfc720d53cbe0af4d489b4364a968ff
06:50:20FromDiscord<leorize> verbose af, but this is rust so what can you do
06:50:34FromDiscord<leorize> albassort\: what exactly are you trying to do
06:50:50FromDiscord<Elegantbeef> Lol sneaky concat 😄
06:50:54FromDiscord<leorize> it looks like you're committing FFI war crimes
06:51:08FromDiscord<Elegantbeef> Yea they like abusing FFI
06:53:05FromDiscord<Elegantbeef> I'm sorta amazed there is no `CStr::from_bytes`
06:53:28FromDiscord<leorize> I mean it does exist
06:53:49FromDiscord<Elegantbeef> Only specific implementations that require atleast 1 `\0` exist
06:53:50FromDiscord<leorize> the unchecked version of the thing I used is basically it
06:54:33FromDiscord<Elegantbeef> There is no version that converts `&[u8]` into `CStr`
06:55:22FromDiscord<leorize> a CStr must be nul terminated so you can't just directly convert it
06:55:24FromDiscord<ta_efimova_19> Hello
06:55:45FromDiscord<Elegantbeef> Uh huh
06:55:50FromDiscord<leorize> @vindaar or @Phil
06:55:54FromDiscord<leorize> brace for impact
06:56:19FromDiscord<Elegantbeef> This is the idea that cstrings are not `ptr char` but always nul terminated, got it
06:56:51FromDiscord<leorize> yea if you just want ptr char you can easily get the ptr from the byte slice
06:58:03FromDiscord<leorize> rust likes to be strict
06:58:03FromDiscord<Elegantbeef> I need `\0` anyway, but yea
06:58:03FromDiscord<Elegantbeef> Thanks again for making it a tinge less ass
06:58:14*ntat joined #nim
06:58:19FromDiscord<Elegantbeef> The C code is even funnier
06:59:17FromDiscord<leorize> looks pretty tame to me \:p
06:59:27FromDiscord<Elegantbeef> The `R("""` is something
07:00:13FromDiscord<leorize> where does that R come from
07:00:15FromDiscord<Elegantbeef> Guess I never refactored the C test 😄
07:00:18FromDiscord<Elegantbeef> That's a C feature
07:00:30FromDiscord<Elegantbeef> Multi line strings, crazy I know
07:00:38FromDiscord<leorize> new stuff?
07:01:03FromDiscord<Elegantbeef> No clue when it was added I was just searching to see if there was a better way
07:01:32FromDiscord<Elegantbeef> Seems it's' actually apart of C++?
07:01:34FromDiscord<leorize> might be a GNU extension
07:01:41FromDiscord<Elegantbeef> C++11
07:01:44FromDiscord<Elegantbeef> https://en.cppreference.com/w/cpp/language/string_literal
07:02:28FromDiscord<leorize> GNU extensions usually just let you use some C++ features
07:02:32FromDiscord<Elegantbeef> Yea it's GCC
07:02:38FromDiscord<Elegantbeef> Clang is having an anyersum
07:02:55FromDiscord<albassort> what is clang up to
07:03:18FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=FOUSFmnu
07:03:36FromDiscord<albassort> hey but, you got pascal strings if you dont wanna use anything besides gcc
07:03:49FromDiscord<Elegantbeef> But i'm using cstrings
07:03:59FromDiscord<Elegantbeef> I'm using string literals so why would I want pascal strings
07:04:31FromDiscord<albassort> they would interop better if you figured out how to pass them properly :)
07:04:48FromDiscord<Elegantbeef> Huh?
07:05:07FromDiscord<albassort> you wouldn't need to cast a nim string to be null terminated
07:05:09FromDiscord<albassort> and vice versa
07:05:40FromDiscord<Elegantbeef> You can just pass them as `cstring, int`
07:07:38FromDiscord<Elegantbeef> There you go we solved strings, oh wait rust uses encoded strings
07:07:38FromDiscord<leorize> usually if you can't FFI to C cleanly you won't be able to FFI anywhere cleanly
07:08:44FromDiscord<albassort> i wonder what the hardest popular language to ffi into is
07:08:49FromDiscord<albassort> probably c++
07:09:27FromDiscord<leorize> btw beef if you want to do errors in C, just use a thread-local string
07:09:28FromDiscord<Elegantbeef> I love that vtables are implementation defined
07:09:52FromDiscord<Elegantbeef> Errno style string?
07:09:53FromDiscord<albassort> In reply to @leorize "btw beef if you": I pass an enum tho
07:10:12FromDiscord<leorize> yea, then return a book whether the op succeed
07:10:57FromDiscord<leorize> if not then direct them to `_get_error()` that returns the string
07:11:16FromDiscord<leorize> bool, even
07:11:26FromDiscord<Elegantbeef> Yea I was so confused for a split second
07:11:34FromDiscord<Elegantbeef> "Are you really suggesting to change the entire api"
07:11:51FromDiscord<leorize> albassort\: enum only works if the lib is built with it in mind
07:12:04FromDiscord<leorize> beef is retrofitting a nim-oriented thing
07:12:24FromDiscord<Elegantbeef> I do personally like a cstring for cross language errors, but I'm an idiot
07:12:43FromDiscord<leorize> it's fine, openssl agrees with you
07:13:11FromDiscord<leorize> their apis more or less specify that all error codes are unstable
07:13:30FromDiscord<leorize> except the ones documented, ofc
07:13:58FromDiscord<Elegantbeef> The one issue is for cheap error handling you have to load symbols from the shared library so addresses match
07:14:15FromDiscord<Elegantbeef> Otherwise to differentiate two errors it's a O(N) check
07:14:53FromDiscord<leorize> just make sure the only type of error is unrecoverable error and you're gold \:p
07:15:25FromDiscord<Elegantbeef> heh
07:45:29FromDiscord<jaar23> `nimble install asciigraph` is 404 now. https://github.com/Yardanico/asciigraph↵the author has either hide the repo or removed it?
07:50:20FromDiscord<Elegantbeef> Yardanico has disappeared and cleaned their entire online presence
07:54:50FromDiscord<.lisuwu_> In reply to @Elegantbeef "Yardanico has disappeared and": what happened to yardanico?
08:01:54FromDiscord<jaar23> aw, okay. hope he is well
08:03:09FromDiscord<ringabout> In reply to @jaar23 "`nimble install asciigraph` is": You can use a backup here => https://github.com/nimbackup/asciigraph
08:11:46FromDiscord<albassort> In reply to @.lisuwu_ "what happened to yardanico?": He was disappeared for being counter revolutionary. His trail is to be aired publicly any day now
08:11:56FromDiscord<albassort> (edit) "trail" => "trial "
08:12:39FromDiscord<albassort> (we don't know, nor do we have means to ask him.)
08:12:55FromDiscord<albassort> We all have copies of their projects on our computers to upload their codebase should we see fit, however.
08:13:05FromDiscord<albassort> (edit) "codebase" => "codebaseS"
08:24:51FromDiscord<jaar23> In reply to @ringabout "You can use a": but nimble install still targeted to yardanico one, any steps / manual to change nimble when pulling it?
08:25:37FromDiscord<ringabout> nimble install https://github.com/nimbackup/asciigraph
09:22:07FromDiscord<drunkenalcoholic> sent a code paste, see https://play.nim-lang.org/#pasty=SwTPtfyc
09:22:20FromDiscord<drunkenalcoholic> ``json
09:22:41FromDiscord<drunkenalcoholic> {"status":"success","result":[{"time":{"time":"2024-06-15T09:18:09.105505Z","secondsAgo":30},"temperature":25.2,"humidity":70.7,"feelsLike":25.2,"rssi":-78}]}
09:32:48FromDiscord<albassort> @drunkenalcoholic Why would you access "status" before "result" if result is not a child of status?
09:33:48FromDiscord<albassort> second thing is, result is a array (JArray) which you need to indice first or handle that there are multiple results
09:33:56FromDiscord<drunkenalcoholic> thats me just throwing it in there while not knowing how it fully works, it should be ["result][0]["temperature"]
09:34:02FromDiscord<albassort> data["result"]'0...["temperature"]
09:34:04FromDiscord<albassort> you got it
09:34:10FromDiscord<drunkenalcoholic> doesn't work
09:34:17FromDiscord<albassort> what is the exception?
09:34:30FromDiscord<albassort> wait
09:34:40FromDiscord<albassort> you should format your json strings when you're looking at them because they can be silly
09:35:22FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=SPscoGAu
09:35:52FromDiscord<drunkenalcoholic> not giving the error now, but not giving the value either
09:35:55FromDiscord<albassort> you need to do .get_float()
09:36:02FromDiscord<albassort> sorry getFloat()
09:36:14FromDiscord<drunkenalcoholic> yeah i had getStr()
09:36:31FromDiscord<albassort> well its not in a string, so you need to get it as a float
09:36:33FromDiscord<albassort> then do $
09:36:37FromDiscord<drunkenalcoholic> hmm now it working without getStr or getFloat
09:36:48FromDiscord<albassort> yes because its just a Jtype
09:37:00FromDiscord<drunkenalcoholic> ok it working now, must have been something I missed last time as I am sure I tried all these before
09:37:10FromDiscord<albassort> This is good :)
09:37:23FromDiscord<drunkenalcoholic> thank you @albassort
10:14:36FromDiscord<CANTAP969> image.png https://media.discordapp.net/attachments/371759389889003532/1251479968341430352/image.png?ex=666ebb0b&is=666d698b&hm=a3dc2010b61fd15d9a16d4099255c32b7abf7cbcb992872803937e6a522e6a44&
10:30:44FromDiscord<albassort> thanks
12:20:05FromDiscord<Robyn [She/Her]> Anyone know why my macro isn't successfully returning something?↵https://play.nim-lang.org/#pasty=rqWrZorM↵It's in a block statement and the last node in the block statement is the query object variable, but for some reason it doesn't get returned so I'm lost
12:20:25FromDiscord<Robyn [She/Her]> The generated Nim code through `repr` looks fine which is even more odd to me
12:23:04*lucasta joined #nim
12:34:32FromDiscord<Robyn [She/Her]> Ah
12:34:35FromDiscord<Robyn [She/Her]> Figured it out
12:35:20*lucasta quit (Quit: Leaving)
12:36:34FromDiscord<Robyn [She/Her]> The query builder was actually pretty easy, neat
12:37:09FromDiscord<Robyn [She/Her]> Even does basic type and field validation :>
12:46:53FromDiscord<Robyn [She/Her]> Ah, I'm gonna have to figure out how to translate stuff like `Verified in it.flags` for sets and stuff
12:48:18FromDiscord<Phil> Out of curiosity, if a lib gave you a distinct type and procs to work on that type, would type-casting it back to the underlying base-type "feel" like enough of a warning shot to you guys that you'd think "Ah, I'm likely in unsupported territory in how I'm using this" ?
12:48:48FromDiscord<Robyn [She/Her]> In reply to @isofruit "Out of curiosity, if": Yeah I'd say so
12:49:58FromDiscord<Phil> sent a long message, see https://pasty.ee/nBDwUyaD
12:50:39FromDiscord<Phil> (edit) "https://pasty.ee/UsxPvSwd" => "https://pasty.ee/TwadGzGo"
12:55:47FromDiscord<Phil> Oh god, which was the type again that is basically available for all kinds of iterables?
12:56:00FromDiscord<Phil> where you can put both seq, array etc into it?
12:58:35FromDiscord<Robyn [She/Her]> In reply to @isofruit "Oh god, which was": Huh?
12:58:54FromDiscord<Phil> for proc parameters when you want to accept all sorts of sequence-like datatypes
12:59:45*coldfeet_ joined #nim
12:59:47FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#pasty=JjmLclEx
13:00:05FromDiscord<Phil> Basically for when you want to allow folks to use your proc with both sequences and arrays
13:00:11FromDiscord<Phil> That type had a name
13:02:09FromDiscord<Robyn [She/Her]> In reply to @isofruit "That type had a": `openArray` :p
13:29:20FromDiscord<albassort> In reply to @isofruit "This is based on": heres how most libraries do it:↵↵Give them a weird fucking type they cant do anything with
13:29:28FromDiscord<albassort> except for like 3 functions
13:29:40FromDiscord<albassort> that all yield their own strange types
13:30:13FromDiscord<Phil> In reply to @albassort "heres how most libraries": Yeah but I can do that with 2 ways
13:30:20FromDiscord<albassort> and they need to be in a separate file/crate/whatever than the main stuff for extra "oh no"
13:30:23FromDiscord<Phil> I can make that weird type an object type or a distinct type
13:36:05FromDiscord<albassort> well
13:36:08FromDiscord<albassort> i think in a nim context
13:36:30FromDiscord<albassort> you have two options, black or white
13:37:06FromDiscord<albassort> should your low level functions take in a special type that requires you to know you're being silly, or should your normal functions take in the special type
13:37:38FromDiscord<albassort> honestly, I think that you should trust the developer
13:41:19FromDiscord<albassort> Result is so powerful in nim that I feel the need to implement it in every function in my Rust Code
13:41:21FromDiscord<albassort> (edit) "Code" => "code"
13:51:27*xet7 quit (Remote host closed the connection)
13:53:19*xet7 joined #nim
13:54:11FromDiscord<Phil> In reply to @albassort "Result is so powerful": Yeah, Result in particular with an arbitrary amount of different exceptions that you can return is the good bits right there
13:54:40FromDiscord<Phil> Having to define specific Result-type all the time if I want the same in nim with various amounts of exception types destroys the ergonomics
14:00:35FromDiscord<albassort> the issue is in rust, i cant return an Option because its ffi, so i need a type that fits the return type, that will allow me to return everything null but with an error code
14:01:49FromDiscord<albassort> the only logical way is to define a result at the start of the function, will all null pointers, and set the return code whenever there is an exception
14:02:06FromDiscord<albassort> (edit) "will" => "with"
14:06:20FromDiscord<zumi.dxy> In reply to @albassort "Result is so powerful": i thought `Result` (or `Option`) was just a given in rust and you're expected to return some type of it anyway?
14:06:48FromDiscord<zumi.dxy> imo ffi is kinda messy no matter how you put it
14:09:28FromDiscord<albassort> err, perhaps i should have spelt it lowercase
14:09:32FromDiscord<albassort> the variable is named result
14:09:42FromDiscord<albassort> its whatever struct the function returns
14:10:11FromDiscord<zumi.dxy> oh
14:10:25FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=JysYIUyj
14:11:03FromDiscord<zumi.dxy> I suppose you find more often functions that incrementally build up
14:11:14FromDiscord<albassort> wdym
14:11:36FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=exSBzzah
14:11:38FromDiscord<zumi.dxy> i thought that's what `result` is best for
14:11:44FromDiscord<albassort> (edit) "sent" => "gnu infected me with" | "code paste, see https://play.nim-lang.org/#pasty=dZMdDpIo" => "taste for`very_long_names_in_code_that_use_snake_case`"
14:11:54FromDiscord<albassort> well in this case, i have no choice because of this
14:12:07FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=gBJFNnRy
14:55:35*coldfeet_ quit (Remote host closed the connection)
15:32:52FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#pasty=gkTxDGfl
15:32:56FromDiscord<Phil> (edit) "https://play.nim-lang.org/#pasty=zJtPmDux" => "https://play.nim-lang.org/#pasty=IrnUeMDp"
15:38:19FromDiscord<vindaar> Did you compile with `-d:openmp`?
15:39:34FromDiscord<Phil> I thought that was arraymancer specific, fair shout, will try again
15:39:52FromDiscord<Phil> Still the same
15:40:30FromDiscord<Phil> ` nim r -f --path:~/dev/slacktors/src --debugger:native --cc:clang -d:chronicles_log_level=trace --threads:on -d:openmp -d:useMalloc --passc:"-fsanitize=address -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" --passl:"-fsanitize=address -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" -d:release --deepcopy:on src/playground.nim `↵↵That was my compile command (sorry, a whole bunch of default flags I keep around in this playgrou
15:45:07FromDiscord<vindaar> I don't use openmp myself much either, because I found it to often produces compilation errors (C), can easily segfault by not being careful enough and it's a bit hard to predict. ↵I don't really know all the rules that openmp follows that decide if something is multithreaded in the first place
15:45:36FromDiscord<vindaar> (it's not helped by the fact that Nim "sits between" us and the C code
15:53:51FromDiscord<leorize> openmp is not a threadpool Phil
15:56:14FromDiscord<Phil> Sure, for the most part I'm just playing around because I didn't even know it existed, I'd still assume it should work as expected, as in spawn new threads at the very least
16:13:24FromDiscord<vindaar> sent a long message, see https://pasty.ee/bQhIEhrY
16:16:07FromDiscord<vindaar> If you compile without the `--passC:"-fopenmp"` Nim puts the `#pragma omp parallel for` above the loop, but it does not pass the necessary flags to GCC. So GCC just ignores them. And without the linker flag it simply leads to undefined references, as you can imagine. Each time I look a it I'm a bit confused. Some compiler / stdlib PRs might not hurt, but well
16:17:30FromDiscord<Phil> Yeah that's a gcc exclusive, clang won't compile that
16:21:15FromDiscord<vindaar> yeah, but Nim should pass the correct flags to GCC (if you use GCC) if it encounters the magic `||` in your code. Or at the _very least_ you shouldn't have to remember to use `--passC` and `--passL` for something "inbuilt" (I mean there's a compiler magic for it, so it is for all intents and purposes)
16:26:07*coldfeet joined #nim
16:33:30*xet7 quit (Quit: Leaving)
16:34:50*xet7 joined #nim
17:13:07FromDiscord<.bobbbob> does the compiler check if a let is computable at compile time and assign it at compile time? as an optimization
17:14:15FromDiscord<Phil> I wouldn't bet on it
17:42:34FromDiscord<frusadev> Hello how to mutate iterated variables in a loop. `for vars in varsss` I mean how do i mutate vars?
17:46:46FromDiscord<Phil> sent a long message, see https://pasty.ee/igMOZyee
17:53:19FromDiscord<.bobbbob> In reply to @isofruit "I wouldn't bet on": would that be a good idea to add? I guess there's no point since theres const
18:11:47*oisota6 joined #nim
18:12:30FromDiscord<frusadev> In reply to @isofruit "for x in y": I see! thanks
18:13:32*coldfeet quit (Ping timeout: 255 seconds)
18:13:32*oisota quit (Ping timeout: 255 seconds)
18:13:32*oisota6 is now known as oisota
18:15:25*coldfeet joined #nim
18:16:14*eery quit (Ping timeout: 255 seconds)
18:16:26*eery joined #nim
18:17:08*ttkap quit (Ping timeout: 255 seconds)
18:17:28FromDiscord<Robyn [She/Her]> In reply to @.bobbbob "would that be a": More stuff being done at compile-time seems good to me, no harm, right?
18:21:42*ttkap joined #nim
18:42:39FromDiscord<demotomohiro> Nim and backend C compiler usually do computation at compile time if possible.↵You can read Nim generated C code (or GCC generated assembler code with --passC:"-S") in Nim cache directory.
18:43:57FromDiscord<planetis_m> It does fold some expressions but others not, like ones that have fp math
18:58:55FromDiscord<Elegantbeef> It already exists you can do `let x = static: ...` 😛↵(@.bobbbob)
19:19:56*nyeaa49284230101 quit (Quit: The Lounge - https://thelounge.chat)
19:23:32*coldfeet quit (Remote host closed the connection)
19:24:32*ntat quit (Quit: Leaving)
19:37:39*coldfeet joined #nim
19:50:30*coldfeet quit (Remote host closed the connection)
20:04:02*nyeaa49284230101 joined #nim
20:07:35*disso-peach joined #nim
20:25:07FromDiscord<Robyn [She/Her]> Should my API server implement ratelimiting, or should that be delegated to something like Caddy? Or should it be configurable?
20:29:01*coldfeet joined #nim
20:36:18FromDiscord<Phil> In reply to @chronos.vitaqua "Should my API server": Depends, what are your business requirements?↵After what logic do you want to rate-limit?
20:36:57FromDiscord<Phil> Number of requests? ↵Expense of the particular computation triggered (however you'd calculate that) ?↵Amount of MS that the request spent on the server?
20:37:23FromDiscord<Phil> (edit) "MS" => "time" | "the request spent" => "all requests cumulatively took" | "server?" => "server so far?"
20:37:30*coldfeet quit (Remote host closed the connection)
20:37:43FromDiscord<Phil> First figure out what you want to do, then you can figure out the how 😄
20:49:06FromDiscord<Elegantbeef> @xkonti I could not help myself from profiling your program, your program is mainly benchmarking the allocator. One easy performance gain is to mark `FrozenState` `{.acyclic.}` since it's a linked list and it'll never create a cycle
20:49:58FromDiscord<Elegantbeef> Otherwise changing `FrozenState` to an `object` and using an arena allocator is probably the best you'll get with the current underlying logic
20:51:18FromDiscord<Elegantbeef> Which practically means using a `seq[FrozenState]` to hold all your `FrozenState`s and passing around a `int` instead of `ref FrozenState`
21:10:33FromDiscord<Robyn [She/Her]> In reply to @isofruit "Number of requests? ": Number of requests
21:12:32FromDiscord<Phil> In reply to @chronos.vitaqua "Number of requests": In that case go with caddy. Code you don't need to write is good code, assuming it fulfills your requirements.
21:12:43FromDiscord<Phil> (edit) "caddy." => "the caddy solution."
21:13:09FromDiscord<Robyn [She/Her]> Fair
21:13:15FromDiscord<Robyn [She/Her]> I might have both either way
21:13:42FromDiscord<Robyn [She/Her]> And then if I use Caddy I'll just disable it on the API side
22:10:14FromDiscord<xkonti> In reply to @Elegantbeef "<@244832576215318528> I could not": This is amazing! I will definitely try it out after the weekend!
22:48:09FromDiscord<raidcade> how can I remove a symlink without deleting the original directory?
22:49:15FromDiscord<Elegantbeef> does `rmFile` not work?
22:49:26FromDiscord<Elegantbeef> Wait it's removeFile in os
22:52:01FromDiscord<raidcade> it doesn't create a dedicated file on windows to delete and running os.removeDir on the targeted location deletes the source
22:57:35FromDiscord<Elegantbeef> Cannot say much do not use windows so cannot test this
23:00:34FromDiscord<Robyn [She/Her]> Hm do I ratelimit based on IP or on the user ID?
23:02:18FromDiscord<leorize> you can start with figuring out what happens if you're hammered
23:02:49FromDiscord<Robyn [She/Her]> Wdym?
23:02:50FromDiscord<Elegantbeef> Most people slur their speech and occasionally piss themselves
23:02:56FromDiscord<Robyn [She/Her]> Lmao
23:04:41FromDiscord<leorize> basically what happens if you got hit with a flood of requests
23:04:47FromDiscord<leorize> what is required to make such requests and so on
23:07:19FromDiscord<raidcade> In reply to @Elegantbeef "Cannot say much do": think there might be a problem with the nim remove since apparently it works just fine by calling the native rm using os.execShellCmd
23:18:13FromDiscord<Robyn [She/Her]> In reply to @leorize "basically what happens if": A ton of requests could put the application to a stop for a while since a lot of DB access is needed for even basic stuff because everything relies on a session ID
23:36:50FromDiscord<leorize> so if you want to stop it you'd need to either\: make session lookup cheaper or ratelimit without knowing the session
23:37:31FromDiscord<leorize> what do you have to id for rate limiting for the latter?
23:38:37*mal`` quit (Quit: Leaving)
23:39:02FromDiscord<Robyn [She/Her]> In reply to @leorize "what do you have": The IP, and that's it
23:39:23FromDiscord<Robyn [She/Her]> Session lookup could get cheaper with a cache but that'll come later tbh
23:39:45FromDiscord<leorize> now you got a rate limit target
23:40:20FromDiscord<Robyn [She/Her]> Fair point xD
23:40:24FromDiscord<Robyn [She/Her]> Thanks Leorize
23:41:11FromDiscord<leorize> if an user flood using one session id over multiple ips (ie. a DDoS attack or just a bot that misfunctions), then your IP defense is useless
23:41:17FromDiscord<demotomohiro> In reply to @raidcade "think there might be": Here is a proc in Nim's stdlib that remove file: https://github.com/nim-lang/Nim/blob/devel/lib/std/private/osfiles.nim#L341↵And it seems this Windows API is used: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilew
23:41:30FromDiscord<leorize> in this case, what else can you do?
23:42:14FromDiscord<Robyn [She/Her]> In reply to @leorize "if an user flood": Could always ratelimit both if really needed
23:42:35FromDiscord<leorize> so it wasn't an `or` question after all \:p
23:42:49FromDiscord<Robyn [She/Her]> Also a good point aha
23:46:47FromDiscord<leorize> usually, you need to protect if there is an asymmetry in computation cost between the client and the server
23:47:48FromDiscord<leorize> it's my personal theory that you can't do anything (in your software) if making a request has the same cost as responding to it correctly, but a proper engineer might disagree \:p
23:48:20FromDiscord<Robyn [She/Her]> It makes sense to me, that's how I was going about things before too
23:48:44FromDiscord<Robyn [She/Her]> If I had to do DB access, before that I'd add a ratelimit check