<< 24-02-2025 >>

00:28:50FromDiscord<Robyn [She/Her]> would it be hacky to make a macro that makes a copy of a typical iterator but instead of using Nim's `iterator` keyword, it's a proc called `<originalName>Iter` that returns a generic iterator type that you can call `next`/`hasNext` on instead of using a for loop?
00:30:44*beholders_eye quit (Ping timeout: 260 seconds)
01:31:53*alexdaguy joined #nim
01:44:26FromDiscord<Elegantbeef> @Robyn [She/Her] https://github.com/beef331/slicerator/blob/master/src/slicerator/closures.nim#L65
01:52:10FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095> https://github.com/beef331/sl": oooh
01:54:44FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095> https://github.com/beef331/sl": does this run an iterator and capture it? i don't really understand the macro that well and I can't tinker with it on my phone rn
01:55:19FromDiscord<Robyn [She/Her]> So it's all 'pre-cached' ig
01:59:01FromDiscord<heysokam> @aintea I learned zig after 2y of using nim, but I never tried figuring out the ziglings validation system↵I also started a nimlings project, but moved to zig right around the time I started it↵Can probably help with zig-nim conversion though. Feel free to ping or dm whenever
01:59:52FromDiscord<heysokam> In reply to @aintea "Any suggestion is welcome": did you find how _(or at least where, so I can take a look)_ ziglings is validating their exercises?↵you can probably do it with string comparison in nim, but wondering if that's how they validate it themselves or if they are using something else
02:47:39*protium joined #nim
03:03:06*protium quit (Quit: My Mac has gone to sleep. ZZZzzz…)
03:17:52*alexdaguy quit (Quit: w)
03:26:32FromDiscord<Robyn [She/Her]> In reply to @battery.acid.bubblegum "does this run an": read up on closure iterators some more and this makes more sense now, rad
03:35:14FromDiscord<nasuray> In reply to @heysokam "did you find how": All the ziglings verification is handled in the build.zig, it's just running the exercises and comparing the outputs.
03:36:28FromDiscord<heysokam> In reply to @nasuray "All the ziglings verification": that doesn't make full complete sense because it is also checking that you are doing the right thing in the code
03:37:06FromDiscord<nasuray> It's just compiling it. The point of the exercises is to learn how to read the compiler error messages to fix broken code
03:38:44FromDiscord<heysokam> I remember there was more to them than that. but it was a long time ago and can't remember what it was exactly
03:39:49FromDiscord<heysokam> plus I never looked into the solutions folder to not spoil my learning, so my memory is vague↵but I do remember it was more than just a return code value
03:45:55*ensyde joined #nim
04:18:55*rockcavera quit (Remote host closed the connection)
04:26:02FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#pasty=KrdKiYMM
04:26:32FromDiscord<nnsee> oh. never mind. that doesn't work on Discord's markdown flavor. excellent
04:39:20FromDiscord<Elegantbeef> @Robyn [She/Her] yea it just generalizes a closure iterator generator and works for any iterator
06:07:08*protium joined #nim
06:21:32*ntat joined #nim
06:29:27*protium quit (Quit: My Mac has gone to sleep. ZZZzzz…)
07:12:33*protium joined #nim
07:18:40FromDiscord<gogolxdong666> https://github.com/gogolxdong/mcp-nim
07:19:37FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095> yea it just": that's rad honestly, gonna keep it in mind for my continuations impl since I wanna unwrap for loops
07:21:14FromDiscord<ajusa> Is there an easy way to have malebolgia return a ref type? When I try having the spawn return a ref type I get↵`malebolgia/paralgos.nim(42, 21) Error: 'toTask' takes a GC safe call expression`
07:22:03FromDiscord<Elegantbeef> Make it return a `Isolate[T]` and it might work
07:22:14FromDiscord<Elegantbeef> refs are sorta kinda thread locked allocations
07:22:57*alexdaguy joined #nim
07:23:12FromDiscord<Elegantbeef> @Robyn [She/Her] are you planning on using closure iterators as a way to thunk for loops?
07:24:08FromDiscord<ajusa> In reply to @Elegantbeef "Make it return a": "expression cannot be isolated" sadly
07:24:46FromDiscord<Elegantbeef> Well isolated requires you to create the graph inside
07:24:46FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#pasty=XRYcJwAu
07:24:59FromDiscord<Elegantbeef> It's not recursive though
07:25:13FromDiscord<Elegantbeef> You can use `Node` there just fine
07:25:38FromDiscord<Elegantbeef> Since `seq[Node]` is pointer indirected the `sizeof(Node)` would be `24`
07:25:40FromDiscord<Elegantbeef> whoops
07:25:49FromDiscord<Elegantbeef> 32
07:27:29*alexdaguy quit (Client Quit)
07:28:23FromDiscord<Elegantbeef> \But yea if it's indeed recursive and requires `ref` you can try to move the creation of the graph into the line that returns or alias the spawn with a proc that wraps the construction with an isolate
07:28:31FromDiscord<ajusa> Good point, and I've removed that `ref` Still gives me the same error around toTask taking a gc safe
07:28:54FromDiscord<Elegantbeef> Right gcsafe is not related to ref though, it's related to accessing global memory
07:29:21FromDiscord<Elegantbeef> If your proc accesses a global variable you need to wrap it in `{.cast(gcSafe).}:` or change how it works
07:31:51FromDiscord<ajusa> I wrapped it in a cast. I'm not accessing any global variables (as far as I can tell), and it worked for a different non-ref object which led me to believe that was the problem. Not exactly sure what happened, but it works now. Thanks beef!
07:32:19FromDiscord<Elegantbeef> Can I see the proc you're calling?
07:33:39*protium quit (Quit: My Mac has gone to sleep. ZZZzzz…)
07:33:44FromDiscord<Elegantbeef> Oh is the proc recursive?
07:33:50FromDiscord<Elegantbeef> If the proc is recursive it also breaks gcsafety analysis
07:34:00FromDiscord<Elegantbeef> So you can just mark it `{.gcsafe.}` and it should work
07:35:37FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#pasty=qhkKVQAK
07:36:28FromDiscord<ajusa> yup that was it, it's complaining because of fromJson from jsony not being gcsafe
07:36:40FromDiscord<Elegantbeef> Right so `get` or `fromJson` might be recursive and therefore not gcsafe
07:36:50FromDiscord<ajusa> yup... weird that I've never run into this before
07:37:02FromDiscord<ajusa> safe to cast in that case, I'm not going to fork jsony over that
07:37:12FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095> are you planning": Yeah, thunk as in use it as a yield point, right?
07:37:21FromDiscord<ajusa> thanks again beef!
07:38:02FromDiscord<Elegantbeef> Well thunking is generally meant for delaying evaluation, each leg of the for loop can be though of as an evaluation I'd imagine
07:38:49FromDiscord<Robyn [She/Her]> yep that's what I'm thinking of
07:39:42*alexdaguy joined #nim
07:40:06FromDiscord<Robyn [She/Her]> I remember talking a bit about this with the nim-cps folk and since inline iterators are an implementation detail and compiled out, would require some work arounds (like what slicerator does) iirc
07:42:30FromDiscord<Elegantbeef> Indeed, though one issue is that it makes a generator for every invocation so can pad the binary
07:45:01FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "Indeed, though one issue": Ah... Surely I could modify your macro slightly to instead produce the generated closure iterator function?
07:46:46FromDiscord<Elegantbeef> You might be able to, don't recall why I made a proc
07:47:06FromDiscord<Robyn [She/Her]> shrug
07:47:21FromDiscord<Robyn [She/Her]> would annotating the iterator with `{.closure.}` be enough?
07:47:31FromDiscord<Elegantbeef> No cause you want it to capture
07:48:01FromDiscord<Robyn [She/Her]> oh
07:48:07FromDiscord<Robyn [She/Her]> okay that makes sense
07:48:16FromDiscord<Elegantbeef> Removing the proc invocation it might still capture
07:48:45FromDiscord<Elegantbeef> Too late in the night for me to try and see what happens
07:51:15FromDiscord<Robyn [She/Her]> that's fair, thanks for showing me slicerators, I'm probably gonna end up drawing inspiration from it or just directly using it
09:34:58FromDiscord<aintea> In reply to @heysokam "did you find how": If you go to the ziglings repo, you will find somewhere a file called `testing-exercises` or something↵↵It looks like there is a function that takes a table as parameter where they define the name of the zig file and what it should output, then iterate over this file, compile the file, execute it and compare the results
09:35:14FromDiscord<aintea> I haven't gotten really in depth on how they generate the error message or anything though
09:36:05FromDiscord<aintea> But I'm trying a simpler approach with functions defined with as less as possible of stdout use since I cannot really test this except by executing the file
09:36:26FromDiscord<aintea> Which I technically can but until I have learnt how to use testament, I won't
10:03:40*beholders_eye joined #nim
10:08:28*xet7 quit (Quit: Leaving)
10:11:19FromDiscord<heysokam> @aintea noted, ty ✍️↵another option, which you might not have considered, is to test against the AST directly↵the data structure is easy enough to deal with, and it would give you accurate results without touching stdout at all
10:12:20FromDiscord<aintea> The problem is that I want the "challenges" to be black box
10:12:33FromDiscord<aintea> I give an input and want an output, I don't really care how they do it
10:13:04FromDiscord<aintea> And testing directly against the AST means their code should be the code I expect
10:14:19FromDiscord<heysokam> gonna be really hard to teach some concepts with that approach. or to validate that the person used the concepts at all
10:14:50*xet7 joined #nim
10:15:29FromDiscord<heysokam> simplest example, what if you wanted to teach me the difference, and best usages, of const/let/var...
10:15:45FromDiscord<heysokam> (edit) "const/let/var..." => "const/let/var...↵but then I take the exercise and hardcode every value"
10:18:17FromDiscord<heysokam> or I'm an oldschool C user and you want to teach me that unsafe memory is bad practice, by requiring refs and var T, but then I use ptr T everywhere instead
10:19:04FromDiscord<heysokam> nim has a lot of those things that only matter because they are clean and readable, but do not modify the output
10:22:36FromDiscord<nnsee> In reply to @heysokam "simplest example, what if": you can also test against compiler output
10:23:04FromDiscord<nnsee> ie deliberately make the user try and change a value after it's been set by let and test against compiler errors
10:24:03FromDiscord<heysokam> you wouldn't be able to tell if I took your `let` and marked it `var`
10:25:15FromDiscord<nnsee> how do you mean? if the compiler is not complaining, then the user is doing something "wrong" (or right, in this case)
10:25:39FromDiscord<nnsee> i've never done any of the lings things so idk how they work specifically
10:26:14*alexdaguy quit (Read error: Connection reset by peer)
10:26:58FromDiscord<heysokam> In reply to @nnsee "i've never done any": they are small snippets of code that the user has to fix
10:27:08FromDiscord<nnsee> oh i see
10:27:50FromDiscord<heysokam> the main problem is that nim has a lot of best practices code that make it incredible and really easy to use,↵but do not influence the outcome... so there is no such thing as using them "wrong" if the outcome is the same and you only test outcome
10:27:54FromDiscord<nnsee> just bolt an LLM on top of it that tests whether the solution is the intended one
10:27:58FromDiscord<nnsee> problem solved
10:28:26FromDiscord<nnsee> the answer is ALWAYS more AI
10:28:33FromDiscord<heysokam> or parse the AST of the solution and search for nodes in the tree that do what you wanted the user to do
10:28:45FromDiscord<nnsee> that seems hard and fragile
10:28:54FromDiscord<heysokam> its easy af
10:29:06FromDiscord<heysokam> the raw ast is very easy to work with
10:29:27FromDiscord<nnsee> for simple things sure
10:29:40FromDiscord<heysokam> thats what lings are
10:29:42FromDiscord<nnsee> but i'm guessing the solutions aren't all going to be as simple as "change let to var"
10:29:49FromDiscord<nnsee> or am i wrong?
10:30:08FromDiscord<heysokam> the fixes are small things that teach one concept at a time
10:30:39FromDiscord<nnsee> but some concepts require more than a little code to grasp. concepts, for example
10:31:04FromDiscord<heysokam> and you could compare the AST of a `secret/solution.number.nim` against `yoursolution.nim` and see what is missing, since the changes are always small and incremental
10:31:36FromDiscord<heysokam> In reply to @nnsee "but some concepts require": I have never touched `concepts`, and never needed them, in years
10:32:14FromDiscord<heysokam> lings are core/root basics/intermediate concepts. rarely you see them teaching advanced stuff
10:32:20FromDiscord<nnsee> fair enough then
10:32:34FromDiscord<nnsee> i still think an LLM would be fun
10:32:50FromDiscord<nnsee> i might whip this up as a proof of concept, it actually sounds pretty good as a product idea
10:33:38FromDiscord<heysokam> would be interesting to see how the llms do against small details in the context of tutorials 🤔
10:33:51FromDiscord<aintea> In reply to @heysokam "simplest example, what if": Well I'm pretty sure ziglings doesn't teach you that
10:34:14FromDiscord<aintea> also the goal is not to enforce using stuff, it's to make the user discover what is possible in Nim, explaining what is better for each situation and let him decide after
10:34:44FromDiscord<heysokam> In reply to @aintea "Well I'm pretty sure": because zig doesn't have such a core concept in the lang. they purposefully design comptime code to be equivalent to runtime code by design
10:34:53FromDiscord<heysokam> but in nim thats a core feature
10:34:57FromDiscord<aintea> I'm not the police, but I'll try to make it so that the user can only do what is asked
10:36:07FromDiscord<heysokam> In reply to @aintea "also the goal is": the problem is that you are considering users new that follow your beaten path↵but what if someone is already experienced and misses your path because they are used to their old ways... and completely misunderstand the purpose of the lang at all
10:36:13FromDiscord<heysokam> happens everytime
10:36:18FromDiscord<heysokam> in this lang
10:37:34FromDiscord<aintea> On one hand I could use the AST but that means the user shall have the exact same code without any possibility for letting him do his own thing (in the limits of what should be done obv)↵On the other hand I can test the functions, have a blackbox thing and only care about the output but like you say it won't stop him from doing stuff that is totally unrelated
10:38:31FromDiscord<heysokam> In reply to @aintea "On one hand I": if you demand exact ast shapes, then yes you are right↵but you could search for specific node combination, and do not touch the rest
10:38:51FromDiscord<aintea> Do you have a simple example for the exercise I gave ?
10:38:55FromDiscord<aintea> I'm curious
10:39:22FromDiscord<heysokam> example of comparing the ast? or example of what exactly?
10:40:28FromDiscord<aintea> example of how you would do this on a given exercise
10:40:31FromDiscord<aintea> on this one for example
10:41:03FromDiscord<aintea> sent a code paste, see https://play.nim-lang.org/#pasty=oUrlRlXv
10:42:28FromDiscord<aintea> sent a code paste, see https://play.nim-lang.org/#pasty=iLyIAWjD
10:42:36FromDiscord<aintea> or explicitely declare the types
10:42:42FromDiscord<aintea> in which case the ast will differ
10:45:21FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=QvpPeKLn
10:46:54FromDiscord<aintea> this will become hardcore if I have to do this on each exercise especially the longer ones
10:46:57FromDiscord<heysokam> as for the `parsing the raw ast`, you can get it with this:↵https://github.com/heysokam/slate/blob/63a156108ba1c7a85083877b197a59ffdf0897e6/src/slate/nimc.nim#L112-L123↵I can give you more examples of each node element if needed, but that's the just of getting it parsed simply
10:47:38FromDiscord<heysokam> In reply to @aintea "this will become hardcore": the more solid solution, of course, would be to create a function that takes 2 ASTs and compares them against each other
10:47:48*beholders_eye quit (Ping timeout: 244 seconds)
10:47:49FromDiscord<heysokam> but in a lenient way
10:47:59FromDiscord<aintea> lenient way ?
10:48:15FromDiscord<heysokam> do not crash if the code is not the exact same, but does the same
10:48:23FromDiscord<aintea> oh
10:48:27FromDiscord<aintea> interesting
10:48:41FromDiscord<heysokam> the user could have whatever they want, but you only search for stuff in your designed ast
10:49:49FromDiscord<heysokam> it would be similar to doing the same thing with macros.. but way way easier to deal with
10:50:19FromDiscord<aintea> I'm not sure to understand this part, what do you mean only searching for stuff in my designed AST
10:52:47FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=QckpGpLJ
10:53:56FromDiscord<heysokam> in this simplified example you would chech that there is a var assigment, with a dontcare name, that gets the value 23, and then is modified to 42
10:54:09FromDiscord<heysokam> (edit) "assigment," => "variable,"
10:54:27FromDiscord<aintea> ooooooooh
10:54:32FromDiscord<aintea> that's smart
13:19:16*xet7 quit (Remote host closed the connection)
13:42:15*xet7 joined #nim
14:50:13*ensyde quit (Ping timeout: 252 seconds)
15:45:26*protium joined #nim
15:50:04*protium quit (Ping timeout: 260 seconds)
16:48:04FromDiscord<root__21> i just got to know about nim can you guys explain me what is this programming language ?
16:48:53FromDiscord<solitudesf> sent a long message, see https://pasty.ee/gCXHmkGE
16:54:07*pmp-p quit (Ping timeout: 244 seconds)
16:57:31FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=IfPcRWdo
16:58:19*pmp-p joined #nim
16:59:42FromDiscord<firasuke> In reply to @root__21 "i just got to": Nim is ADA/Pascal/Modular with a performant "pluggable" GC and friendly pythonic syntax
16:59:43FromDiscord<aintea> sent a long message, see https://pasty.ee/WFVQWfzB
17:00:41FromDiscord<aintea> (edit) "https://pasty.ee/AICDzRPm" => "https://pasty.ee/sbmKsHDY"
17:33:54FromDiscord<__nycto__> Hey all! Just wanted to share that I published a game built using Nim this morning: https://elephantstarballoon.itch.io/the-long-arc↵↵You would need a Playdate console to play, but the game itself is an action arcade game. Players take on the role of an archer defending their tower against waves of enemies, upgrading their arrows, buying spells, and using the Playdate crank as their bow.
17:55:42FromDiscord<solitudesf> In reply to @user2m "is there a compiler": the stack trace should be printed right above the error.
17:56:39FromDiscord<solitudesf> unless you're compiling with -d:release
18:03:33*khazakar quit (Ping timeout: 265 seconds)
18:05:58*bgupta quit (Read error: Connection reset by peer)
18:06:54*bgupta joined #nim
18:08:54*khazakar joined #nim
18:14:34*attah quit (Ping timeout: 245 seconds)
18:17:23FromDiscord<Elegantbeef> @nycto I cannot believe you named the game after the memory management system! 😛
18:17:49FromDiscord<__nycto__> In reply to @Elegantbeef "<@398348508136210434> I cannot believe": Hahahahaha
18:18:00FromDiscord<__nycto__> In reply to @__nycto__ "Hahahahaha": I wish I were that clever
18:18:06FromDiscord<Elegantbeef> Just due to curiosity is there any fungus in this project?
18:18:40*attah joined #nim
18:19:51FromDiscord<__nycto__> There is!
18:20:19FromDiscord<Elegantbeef> "Mom get the camera I made software someone uses!"
18:22:58FromDiscord<__nycto__> It’s one of my “go to” libraries at this point
18:23:42FromDiscord<Elegantbeef> Nice, now to sell you on my shitty messagepack 'clone' 😄
18:24:32FromDiscord<user2m> In reply to @solitudesf "the stack trace should": I am using -d:release
18:25:00FromDiscord<Elegantbeef> `--stackTrace:on` should help
18:29:27FromDiscord<user2m> would --lineTrace:on be better for finding the line where the defect occurs?
18:29:40FromDiscord<Elegantbeef> Enable them both and be merry
18:43:23Amun-Radisable both and be pippin
18:43:55FromDiscord<Elegantbeef> Have them on 3 times in the morning and server with potatoes to be quite Sam
18:44:17Amun-Ra:P
19:21:53*icebattle46 joined #nim
19:23:23*icebattle46 is now known as icebattle
19:27:17FromDiscord<.bobbbob> it seems like multipart/form-data forms broke in prologue with the newest firefox release, still works on chromium and older firefox versions, @ringabout know anything about this? or could my code somehow be wrong? in the ctx.request data the formParams section is just empty, it seems like firefox is sending the same request format as chromium etc, idk
19:29:22*beholders_eye joined #nim
19:54:51*ntat_ joined #nim
19:55:18*ntat quit (Ping timeout: 252 seconds)
19:59:30FromDiscord<ob128> I made a YouTube video of the Nim Tutorial Part I: https://www.youtube.com/watch?v=o0LCV-Y9o-c
20:17:51FromDiscord<thexxiv> In reply to @ob128 "I made a YouTube": https://cdn.discordapp.com/emojis/742347950973255710.gif?v=1
21:10:09*ntat_ quit (Quit: Leaving)
21:22:21FromDiscord<.bobbbob> In reply to @.bobbbob "it seems like multipart/form-data": well regardless I opened an issue with a minimal example
21:33:40FromDiscord<beastarss> why cant you use negative indexes with substring/
21:33:41FromDiscord<beastarss> (edit) "substring/" => "substring?"
21:36:01*icebattle quit (Quit: Client closed)
21:38:39Amun-Rathere is ^num notation fot that
21:38:46Amun-Ra[-1] == [^1]
21:45:08FromDiscord<odexine> In reply to @beastarss "why cant you use": Technically, negative indices can be a real index in the case of an array, so they cannot serve the purpose of being a backwards index
21:49:23FromDiscord<aintea> While making the nimlings I saw you can index an array with anything
21:49:38FromDiscord<aintea> My will to live just decreased by a significant amount
21:50:22*Ekho quit (Quit: CORE ERROR, SYSTEM HALTED.)
21:52:36FromDiscord<fabric.input_output> it's an overloadable operator
21:53:06FromDiscord<fabric.input_output> I only know you can index with enums, ranges and integer types
21:53:18FromDiscord<fabric.input_output> (edit) "enums, ranges" => "enums "
21:53:32FromDiscord<fabric.input_output> ordinal types in general if I remember correctly
22:08:07*Ekho joined #nim
22:09:16FromDiscord<aintea> Sometimes I love Nim but sometimes it looks like it lets you hammer a watch into the ground using a gaming headset because why not
22:38:38FromDiscord<threefour> In reply to @aintea "Sometimes I love Nim": With great power comes great responsibility
22:39:07FromDiscord<threefour> So hammer with your headset responsibly
22:40:18FromDiscord<threefour> Okay I just discovered concepts and I feel like I've discovered magic. Are there other mature languages that have those?
23:38:59*beholders_eye quit (Ping timeout: 265 seconds)