00:09:34 | FromDiscord | <morgan> is there anything that handles converting nim variadic arguments to a c va_list? |
00:16:07 | FromDiscord | <morgan> im not sure i need to implement it yet |
00:16:19 | FromDiscord | <morgan> it's in two debug functions in bgfx |
00:18:18 | FromDiscord | <riku5543> Hi there. I seem to be having some memory issues with Nim when trying to work with the cstring type. The code should output the same thing twice, but the second time around, the immutable variable gets messed up somehow. Here's the code. https://play.nim-lang.org/#pasty=sWYjnUCJ |
00:19:41 | FromDiscord | <ElegantBeef> You are making a dangling pointer |
00:19:55 | FromDiscord | <ElegantBeef> `bleh.cstring` does not extend the lifetime of `bleh` |
00:20:43 | FromDiscord | <riku5543> Would I have to return like a brand new cstring somehow? |
00:20:55 | FromDiscord | <ElegantBeef> You would have to return a manually managed cstring |
00:20:59 | * | krux02 quit (Remote host closed the connection) |
00:20:59 | FromDiscord | <ElegantBeef> Why are you using cstring is my question |
00:21:28 | FromDiscord | <riku5543> I was interfacing with some C code (raygui) and the parameter for comboboxes requires a cstring |
00:21:40 | FromDiscord | <ElegantBeef> So use a string and pass `myString.cstring` |
00:21:46 | FromDiscord | <ElegantBeef> Do not attempt to have a cstring outlive your `string` |
00:22:04 | FromDiscord | <riku5543> Alright haha, thanks |
00:23:03 | FromDiscord | <ElegantBeef> Do you have any reference material for the combo box procedure? |
00:23:08 | FromDiscord | <ElegantBeef> I cannot find any documentation for it |
00:24:15 | FromDiscord | <riku5543> Not exactly haha, but here's the header file for it↵https://github.com/raysan5/raygui/blob/master/src/raygui.h↵↵RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char text, bool checked); |
00:24:40 | FromDiscord | <riku5543> (edit) "Not exactly haha, but here's the header file for it↵https://github.com/raysan5/raygui/blob/master/src/raygui.h↵↵RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char text, bool checked);" => "sent a code paste, see https://play.nim-lang.org/#pasty=GZTaYJpP" |
00:25:40 | FromDiscord | <riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=PlQNVYxh |
00:26:00 | FromDiscord | <ElegantBeef> Right so that likely should be an `array[entries, cstring]` |
00:26:24 | FromDiscord | <ElegantBeef> Or is text supposed to be new line seperated |
00:26:30 | FromDiscord | <ElegantBeef> That's an awful api 😄 |
00:26:37 | FromDiscord | <riku5543> Ah my bad, in the widget gallery example, it's formatted as "OptionA;OptionB" etc |
00:27:13 | FromDiscord | <ElegantBeef> Ah then yea just use a Nim string and explicitly do `cstring myString` ensuring `myString` outlives `guiComboBox` call |
00:28:11 | FromDiscord | <riku5543> Alright \:P |
00:29:25 | FromDiscord | <ElegantBeef> You have fallen into the trap in thinking that `cstring` keeps `string` alive, but due to how `string` works it does not |
00:30:22 | FromDiscord | <riku5543> I'm surprised that the data isn't just copied and behaves like a pointer. But I guess since it's basically a pointer to a char array it would make sense that it doesn't create a whole new variable |
00:30:32 | FromDiscord | <ElegantBeef> Well this is the point of how Nim does it's strings |
00:30:40 | FromDiscord | <ElegantBeef> You can use all of the stdlib and not have to copy to send it to C |
00:30:56 | FromDiscord | <riku5543> That sounds pretty efficient honestly |
00:31:10 | FromDiscord | <ElegantBeef> Almost every modern string implementation is a pascal string that is also a cstring internally |
00:31:36 | FromDiscord | <ElegantBeef> Except those that treat `string` as a sequence of runes |
00:32:35 | FromDiscord | <ElegantBeef> In reply to @riku5543 "That sounds pretty efficient": Some might say it's a 0-cost abstraction |
00:32:45 | FromDiscord | <ElegantBeef> It's not 0-cost cause it takes an extra byte! |
00:33:21 | FromDiscord | <riku5543> Haha |
00:34:41 | FromDiscord | <riku5543> Thanks to you I can dream of having my own desktop environment haha https://media.discordapp.net/attachments/371759389889003532/1248797313254690896/image.png?ex=6664f8a1&is=6663a721&hm=359d577d757f879568c7288be0b61a73cfb4256000f5422b8dc992d3ebb4bee2& |
00:34:56 | FromDiscord | <ElegantBeef> Using raygui as a GUI toolkit is a choice |
00:35:03 | FromDiscord | <ElegantBeef> No sure I'd do it, but to each their own |
00:35:47 | FromDiscord | <riku5543> I made something similar using web tech a long time ago \:P Having nim do everything is a whole lot nicer at the very least |
00:37:05 | FromDiscord | <ElegantBeef> How accessible is raygui? Curious how much control the programmer has |
00:39:24 | FromDiscord | <riku5543> It's pretty similar to imgui, it's immediate mode and everything so you gotta keep track of state yourself. You can also mix it with regular ol raylib so you could make your own controls if you wanted to |
00:39:44 | FromDiscord | <ElegantBeef> Ah that's to say it's not |
00:40:39 | FromDiscord | <riku5543> I guess infinite control isn't accessible lol |
00:41:12 | FromDiscord | <morgan> so raylib uses like ui widgets and shapes and such? |
00:42:25 | FromDiscord | <riku5543> raygui has all the ui widgets, raylib is a general-purpose graphics library that can do whatever (draw rectangles, text, control framerate, get input, etc) |
00:42:35 | FromDiscord | <riku5543> (edit) "graphics" => "game engine(?)" |
00:42:59 | FromDiscord | <ElegantBeef> I'd calle it a framework more than an engine not that those terms mean anything |
00:43:34 | FromDiscord | <morgan> ah ok |
00:44:21 | FromDiscord | <morgan> it seemed a bit more focused on that sorta abstraction so i didn't look much into it |
00:44:52 | FromDiscord | <ElegantBeef> It's meant for education, but you can use it as a full game dev library |
00:45:03 | FromDiscord | <morgan> In reply to @morganalyssa "it seemed a bit": (as opposed to just papering over the differences between opengl and directx etc but still based on meshes and shaders) |
00:45:15 | FromDiscord | <ElegantBeef> It just uses opengl of course |
00:45:20 | FromDiscord | <riku5543> I used it instead of sdl2 to make an emulator \:D (It handled some things a little better) |
00:45:39 | FromDiscord | <ElegantBeef> I'm too deep into opengl + sdl2 to think raylib can do any better 😄 |
00:46:03 | FromDiscord | <riku5543> Fair \:P I kinda gave up on sdl2 through nim cause the library is just way too c-heavy if you know what I mean |
00:46:11 | FromDiscord | <morgan> i think sokol can do better than those tho |
00:46:17 | FromDiscord | <ElegantBeef> To each their own |
00:46:33 | FromDiscord | <ElegantBeef> Opengl works well enough for me |
00:46:42 | FromDiscord | <ElegantBeef> Plus runs on all platforms I care about |
00:46:56 | FromDiscord | <morgan> yea and sokol can use opengl |
00:47:08 | FromDiscord | <morgan> or use vulkan, or metal, or two directx options |
00:47:15 | FromDiscord | <morgan> and webgpu |
00:47:16 | FromDiscord | <ElegantBeef> Yea I know what it does |
00:47:29 | FromDiscord | <morgan> ah ok |
00:48:06 | FromDiscord | <morgan> i had been using plain opengl before and it was a complete mess and i had errors i just could not fix |
00:48:13 | FromDiscord | <ElegantBeef> User error |
00:48:14 | FromDiscord | <ElegantBeef> 😛 |
00:48:20 | FromDiscord | <morgan> yea |
00:48:31 | FromDiscord | <morgan> but it's also bad api design lol |
00:48:40 | FromDiscord | <riku5543> Try using vulkan 💀 |
00:48:44 | FromDiscord | <ElegantBeef> I truthfully think it's fine if you use opengl 4.5+ |
00:48:51 | FromDiscord | <ElegantBeef> Most people stick to like opengl3.3 and whine about the API |
00:49:01 | FromDiscord | <ElegantBeef> DSA makes life way less silly |
00:49:40 | FromDiscord | <ElegantBeef> You no longer need to do `glBind(GlTexture, myTextureHandle); glSomeOperation(GlTexture, ...)` |
00:49:40 | FromDiscord | <morgan> i was targetting some 3 version because juce only allowed targetting specific versions and the 4 version they had was newer than apple's latest version (yea i know it's part apple's fault not continuing to update their opengl support) |
00:49:54 | FromDiscord | <ElegantBeef> you just do `glNamedOperation(myTextureHandle, ...)` |
00:50:03 | FromDiscord | <ElegantBeef> It removes a lot of the global state management |
00:50:13 | FromDiscord | <riku5543> Whaat I wanna try that |
00:50:40 | FromDiscord | <morgan> that was actually the thing that pushed me to switch from juce and write plugins in nim (yea i traded pain for different pain lol) |
00:51:02 | FromDiscord | <ElegantBeef> I havent fully moved to DSA but I do try to use it in all of my new code 😄 |
00:51:16 | FromDiscord | <ElegantBeef> I heavily use SSBOs aswell so I remove a lot of uniforms |
00:52:01 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=tvatEDMe |
00:52:16 | FromDiscord | <ElegantBeef> Only set uniforms for the entire batch renderer |
00:52:18 | FromDiscord | <ElegantBeef> So lovely |
00:52:28 | FromDiscord | <morgan> nice |
00:52:30 | FromDiscord | <riku5543> Spicy |
00:52:46 | FromDiscord | <riku5543> Does that mean you can use opengl 4.5 in nim then? |
00:52:55 | FromDiscord | <ElegantBeef> Of course |
00:53:03 | * | SchweinDeBurg quit (Quit: WeeChat 4.4.0-dev) |
00:53:16 | FromDiscord | <ElegantBeef> <https://github.com/beef331/truss3d/> My shitty framework is here if you want to investigate |
00:53:28 | * | SchweinDeBurg joined #nim |
00:54:36 | FromDiscord | <riku5543> Hm wait a second, since I'm wrapping raygui manually, does that mean I could let the user pass in a regular string and just convert it to a cstring before calling the C code? \:o |
00:54:43 | FromDiscord | <ElegantBeef> Yes |
00:55:03 | FromDiscord | <riku5543> My library wrappers just got so much better |
00:55:05 | * | beholders_eye quit (Read error: Connection reset by peer) |
00:55:27 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=AHLXkphe |
00:55:38 | FromDiscord | <ElegantBeef> (edit) "https://play.nim-lang.org/#pasty=vHzSzlGW" => "https://play.nim-lang.org/#pasty=PXYVAxEB" |
00:55:42 | FromDiscord | <ElegantBeef> Will work just fine |
00:55:55 | FromDiscord | <ElegantBeef> Also you do know about naylib right? |
00:56:43 | FromDiscord | <riku5543> Yeah \:D It doesn't wrap raygui though last I checked |
00:57:06 | FromDiscord | <riku5543> (So I just use my wrapper and naylib together) |
00:58:19 | FromDiscord | <riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=BJNdhxMA |
01:01:05 | * | beholders_eye joined #nim |
01:01:08 | FromDiscord | <ElegantBeef> No it's not |
01:01:15 | FromDiscord | <ElegantBeef> That's not even close |
01:01:42 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=IHiJQBHA |
01:01:44 | FromDiscord | <ElegantBeef> There we go |
01:01:47 | FromDiscord | <ElegantBeef> We're now Nimming |
01:02:21 | FromDiscord | <riku5543> Whoa you turned it into a bool |
01:02:25 | FromDiscord | <riku5543> Like automatically |
01:02:56 | FromDiscord | <ElegantBeef> What did you think `== 0` was doing? |
01:03:19 | FromDiscord | <ElegantBeef> `guiDropdownBoxOrig(bounds, text.cstring, active, editMode).bool` is also valid |
01:03:41 | FromDiscord | <ElegantBeef> Actually that should've been `!= 0` originally |
02:02:30 | * | rockcavera quit (Remote host closed the connection) |
02:07:03 | * | beholders_eye quit (Read error: Connection reset by peer) |
02:12:30 | * | beholders_eye joined #nim |
02:43:00 | * | beholders_eye quit (Read error: Connection reset by peer) |
02:49:20 | * | beholders_eye joined #nim |
03:01:56 | * | beholders_eye quit (Read error: Connection reset by peer) |
03:07:54 | * | beholders_eye joined #nim |
03:11:18 | * | beholders_eye quit (Read error: Connection reset by peer) |
03:17:17 | * | beholders_eye joined #nim |
04:03:41 | FromDiscord | <xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=ybyStKDw |
04:04:26 | FromDiscord | <ElegantBeef> It's fine as is |
04:05:37 | * | beholders_eye quit (Read error: Connection reset by peer) |
04:10:12 | FromDiscord | <xkonti> I can't seem to find a compile-time implementation of the `myAppend` that will actually be compile-time 😦 |
04:10:49 | FromDiscord | <ElegantBeef> `add` |
04:11:27 | * | beholders_eye joined #nim |
04:14:19 | FromDiscord | <ElegantBeef> `const` forces compile time evaluation |
04:14:46 | FromDiscord | <xkonti> Oh. That works! I guess I went through so many weird issues that I lost the clarity 😅 |
04:49:47 | * | beholders_eye quit (Ping timeout: 264 seconds) |
05:37:11 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/NaOueTMm |
05:37:50 | FromDiscord | <Phil> You can, in fact, combine the above with whatever SQL query you do against the DB for authentication |
05:38:27 | FromDiscord | <Phil> So it wouldn't even be an extra SQL query, assuming you're not doing token based auth. |
05:39:43 | FromDiscord | <Phil> If you are doing JWT based auth, you could play around with the thought of storing the boolean whether the user is past their limit or not inside the token, which circumvents the db trip all together the same way JWT based auth avoids DB trips for permission checks more generally |
05:42:35 | FromDiscord | <Phil> However, the above assumes you plan a rate limiting scheme that can be expressed with that kind of DB setup. It all depends on business logic.↵If its sufficiently more complex, you might need to write an entry into the DB per request and then aggregate over that. |
05:43:41 | FromDiscord | <Phil> In that case to avoid needing to aggregate every time you can write yourself a materialized view aka just a second table that is basically derived from the first table and just contains the data in a simple format to answer your question whether the user can have access to the API or not. |
05:44:03 | FromDiscord | <Phil> The options for this kind of stuff are myriad and it can range from medium complex to really tricky depending on business needs |
05:59:30 | FromDiscord | <xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=cxdPrDPp |
06:01:46 | FromDiscord | <xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=lwaaQrpy |
06:05:02 | FromDiscord | <ElegantBeef> Why even use a template |
06:08:06 | FromDiscord | <xkonti> In reply to @elegantbeef "Why even use a": My brain hurts when dealing with macros... At least for now. Should I make a macro that defines macros instead? |
06:08:21 | FromDiscord | <ElegantBeef> No you should stop what you're doing 😄 |
06:10:41 | FromDiscord | <xkonti> Still... I need to solve this somehow. |
06:15:01 | FromDiscord | <ElegantBeef> should be `bodyNode & node.repr` to build a string |
06:17:16 | FromDiscord | <xkonti> In reply to @elegantbeef "should be `bodyNode &": Not sure if I understand in the context of my code... |
06:17:51 | FromDiscord | <ElegantBeef> sorry your `bodyNode` should just be a string |
06:18:52 | FromDiscord | <ElegantBeef> Actually i'm wrong |
06:29:55 | FromDiscord | <ElegantBeef> @xkonti https://play.nim-lang.org/#pasty=tJPgsfNL does work |
06:29:57 | FromDiscord | <ElegantBeef> But yea idk |
06:30:10 | FromDiscord | <basilajith> When I call `now()` from `std/times` I get a value like this: "2024-06-08 06:21:04+00"↵↵However, how I can I get a value like this "2024-06-04 11:05:48.791403+00" with milliseconds? |
06:30:51 | FromDiscord | <ElegantBeef> format time |
06:33:07 | FromDiscord | <xkonti> @ElegantBeef Whoah! That's awesome! I was trying to make a macro define other macros, but then the backtick values stop working from the internal macro... |
06:33:21 | FromDiscord | <ElegantBeef> templates + macros |
06:33:51 | FromDiscord | <xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=wqkvrORQ |
06:34:39 | FromDiscord | <ElegantBeef> there is a html dsl |
06:35:41 | * | ntat joined #nim |
06:36:06 | FromDiscord | <ElegantBeef> Think there is htmlgen or whatever in nimble you can refer to |
06:50:21 | FromDiscord | <xkonti> Niml: https://nimble.directory/pkg/niml↵Thank you for your help @ElegantBeef ! |
08:53:35 | * | coldfeet joined #nim |
11:00:41 | * | beholders_eye joined #nim |
12:24:26 | * | casaca quit (Read error: Connection reset by peer) |
12:24:27 | * | ursa-major quit (Write error: Connection reset by peer) |
12:24:27 | * | adigitoleo quit (Read error: Connection reset by peer) |
12:24:27 | * | noeontheend quit (Write error: Broken pipe) |
12:24:27 | * | johuck quit (Write error: Connection reset by peer) |
12:24:28 | * | mronetwo quit (Remote host closed the connection) |
12:24:28 | * | robertmeta quit (Remote host closed the connection) |
12:24:36 | * | mronetwo joined #nim |
12:24:39 | * | robertmeta joined #nim |
12:24:40 | * | johuck joined #nim |
12:24:42 | * | noeontheend joined #nim |
12:24:43 | * | ursa-major joined #nim |
12:24:51 | * | adigitoleo joined #nim |
12:37:30 | * | deadmarshal_ quit (Ping timeout: 256 seconds) |
12:39:32 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "The options for this": Thanks for explaining, Phil! |
13:04:23 | ehmry | are there tools for processing the JSON format for Nim docs? |
13:05:41 | FromDiscord | <sOkam! 🫐> there are at least 3-4 html dsl libraries |
13:05:56 | FromDiscord | <sOkam! 🫐> best is probably treeform's |
13:06:13 | FromDiscord | <sOkam! 🫐> `taggy` I believe it was called |
13:17:59 | * | ntat quit (Quit: Leaving) |
13:53:46 | FromDiscord | <user2m> In reply to @xkonti "Niml: https://nimble.directory/pkg/niml Thank you": theres also dekao |
14:27:47 | * | lucasta joined #nim |
14:30:37 | FromDiscord | <fabric.input_output> just make your own like everyone else :P |
14:33:25 | * | coldfeet quit (Remote host closed the connection) |
14:46:22 | FromDiscord | <user2m> In reply to @fabric.input_output "just make your own": lol yeah we need to settle on one main one. taggy looks great |
15:21:56 | FromDiscord | <double_spiral> Is there a way to rename imported symbols? Im using bindings for a c library so for whatever reason `const renamed_func = funcToRename` doesnt work |
15:45:06 | FromDiscord | <double_spiral> Ok nvm nim is aparently the collest language ever invented and automatically translates snake case with camel case |
15:45:15 | FromDiscord | <double_spiral> awesome |
15:49:27 | * | coldfeet joined #nim |
16:25:02 | FromDiscord | <sOkam! 🫐> In reply to @double_spiral "Ok nvm nim is": only the first character matters. the rest you are free to do whatev |
16:25:11 | FromDiscord | <sOkam! 🫐> one of the best features of nim, agreed |
16:47:14 | * | lucasta quit (Remote host closed the connection) |
16:47:59 | * | ntat joined #nim |
17:42:13 | * | ntat quit (Ping timeout: 268 seconds) |
19:18:53 | * | ntat joined #nim |
19:51:47 | * | ntat quit (Quit: Leaving) |
20:01:29 | * | krux02 joined #nim |
20:54:46 | * | coldfeet quit (Remote host closed the connection) |
22:01:44 | * | deadmarshal_ joined #nim |
22:16:28 | * | beholders_eye quit (Read error: Connection reset by peer) |
22:22:08 | * | beholders_eye joined #nim |
22:28:41 | * | beholders_eye quit (Read error: Connection reset by peer) |
22:34:35 | * | beholders_eye joined #nim |