00:22:43 | FromDiscord | <leorize> getTypeInst↵(@Robyn [She/Her]) |
00:23:19 | FromDiscord | <leorize> using any getType gives you typed ast of the type you want |
00:24:05 | FromDiscord | <leorize> which you can use as parameters to other getType\ functions, regardless of whether they support typedesc |
00:24:18 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "getTypeInst (<@524288464422830095>)": Thank you, didnt realise this did what i needed aha |
00:24:40 | FromDiscord | <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:00 | FromDiscord | <leorize> checkout my union.nim, I have a helper module just for type shenanigans |
00:25:35 | FromDiscord | <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:23 | FromDiscord | <leorize> it's when you getType something and you get `nkBracket(typedesc, type)` AST |
00:27:04 | FromDiscord | <Robyn [She/Her]> Huh, cant think of a case i ran into that |
00:27:38 | FromDiscord | <leorize> union consumes typedesc as input and that happens a ton |
00:28:43 | FromDiscord | <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:44 | FromDiscord | <leorize> you will know when it's a problem, so don't worry about it |
00:29:15 | FromDiscord | <leorize> yea, in fact it exclusively takes that form as input |
00:30:07 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "you will know when": Fair |
00:30:23 | FromDiscord | <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:39 | NimEventer | New 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:25 | FromDiscord | <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:13 | FromDiscord | <albassort> im having a fist fight with rust |
06:04:24 | FromDiscord | <Elegantbeef> Good |
06:04:29 | FromDiscord | <albassort> im loosing |
06:04:35 | FromDiscord | <Elegantbeef> Losing even |
06:05:22 | FromDiscord | <albassort> its very hard to create a c array of cstrings. I don't know why they made it so difficult? |
06:06:33 | FromDiscord | <Elegantbeef> Ah I joined that club |
06:06:33 | FromDiscord | <Elegantbeef> It's cause fuck you |
06:07:12 | FromDiscord | <Elegantbeef> https://github.com/beef331/libnimib/blob/master/tests/test.rs#L30-L33 |
06:07:17 | FromDiscord | <Elegantbeef> A joke imo |
06:07:56 | * | krux02_ quit (Remote host closed the connection) |
06:08:11 | FromDiscord | <Elegantbeef> Probably just me holding it wrong, but I could not find a cleaner way |
06:08:27 | FromDiscord | <leorize> rust is just that verbose |
06:09:23 | FromDiscord | <Elegantbeef> Gotta appreciate my `type RealCstring = const c_char;` |
06:09:42 | FromDiscord | <leorize> though you did hold it wrong in that particular sample \:p |
06:09:49 | FromDiscord | <Elegantbeef> Hey the code compiles |
06:10:10 | FromDiscord | <Elegantbeef> Show me a better way and I'll fix it 😄 |
06:12:05 | FromDiscord | <albassort> Beef your code is horrible here |
06:12:19 | FromDiscord | <albassort> this screams "its 2 and im very frustrated" |
06:12:29 | FromDiscord | <Elegantbeef> Cool |
06:12:31 | FromDiscord | <Elegantbeef> I don't write Rust I wanted a test language |
06:13:29 | FromDiscord | <Elegantbeef> Feel free to suggest improvements |
06:14:11 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=fEhljEjE |
06:14:55 | FromDiscord | <Elegantbeef> That's better how? |
06:15:10 | FromDiscord | <Elegantbeef> I leak memory yea, but this is not a real program |
06:15:14 | FromDiscord | <Elegantbeef> This is a test to ensure the API works |
06:15:19 | FromDiscord | <leorize> beef\: `c"str"` is a `&'static CStr` literal |
06:15:43 | FromDiscord | <Elegantbeef> Ok that's actual help |
06:15:58 | FromDiscord | <albassort> In reply to @Elegantbeef "I leak memory yea,": we should strive to be pretty :) |
06:16:19 | FromDiscord | <albassort> beauty >>> function |
06:17:00 | FromDiscord | <Elegantbeef> I sincerely do not understand what you showed achieved with the API I have here |
06:18:04 | FromDiscord | <leorize> that's probably not how you should create a cstring array as well |
06:19:35 | FromDiscord | <Elegantbeef> That does seem wildly odd |
06:19:37 | FromDiscord | <Elegantbeef> Is `mem:forget` like `wasMoved`? |
06:20:43 | FromDiscord | <albassort> In reply to @leorize "that's probably not how": its not but im almost there! |
06:20:53 | FromDiscord | <albassort> i should have it working in 2 hours |
06:21:14 | FromDiscord | <Elegantbeef> Just allocate the size |
06:21:17 | FromDiscord | <Elegantbeef> Then set the elements |
06:21:22 | FromDiscord | <Elegantbeef> Why use a `Vec` |
06:22:13 | FromDiscord | <leorize> rust even have `Box<[CString]>` if you want it |
06:22:15 | FromDiscord | <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:52 | FromDiscord | <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:09 | FromDiscord | <albassort> im also just trying to get a minimum viable output |
06:23:29 | FromDiscord | <leorize> you know that Box is like the barebone stuff, right? |
06:23:30 | FromDiscord | <Elegantbeef> Oh god doing it your way leo has brought lifetime annotations in the error messages |
06:23:32 | FromDiscord | <Elegantbeef> I'm too far |
06:24:34 | FromDiscord | <albassort> In reply to @leorize "you know that Box": I tried with box and also had segfault |
06:25:15 | FromDiscord | <Elegantbeef> '------ expected `CStr`, found `&CStr`' ah yes a reference to a cstring 😄 |
06:26:14 | FromDiscord | <leorize> what did you do lol |
06:26:27 | FromDiscord | <leorize> I'll cook it up for you in the playground, wait a lil |
06:27:24 | FromDiscord | <Elegantbeef> I changed `RealCstring` to `CStr` |
06:27:57 | FromDiscord | <Elegantbeef> and all literals to `c"..."` |
06:29:45 | FromDiscord | <Elegantbeef> Nothing made me feel as dumb as attempting to use other languages' FFI |
06:30:21 | FromDiscord | <albassort> alright fuck this im gonna put it into ; separated strings |
06:30:50 | FromDiscord | <albassort> that way i dont need to worry about deallocing in rust either |
06:30:53 | FromDiscord | <Elegantbeef> I thought we should strive to be pretty |
06:31:14 | FromDiscord | <albassort> the end user may never know |
06:35:55 | FromDiscord | <leorize> beef\: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e75810f03e79230ad109283e42181afe |
06:36:14 | FromDiscord | <Elegantbeef> Oh you still need the as\_ptr for this |
06:36:40 | FromDiscord | <leorize> yea, `&` implies rust borrowing |
06:36:52 | FromDiscord | <Elegantbeef> Well thanks |
06:36:53 | FromDiscord | <leorize> which doesn't exist for nim FFI |
06:37:27 | FromDiscord | <Elegantbeef> Well yea `&` clearly is wrong since it's likely a reference 😄 |
06:39:09 | FromDiscord | <Elegantbeef> `thread 'main' panicked at tests/test.rs:29:48:` I trusted you leo! 😄 |
06:40:04 | FromDiscord | <leorize> I'd need a backtrace \:p |
06:40:42 | FromDiscord | <albassort> i dont understand & in rust |
06:40:45 | FromDiscord | <albassort> its a bit strange |
06:41:18 | FromDiscord | <Elegantbeef> I assume the issue is that it does not find a null inside the string inside `as_cstr` and errors out |
06:41:51 | FromDiscord | <albassort> for some reason the new string i made thats joined with ';' doesn't dealloc |
06:42:00 | FromDiscord | <albassort> im sure thats fine |
06:42:21 | FromDiscord | <albassort> (the other ones dont segfault when i call dealloc on them) |
06:42:59 | FromDiscord | <leorize> oh right rust doesn't put nul at the end of strings |
06:43:30 | FromDiscord | <Elegantbeef> Yea plus `str` will not have a nul there |
06:43:46 | FromDiscord | <Elegantbeef> as it only iterates 0..^1 |
06:48:26 | FromDiscord | <albassort> yeah all the cstrings rust hands me I cannot dealloc. I'm sure this is fine tho |
06:48:49 | FromDiscord | <albassort> probably have to make a rust function to dealloc |
06:50:10 | FromDiscord | <leorize> beef\: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9cfc720d53cbe0af4d489b4364a968ff |
06:50:20 | FromDiscord | <leorize> verbose af, but this is rust so what can you do |
06:50:34 | FromDiscord | <leorize> albassort\: what exactly are you trying to do |
06:50:50 | FromDiscord | <Elegantbeef> Lol sneaky concat 😄 |
06:50:54 | FromDiscord | <leorize> it looks like you're committing FFI war crimes |
06:51:08 | FromDiscord | <Elegantbeef> Yea they like abusing FFI |
06:53:05 | FromDiscord | <Elegantbeef> I'm sorta amazed there is no `CStr::from_bytes` |
06:53:28 | FromDiscord | <leorize> I mean it does exist |
06:53:49 | FromDiscord | <Elegantbeef> Only specific implementations that require atleast 1 `\0` exist |
06:53:50 | FromDiscord | <leorize> the unchecked version of the thing I used is basically it |
06:54:33 | FromDiscord | <Elegantbeef> There is no version that converts `&[u8]` into `CStr` |
06:55:22 | FromDiscord | <leorize> a CStr must be nul terminated so you can't just directly convert it |
06:55:24 | FromDiscord | <ta_efimova_19> Hello |
06:55:45 | FromDiscord | <Elegantbeef> Uh huh |
06:55:50 | FromDiscord | <leorize> @vindaar or @Phil |
06:55:54 | FromDiscord | <leorize> brace for impact |
06:56:19 | FromDiscord | <Elegantbeef> This is the idea that cstrings are not `ptr char` but always nul terminated, got it |
06:56:51 | FromDiscord | <leorize> yea if you just want ptr char you can easily get the ptr from the byte slice |
06:58:03 | FromDiscord | <leorize> rust likes to be strict |
06:58:03 | FromDiscord | <Elegantbeef> I need `\0` anyway, but yea |
06:58:03 | FromDiscord | <Elegantbeef> Thanks again for making it a tinge less ass |
06:58:14 | * | ntat joined #nim |
06:58:19 | FromDiscord | <Elegantbeef> The C code is even funnier |
06:59:17 | FromDiscord | <leorize> looks pretty tame to me \:p |
06:59:27 | FromDiscord | <Elegantbeef> The `R("""` is something |
07:00:13 | FromDiscord | <leorize> where does that R come from |
07:00:15 | FromDiscord | <Elegantbeef> Guess I never refactored the C test 😄 |
07:00:18 | FromDiscord | <Elegantbeef> That's a C feature |
07:00:30 | FromDiscord | <Elegantbeef> Multi line strings, crazy I know |
07:00:38 | FromDiscord | <leorize> new stuff? |
07:01:03 | FromDiscord | <Elegantbeef> No clue when it was added I was just searching to see if there was a better way |
07:01:32 | FromDiscord | <Elegantbeef> Seems it's' actually apart of C++? |
07:01:34 | FromDiscord | <leorize> might be a GNU extension |
07:01:41 | FromDiscord | <Elegantbeef> C++11 |
07:01:44 | FromDiscord | <Elegantbeef> https://en.cppreference.com/w/cpp/language/string_literal |
07:02:28 | FromDiscord | <leorize> GNU extensions usually just let you use some C++ features |
07:02:32 | FromDiscord | <Elegantbeef> Yea it's GCC |
07:02:38 | FromDiscord | <Elegantbeef> Clang is having an anyersum |
07:02:55 | FromDiscord | <albassort> what is clang up to |
07:03:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=FOUSFmnu |
07:03:36 | FromDiscord | <albassort> hey but, you got pascal strings if you dont wanna use anything besides gcc |
07:03:49 | FromDiscord | <Elegantbeef> But i'm using cstrings |
07:03:59 | FromDiscord | <Elegantbeef> I'm using string literals so why would I want pascal strings |
07:04:31 | FromDiscord | <albassort> they would interop better if you figured out how to pass them properly :) |
07:04:48 | FromDiscord | <Elegantbeef> Huh? |
07:05:07 | FromDiscord | <albassort> you wouldn't need to cast a nim string to be null terminated |
07:05:09 | FromDiscord | <albassort> and vice versa |
07:05:40 | FromDiscord | <Elegantbeef> You can just pass them as `cstring, int` |
07:07:38 | FromDiscord | <Elegantbeef> There you go we solved strings, oh wait rust uses encoded strings |
07:07:38 | FromDiscord | <leorize> usually if you can't FFI to C cleanly you won't be able to FFI anywhere cleanly |
07:08:44 | FromDiscord | <albassort> i wonder what the hardest popular language to ffi into is |
07:08:49 | FromDiscord | <albassort> probably c++ |
07:09:27 | FromDiscord | <leorize> btw beef if you want to do errors in C, just use a thread-local string |
07:09:28 | FromDiscord | <Elegantbeef> I love that vtables are implementation defined |
07:09:52 | FromDiscord | <Elegantbeef> Errno style string? |
07:09:53 | FromDiscord | <albassort> In reply to @leorize "btw beef if you": I pass an enum tho |
07:10:12 | FromDiscord | <leorize> yea, then return a book whether the op succeed |
07:10:57 | FromDiscord | <leorize> if not then direct them to `_get_error()` that returns the string |
07:11:16 | FromDiscord | <leorize> bool, even |
07:11:26 | FromDiscord | <Elegantbeef> Yea I was so confused for a split second |
07:11:34 | FromDiscord | <Elegantbeef> "Are you really suggesting to change the entire api" |
07:11:51 | FromDiscord | <leorize> albassort\: enum only works if the lib is built with it in mind |
07:12:04 | FromDiscord | <leorize> beef is retrofitting a nim-oriented thing |
07:12:24 | FromDiscord | <Elegantbeef> I do personally like a cstring for cross language errors, but I'm an idiot |
07:12:43 | FromDiscord | <leorize> it's fine, openssl agrees with you |
07:13:11 | FromDiscord | <leorize> their apis more or less specify that all error codes are unstable |
07:13:30 | FromDiscord | <leorize> except the ones documented, ofc |
07:13:58 | FromDiscord | <Elegantbeef> The one issue is for cheap error handling you have to load symbols from the shared library so addresses match |
07:14:15 | FromDiscord | <Elegantbeef> Otherwise to differentiate two errors it's a O(N) check |
07:14:53 | FromDiscord | <leorize> just make sure the only type of error is unrecoverable error and you're gold \:p |
07:15:25 | FromDiscord | <Elegantbeef> heh |
07:45:29 | FromDiscord | <jaar23> `nimble install asciigraph` is 404 now. https://github.com/Yardanico/asciigraph↵the author has either hide the repo or removed it? |
07:50:20 | FromDiscord | <Elegantbeef> Yardanico has disappeared and cleaned their entire online presence |
07:54:50 | FromDiscord | <.lisuwu_> In reply to @Elegantbeef "Yardanico has disappeared and": what happened to yardanico? |
08:01:54 | FromDiscord | <jaar23> aw, okay. hope he is well |
08:03:09 | FromDiscord | <ringabout> In reply to @jaar23 "`nimble install asciigraph` is": You can use a backup here => https://github.com/nimbackup/asciigraph |
08:11:46 | FromDiscord | <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:56 | FromDiscord | <albassort> (edit) "trail" => "trial " |
08:12:39 | FromDiscord | <albassort> (we don't know, nor do we have means to ask him.) |
08:12:55 | FromDiscord | <albassort> We all have copies of their projects on our computers to upload their codebase should we see fit, however. |
08:13:05 | FromDiscord | <albassort> (edit) "codebase" => "codebaseS" |
08:24:51 | FromDiscord | <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:37 | FromDiscord | <ringabout> nimble install https://github.com/nimbackup/asciigraph |
09:22:07 | FromDiscord | <drunkenalcoholic> sent a code paste, see https://play.nim-lang.org/#pasty=SwTPtfyc |
09:22:20 | FromDiscord | <drunkenalcoholic> ``json |
09:22:41 | FromDiscord | <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:48 | FromDiscord | <albassort> @drunkenalcoholic Why would you access "status" before "result" if result is not a child of status? |
09:33:48 | FromDiscord | <albassort> second thing is, result is a array (JArray) which you need to indice first or handle that there are multiple results |
09:33:56 | FromDiscord | <drunkenalcoholic> thats me just throwing it in there while not knowing how it fully works, it should be ["result][0]["temperature"] |
09:34:02 | FromDiscord | <albassort> data["result"]'0...["temperature"] |
09:34:04 | FromDiscord | <albassort> you got it |
09:34:10 | FromDiscord | <drunkenalcoholic> doesn't work |
09:34:17 | FromDiscord | <albassort> what is the exception? |
09:34:30 | FromDiscord | <albassort> wait |
09:34:40 | FromDiscord | <albassort> you should format your json strings when you're looking at them because they can be silly |
09:35:22 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=SPscoGAu |
09:35:52 | FromDiscord | <drunkenalcoholic> not giving the error now, but not giving the value either |
09:35:55 | FromDiscord | <albassort> you need to do .get_float() |
09:36:02 | FromDiscord | <albassort> sorry getFloat() |
09:36:14 | FromDiscord | <drunkenalcoholic> yeah i had getStr() |
09:36:31 | FromDiscord | <albassort> well its not in a string, so you need to get it as a float |
09:36:33 | FromDiscord | <albassort> then do $ |
09:36:37 | FromDiscord | <drunkenalcoholic> hmm now it working without getStr or getFloat |
09:36:48 | FromDiscord | <albassort> yes because its just a Jtype |
09:37:00 | FromDiscord | <drunkenalcoholic> ok it working now, must have been something I missed last time as I am sure I tried all these before |
09:37:10 | FromDiscord | <albassort> This is good :) |
09:37:23 | FromDiscord | <drunkenalcoholic> thank you @albassort |
10:14:36 | FromDiscord | <CANTAP969> image.png https://media.discordapp.net/attachments/371759389889003532/1251479968341430352/image.png?ex=666ebb0b&is=666d698b&hm=a3dc2010b61fd15d9a16d4099255c32b7abf7cbcb992872803937e6a522e6a44& |
10:30:44 | FromDiscord | <albassort> thanks |
12:20:05 | FromDiscord | <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:25 | FromDiscord | <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:32 | FromDiscord | <Robyn [She/Her]> Ah |
12:34:35 | FromDiscord | <Robyn [She/Her]> Figured it out |
12:35:20 | * | lucasta quit (Quit: Leaving) |
12:36:34 | FromDiscord | <Robyn [She/Her]> The query builder was actually pretty easy, neat |
12:37:09 | FromDiscord | <Robyn [She/Her]> Even does basic type and field validation :> |
12:46:53 | FromDiscord | <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:18 | FromDiscord | <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:48 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "Out of curiosity, if": Yeah I'd say so |
12:49:58 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/nBDwUyaD |
12:50:39 | FromDiscord | <Phil> (edit) "https://pasty.ee/UsxPvSwd" => "https://pasty.ee/TwadGzGo" |
12:55:47 | FromDiscord | <Phil> Oh god, which was the type again that is basically available for all kinds of iterables? |
12:56:00 | FromDiscord | <Phil> where you can put both seq, array etc into it? |
12:58:35 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "Oh god, which was": Huh? |
12:58:54 | FromDiscord | <Phil> for proc parameters when you want to accept all sorts of sequence-like datatypes |
12:59:45 | * | coldfeet_ joined #nim |
12:59:47 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=JjmLclEx |
13:00:05 | FromDiscord | <Phil> Basically for when you want to allow folks to use your proc with both sequences and arrays |
13:00:11 | FromDiscord | <Phil> That type had a name |
13:02:09 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "That type had a": `openArray` :p |
13:29:20 | FromDiscord | <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:28 | FromDiscord | <albassort> except for like 3 functions |
13:29:40 | FromDiscord | <albassort> that all yield their own strange types |
13:30:13 | FromDiscord | <Phil> In reply to @albassort "heres how most libraries": Yeah but I can do that with 2 ways |
13:30:20 | FromDiscord | <albassort> and they need to be in a separate file/crate/whatever than the main stuff for extra "oh no" |
13:30:23 | FromDiscord | <Phil> I can make that weird type an object type or a distinct type |
13:36:05 | FromDiscord | <albassort> well |
13:36:08 | FromDiscord | <albassort> i think in a nim context |
13:36:30 | FromDiscord | <albassort> you have two options, black or white |
13:37:06 | FromDiscord | <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:38 | FromDiscord | <albassort> honestly, I think that you should trust the developer |
13:41:19 | FromDiscord | <albassort> Result is so powerful in nim that I feel the need to implement it in every function in my Rust Code |
13:41:21 | FromDiscord | <albassort> (edit) "Code" => "code" |
13:51:27 | * | xet7 quit (Remote host closed the connection) |
13:53:19 | * | xet7 joined #nim |
13:54:11 | FromDiscord | <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:40 | FromDiscord | <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:35 | FromDiscord | <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:49 | FromDiscord | <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:06 | FromDiscord | <albassort> (edit) "will" => "with" |
14:06:20 | FromDiscord | <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:48 | FromDiscord | <zumi.dxy> imo ffi is kinda messy no matter how you put it |
14:09:28 | FromDiscord | <albassort> err, perhaps i should have spelt it lowercase |
14:09:32 | FromDiscord | <albassort> the variable is named result |
14:09:42 | FromDiscord | <albassort> its whatever struct the function returns |
14:10:11 | FromDiscord | <zumi.dxy> oh |
14:10:25 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=JysYIUyj |
14:11:03 | FromDiscord | <zumi.dxy> I suppose you find more often functions that incrementally build up |
14:11:14 | FromDiscord | <albassort> wdym |
14:11:36 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=exSBzzah |
14:11:38 | FromDiscord | <zumi.dxy> i thought that's what `result` is best for |
14:11:44 | FromDiscord | <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:54 | FromDiscord | <albassort> well in this case, i have no choice because of this |
14:12:07 | FromDiscord | <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:52 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=gkTxDGfl |
15:32:56 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#pasty=zJtPmDux" => "https://play.nim-lang.org/#pasty=IrnUeMDp" |
15:38:19 | FromDiscord | <vindaar> Did you compile with `-d:openmp`? |
15:39:34 | FromDiscord | <Phil> I thought that was arraymancer specific, fair shout, will try again |
15:39:52 | FromDiscord | <Phil> Still the same |
15:40:30 | FromDiscord | <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:07 | FromDiscord | <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:36 | FromDiscord | <vindaar> (it's not helped by the fact that Nim "sits between" us and the C code |
15:53:51 | FromDiscord | <leorize> openmp is not a threadpool Phil |
15:56:14 | FromDiscord | <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:24 | FromDiscord | <vindaar> sent a long message, see https://pasty.ee/bQhIEhrY |
16:16:07 | FromDiscord | <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:30 | FromDiscord | <Phil> Yeah that's a gcc exclusive, clang won't compile that |
16:21:15 | FromDiscord | <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:07 | FromDiscord | <.bobbbob> does the compiler check if a let is computable at compile time and assign it at compile time? as an optimization |
17:14:15 | FromDiscord | <Phil> I wouldn't bet on it |
17:42:34 | FromDiscord | <frusadev> Hello how to mutate iterated variables in a loop. `for vars in varsss` I mean how do i mutate vars? |
17:46:46 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/igMOZyee |
17:53:19 | FromDiscord | <.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:30 | FromDiscord | <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:28 | FromDiscord | <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:39 | FromDiscord | <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:57 | FromDiscord | <planetis_m> It does fold some expressions but others not, like ones that have fp math |
18:58:55 | FromDiscord | <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:07 | FromDiscord | <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:18 | FromDiscord | <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:57 | FromDiscord | <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:23 | FromDiscord | <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:43 | FromDiscord | <Phil> First figure out what you want to do, then you can figure out the how 😄 |
20:49:06 | FromDiscord | <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:58 | FromDiscord | <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:18 | FromDiscord | <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:33 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "Number of requests? ": Number of requests |
21:12:32 | FromDiscord | <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:43 | FromDiscord | <Phil> (edit) "caddy." => "the caddy solution." |
21:13:09 | FromDiscord | <Robyn [She/Her]> Fair |
21:13:15 | FromDiscord | <Robyn [She/Her]> I might have both either way |
21:13:42 | FromDiscord | <Robyn [She/Her]> And then if I use Caddy I'll just disable it on the API side |
22:10:14 | FromDiscord | <xkonti> In reply to @Elegantbeef "<@244832576215318528> I could not": This is amazing! I will definitely try it out after the weekend! |
22:48:09 | FromDiscord | <raidcade> how can I remove a symlink without deleting the original directory? |
22:49:15 | FromDiscord | <Elegantbeef> does `rmFile` not work? |
22:49:26 | FromDiscord | <Elegantbeef> Wait it's removeFile in os |
22:52:01 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> Cannot say much do not use windows so cannot test this |
23:00:34 | FromDiscord | <Robyn [She/Her]> Hm do I ratelimit based on IP or on the user ID? |
23:02:18 | FromDiscord | <leorize> you can start with figuring out what happens if you're hammered |
23:02:49 | FromDiscord | <Robyn [She/Her]> Wdym? |
23:02:50 | FromDiscord | <Elegantbeef> Most people slur their speech and occasionally piss themselves |
23:02:56 | FromDiscord | <Robyn [She/Her]> Lmao |
23:04:41 | FromDiscord | <leorize> basically what happens if you got hit with a flood of requests |
23:04:47 | FromDiscord | <leorize> what is required to make such requests and so on |
23:07:19 | FromDiscord | <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:13 | FromDiscord | <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:50 | FromDiscord | <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:31 | FromDiscord | <leorize> what do you have to id for rate limiting for the latter? |
23:38:37 | * | mal`` quit (Quit: Leaving) |
23:39:02 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "what do you have": The IP, and that's it |
23:39:23 | FromDiscord | <Robyn [She/Her]> Session lookup could get cheaper with a cache but that'll come later tbh |
23:39:45 | FromDiscord | <leorize> now you got a rate limit target |
23:40:20 | FromDiscord | <Robyn [She/Her]> Fair point xD |
23:40:24 | FromDiscord | <Robyn [She/Her]> Thanks Leorize |
23:41:11 | FromDiscord | <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:17 | FromDiscord | <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:30 | FromDiscord | <leorize> in this case, what else can you do? |
23:42:14 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "if an user flood": Could always ratelimit both if really needed |
23:42:35 | FromDiscord | <leorize> so it wasn't an `or` question after all \:p |
23:42:49 | FromDiscord | <Robyn [She/Her]> Also a good point aha |
23:46:47 | FromDiscord | <leorize> usually, you need to protect if there is an asymmetry in computation cost between the client and the server |
23:47:48 | FromDiscord | <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:20 | FromDiscord | <Robyn [She/Her]> It makes sense to me, that's how I was going about things before too |
23:48:44 | FromDiscord | <Robyn [She/Her]> If I had to do DB access, before that I'd add a ratelimit check |