<< 28-07-2023 >>

00:03:03*jmdaemon joined #nim
00:19:53FromDiscord<monark.chan> How can I import a directory of nim files
00:20:21FromDiscord<monark.chan> Like in JavaScript I can loop through the files and require each one
00:20:25FromDiscord<Elegantbeef> There is no mechanism to automate that
00:20:35FromDiscord<Elegantbeef> You can write a macro to do it but nothing built in
00:20:41*xet7 joined #nim
00:21:08FromDiscord<monark.chan> Any examples on what that macro would look like?
00:23:51*jjido joined #nim
00:23:57FromDiscord<demotomohiro> You can write a module that imports modules in a directory and export symbols from imported module.↵https://nim-lang.org/docs/manual.html#modules-export-statement
00:25:21NimEventerNew post on r/nim by Robert_Bobbinson: [noob] Circular dependency hell in Nim, see https://reddit.com/r/nim/comments/15bia07/noob_circular_dependency_hell_in_nim/
00:26:30FromDiscord<demotomohiro> Getting a list of files in macro would fails if compiled with --os:any:↵https://github.com/nim-lang/Nim/issues/19414
00:27:27FromDiscord<egomind> In reply to @monark.chan "Any examples on what": I'm new to Nim, so I don't know for sure, but maybe try getting the files in a directory and then return an import statement for each one?
00:27:55FromDiscord<monark.chan> In reply to @egomind "I'm new to Nim,": Can I use an import statement in a loop?
00:28:01FromDiscord<monark.chan> I don’t believe I can
00:28:12FromDiscord<egomind> The way I understand it, you don't actually important anything in your macro
00:28:19FromDiscord<egomind> you just add import statements to the AST, no?
00:28:50FromDiscord<egomind> Or am I misunderstanding how macros work
00:29:02FromDiscord<monark.chan> Wait what
00:29:15FromDiscord<monark.chan> Idk I’m pretty unfamiliar with macros
00:29:22FromDiscord<egomind> https://nim-lang.org/docs/macros.html
00:29:30FromDiscord<egomind> https://nim-by-example.github.io/macros/
00:29:38FromDiscord<egomind> > Nim’s syntax is incredibly versatile, and macros can be used to rewrite the abstract syntax tree of a program. The general process for writing a macro consists of two steps that are repeated until the desired results are achieved:↵> ↵> Dump and examine the AST↵> Modify the AST to match the desired shape
00:29:58FromDiscord<egomind> The way I understand it, you get the AST and can play around with it
00:30:15FromDiscord<egomind> and the resulting code then gets transpiled to C or JS
00:30:20FromDiscord<egomind> or whatever
00:30:36FromDiscord<michaelb.eth> and/or build an AST, injecting things as it were
00:31:26FromDiscord<egomind> In case you don't know what an AST is: You're basically rewriting your program before transpiling it
00:31:30FromDiscord<michaelb.eth> `quote do:` and backticks help make the process less tedious than if you build all the NimNode instances imperatively, though sometimes you have to do that
00:31:33FromDiscord<egomind> but automatically
00:31:43FromDiscord<Elegantbeef> Technically one could use staticExec↵(@demotomohiro)
00:31:56FromDiscord<Elegantbeef> michael it's 2023 stop suggesting quote do 😛
00:32:07FromDiscord<Elegantbeef> https://nim-lang.org/docs/genasts.html is the cooler kid on the block
00:32:10FromDiscord<michaelb.eth> really? it's not good?
00:32:23FromDiscord<michaelb.eth> ah, okay, yeah I haven't grok'd that yet, thanks for the reminder
00:32:56FromDiscord<Elegantbeef> I mean it's nice if you like manually quoting symbols that you want to inject
00:33:16FromDiscord<demotomohiro> @elegantbeef So, get a list of files in a directory with `ls` or `dir` command?
00:33:28FromDiscord<Elegantbeef> oh it's awful to do, but yes you could
00:33:54FromDiscord<egomind> I would think there's an OS function for this
00:34:14FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/ap1Tm
00:34:20FromDiscord<Elegantbeef> god that's old Nim code of mine
00:35:05FromDiscord<michaelb.eth> In reply to @egomind "I would think there's": maybe, but shelling out can sometimes be more convenient because output of a command in the shell is already fairly easy to parse, e.g. newlines separate things, etc.
00:35:37FromDiscord<Elegantbeef> It's easier to just make nimscript prebuild task that generates your list of `import x` then just `include myfile` inside your program
00:35:43FromDiscord<Elegantbeef> or better yet a `import x; export x` list
00:35:51FromDiscord<Elegantbeef> to avoid include
00:36:32FromDiscord<demotomohiro> I think you can write a `config.nims` file that runs `switch("import", file)` to each files in a directory.
00:37:02FromDiscord<Elegantbeef> Right but that imports globally
00:37:11FromDiscord<Elegantbeef> They want a way to import all files in a directory
00:37:35FromDiscord<Elegantbeef> There is no built in way and assuming it's like my command stuff they are best to just make a single file before they build
00:50:32*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
00:50:50*jmdaemon joined #nim
00:51:19*xet7 quit (Remote host closed the connection)
00:52:08*xet7 joined #nim
00:59:07*jmdaemon quit (Ping timeout: 245 seconds)
01:00:14*lumo_e joined #nim
01:16:02*disso-peach quit (Quit: Leaving)
01:18:56*jmd_ joined #nim
01:31:37*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
01:55:00FromDiscord<monark.chan> How can I use the import command from a macro
01:55:12FromDiscord<monark.chan> I tried calling it as an ident but that doesn't work
01:55:48FromDiscord<Elegantbeef> It'd be `nnkImportStmt`
01:55:59FromDiscord<Elegantbeef> so `nnkImportStmt.newTree(....)`
01:56:18FromDiscord<Elegantbeef> I still wouldnt really suggest using a macro for importing a directory
01:56:29FromDiscord<monark.chan> In reply to @Elegantbeef "so `nnkImportStmt.newTree(....)`": Ok
02:01:37FromDiscord<Andreas> @monark.chan when i started with Nim, i was told that a macro is kind of a 'last resort'. In some cases a template might already solve a problem. In your case a `import/export' without a template or macro will do. And writing correct macros is not trivial - so i'd second beefs advice here..
02:03:28FromDiscord<monark.chan> You would have to manually specify each file in an import/export
02:03:55FromDiscord<monark.chan> That would be no different than just importing everything manually into the main.nim file
02:10:56FromDiscord<Andreas> @ark right, gimme a figure - are you importing dozends or hundrets oy symbols ?
02:11:13FromDiscord<Andreas> (edit) "oy" => "of"
02:16:18*azimut quit (Ping timeout: 240 seconds)
02:19:31FromDiscord<that_dude.> sent a code paste, see https://play.nim-lang.org/#ix=4BFb
02:19:49FromDiscord<that_dude.> You may need to capture it and return it or smth tho
02:31:12*lumo_e quit (Quit: Quit)
02:57:53FromDiscord<BanannaMan> Guys, how do I get better at nim? Im stuck at this weird mental blockage where i understand the problem but I only have a half baked idea of how to solve it. This goes for any language and i feel like I don't know anything despite me learning for a decade. Am I not cut out for programming?
02:58:49FromDiscord<BanannaMan> I seriously don't know what to do anymore
03:00:36FromDiscord<egomind> In reply to @BanannaMan "Guys, how do I": How do you typically approach problems?
03:00:47FromDiscord<egomind> Like, which steps do you take to get to a solution
03:08:30FromDiscord<elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4BFf
03:09:21FromDiscord<elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4BFg
03:09:45FromDiscord<graveflo> sent a long message, see http://ix.io/4BFi
03:09:52FromDiscord<Elegantbeef> `some(@[])` or `none(seq[HandlerAsync])`
03:10:25FromDiscord<egomind> In reply to @graveflo "Everyone has been there": ?
03:11:16FromDiscord<graveflo> In reply to @BanannaMan "Guys, how do I": wrong ping
03:12:31FromDiscord<that_dude.> In reply to @BanannaMan "Guys, how do I": In my experience, you "just gotta do". You are unlikely to ever build a complete plan in your head. Just write a list of requirements, and start grinding away. Don't be afraid of wasted effort. Feel free to keep deleting and changing your mind as needed. Feel free to use git if deleting code you worked on makes your heart ache.
03:12:41FromDiscord<BanannaMan> In reply to @graveflo "Everyone has been there": The problem that I'm having a hard time understanding is determining the number of sides different kinds of triangles have
03:12:53FromDiscord<elamandeep> In reply to @Elegantbeef "`some(@[])` or `none(seq[HandlerAsync])`": I didn't get
03:13:30FromDiscord<egomind> In reply to @BanannaMan "The problem that I'm": 3..?
03:13:33FromDiscord<graveflo> In reply to @BanannaMan "The problem that I'm": that sounds like an interesting problem because it's 3?
03:13:43FromDiscord<elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4BFj
03:14:20FromDiscord<elamandeep> (edit) "https://play.nim-lang.org/#ix=4BFj" => "https://play.nim-lang.org/#ix=4BFk"
03:14:30FromDiscord<that_dude.> In reply to @elamandeep "I didn't get": https://nim-lang.org/docs/options.html↵Basically you wrap the value in an object that can either represent a value or the lack of one
03:14:37FromDiscord<elamandeep> (edit) "https://play.nim-lang.org/#ix=4BFk" => "https://play.nim-lang.org/#ix=4BFl"
03:14:46FromDiscord<Elegantbeef> Look at the error
03:14:49FromDiscord<that_dude.> It's kind a simmilar to how a pointer can point to nil or the object itself
03:14:53FromDiscord<that_dude.> (edit) "simmilar" => "similar"
03:15:01FromDiscord<Elegantbeef> > required type for middlewares\: Option[seq[HandlerAsync]]↵> 'middlewares = @[CorsMiddleware(@["\"], re"", @["GET"], @[], @[], false, 7200,↵> @[])]' is of type\: seq[HandlerAsync]
03:15:43FromDiscord<BanannaMan> In reply to @graveflo "that sounds like an": It's this problem in particular:↵https://www exercism.org/tracks/nim/exercises/triangle
03:15:52FromDiscord<BanannaMan> (edit) "particular:↵https://www exercism.org/tracks/nim/exercises/triangle" => "particular:↵https://www.exercism.org/tracks/nim/exercises/triangle"
03:16:42FromDiscord<that_dude.> So what's the hard part?
03:16:52FromDiscord<elamandeep> In reply to @elamandeep "from what I got": @that_dude. i need to put cors on every route?
03:18:01FromDiscord<that_dude.> sent a code paste, see https://play.nim-lang.org/#ix=4BFm
03:18:11FromDiscord<graveflo> In reply to @BanannaMan "It's this problem in": ok so for this one what you want to do is just focus on one thing at a time. Have you taken algebra class in school? You want to define your given information and then define each step one at a time until the problem is solved. You essentially just need to define what was said in the post. Don't try and do it all at once
03:18:17FromDiscord<that_dude.> I haven't used prologue so idk tbh
03:18:54FromDiscord<BanannaMan> In reply to @graveflo "ok so for this": What do you mean?
03:19:37FromDiscord<BanannaMan> You mean in terms of procedural programming?
03:20:59FromDiscord<graveflo> In reply to @BanannaMan "What do you mean?": since this problem is dealing with triangles, and their sides defined as `a`, `b` and `c` first you will want tot define those variables. Then you want to make sure they are a triangle (the post explained a simple check for this). Next you want to translate the logic that they had specified about each type of triangle into code. Since there can be several discrete choices you will probably w
03:21:28FromDiscord<BanannaMan> In reply to @graveflo "since this problem is": I tried using a switch case flow but it didn't work
03:21:39FromDiscord<BanannaMan> That's what I immediately thought
03:21:48FromDiscord<graveflo> then try `if`
03:22:03FromDiscord<that_dude.> If it's a triangle, that's a small enough number of sides where you can hardcode your tests/checks
03:22:03FromDiscord<BanannaMan> But I dunno. Maybe I didn't do it right.
03:22:56FromDiscord<graveflo> one other thing I'll say is wrap this into a `proc` if you have not already. It might help you reason if `a`, `b` and `c` are parameters to a function
03:23:49FromDiscord<BanannaMan> A, b and c are an array
03:24:03FromDiscord<that_dude.> sent a code paste, see https://play.nim-lang.org/#ix=4BFn
03:24:06FromDiscord<BanannaMan> Yep
03:24:23FromDiscord<BanannaMan> I dunno man.
03:24:43FromDiscord<that_dude.> Well just do the first one
03:24:53FromDiscord<that_dude.> What is it asking for?
03:25:07FromDiscord<BanannaMan> Maybe it's because I have a rudimentary amount of knowledge on how to write operands and use control flows properly
03:26:18FromDiscord<BanannaMan> How do I continuously practice the basics?
03:26:43FromDiscord<BanannaMan> Just go over everything in the nim tutorials?
03:26:56FromDiscord<BanannaMan> Maybe I should just do that
03:27:04FromDiscord<that_dude.> How much general programming experince do you have?
03:28:46FromDiscord<BanannaMan> In reply to @that_dude. "How much general programming": I spent a decade learning how to read and write C, C++, VB.Net, etc but I never mastered any of them. I know what a program does by looking at every component of it but I can't write my own projects.
03:29:00FromDiscord<BanannaMan> I guess it's because I didn't try hard enough or I just suck
03:29:31FromDiscord<that_dude.> I guess you have to turn on the creative part of your brain more
03:30:02FromDiscord<that_dude.> Generally your knowledge of other languages should carry over to this one as well.
03:30:11FromDiscord<BanannaMan> In reply to @that_dude. "I guess you have": That's a other issue. I have tons of wonderful ideas, but I don't have the expertise to make it happen
03:30:12FromDiscord<graveflo> Can you post what your current solution is to the triangle problem? I am curious. It will also help understand your thought process so maybe we can give a pointer or two
03:31:04FromDiscord<BanannaMan> In reply to @graveflo "Can you post what": https://media.discordapp.net/attachments/371759389889003532/1134327133708243055/20230727_233054.jpg
03:31:20FromDiscord<that_dude.> You can take a look into any of these https://nim-lang.org/documentation.html if you don't know what is possible in this lang yet
03:31:57FromDiscord<graveflo> alright the first is a misunderstanding of how the case statement works as well as `or`
03:31:58FromDiscord<BanannaMan> (edit) "a other" => "another"
03:33:04FromDiscord<that_dude.> So it looks like the spacing/indentation is wrong. Because Nim is white space significant, isEquilateral will always use return false due to an implicit false. The case part does get run, but not in the proc
03:33:05FromDiscord<graveflo> this is mostly just syntax, but I'll tell you that your woes will go away if you track the meaning and mechanics of these directives down to their source. You will be uncomfortable with any language if you don't understand it's fundamentals
03:33:29FromDiscord<that_dude.> (edit) "So it looks like ... the" added "one issue is that"
03:34:05FromDiscord<that_dude.> Also why are you trying to test if any of the numbers is a 3?
03:34:25FromDiscord<that_dude.> Aren't `a, b, c` the lengths of each side of a triangle?
03:34:51FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4BFp
03:34:58FromDiscord<that_dude.> Don't we have a bot in here that can run things?
03:36:51FromDiscord<graveflo> In a language like Nim, we may not immediately know what `or` means in the context of two integer values. One of the things it could do is conver the integers to bools and then do a logical or on them. It could also just do a bitwise or on them: https://en.wikipedia.org/wiki/Bitwise_operation#OR
03:39:07FromDiscord<graveflo> and when you are doing more than one conditional you should not need to say `case sides` because that is not relevant to the conditions. when you say `case sides` you are testing the values of `sides` against the value of each of the cases. You want to use `if` here instead and don't test `sides` instead test `a` `b` and `c`
03:39:27FromDiscord<graveflo> (edit) "values" => "value"
03:41:29FromDiscord<BanannaMan> Okay
03:41:32FromDiscord<BanannaMan> Thanks
03:43:03FromDiscord<graveflo> I think your indentation my be messed up too. Basically, you will not be so frustrated if you get pedantic about syntax and what everything "does". Once you understand that well then you won't get confused. You seem to understand the idea of what to do, you just don't know the language well enough to translate
03:46:47FromDiscord<BanannaMan> In reply to @graveflo "I think your indentation": Exactly
03:46:57FromDiscord<BanannaMan> And that goes for every language I know
03:47:12FromDiscord<BanannaMan> And I'm mad at myself for it because I don't know how to get better
03:48:11FromDiscord<that_dude.> If you don't have nim installed localy, you can just use this for testing. https://play.nim-lang.org/
03:48:30FromDiscord<BanannaMan> I have it installed already
03:48:38FromDiscord<graveflo> I'm tell you, if this is a re-occuring problem then you are not diving deep enough into fundamentals. You really need to understand the logical rules or each language directive instead of just having a "feel" for how they work. Think like a computer sometimes
03:48:40FromDiscord<that_dude.> Can you make a hello world program from scratch?
03:49:30FromDiscord<that_dude.> I'm kinda struggling to on what angle of help ya need
03:49:34FromDiscord<that_dude.> (edit) "need" => "need, ya know"
03:49:34FromDiscord<BanannaMan> In reply to @graveflo "I'm tell you, if": You're right. I'll spend time to learn more about the fundamentals and build small programs to demonstrate my understanding
03:49:59FromDiscord<that_dude.> I think you should try to build the fibinocci functions
03:50:34FromDiscord<that_dude.> both recursive and not.
03:50:53FromDiscord<that_dude.> (edit) "fibinocci" => "fibonacci"
03:51:26FromDiscord<BanannaMan> In reply to @that_dude. "I think you should": Stahp
04:15:39*cornfeedhobo joined #nim
04:48:43FromDiscord<Phil> 😦 ↵No `find` proc in sequtils.↵Not a big deal, you can easily write your own in like 10 lines or so, but still bummer
04:54:26FromDiscord<Elegantbeef> `find` is in system
04:54:26FromDiscord<that_dude.> I've had a simmilar situation where I expected smth like a dist proc
04:55:02FromDiscord<that_dude.> Is there a reason that system things don't show up in the index?
04:55:02FromDiscord<Phil> 👀
04:55:23FromDiscord<Elegantbeef> They do
04:55:34FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1134348400314290186/image.png
04:55:45FromDiscord<that_dude.> https://media.discordapp.net/attachments/371759389889003532/1134348444996206703/image.png
04:55:58FromDiscord<that_dude.> Fair
04:56:07FromDiscord<Elegantbeef> > Returns the first index of item in a or -1 if not found. This requires appropriate items and == operations to work.
04:56:43FromDiscord<that_dude.> Another question I've had, how come concepts aren't used more for things like this
04:56:53FromDiscord<that_dude.> Would it make things more confusing?
04:56:57FromDiscord<Phil> More in a FP sense, I'd want the first item for which a condition is true, should return Optional basically
04:57:04FromDiscord<Elegantbeef> Concepts are experimental is the only thing I can say
04:57:20FromDiscord<Phil> Or an index with a sentinel value if no entry in the list fulfills the condition, I'll take either
04:57:55FromDiscord<that_dude.> So like -1 that it returns?
04:58:28FromDiscord<Phil> If no value matches, yeah, it's one of the options.↵Optional of the actual value would be preferrable
04:58:43FromDiscord<Phil> Looking through the functional programming libs and I'm surprised that I'm not finding anything either
04:59:39FromDiscord<Phil> zero-functional seems to have one that returns index, but no docs on it
05:03:24FromDiscord<Phil> Ohhh nimfp also has it, it's just somewhat buried
05:04:13FromDiscord<Phil> But nimfp appears to make a giant linked list and that seems slow as hell
05:04:31FromDiscord<Phil> (edit) "make" => "first demand that seqs etc. must be" | removed "giant"
05:10:38FromDiscord<odexine> In reply to @isofruit "But nimfp appears to": not really? i mean test your hypotheses
05:27:09FromDiscord<Phil> Compared to arrays which cache much more nicely?↵I'm not willing to burn the 5 minutes to do that testing when I can't even see a conceptual reason why linked lists wouldn't be slow (compared to arrays) for what they're doing.
05:27:33FromDiscord<elamandeep> how to make post request in prologue?
05:28:09FromDiscord<Phil> As in make the prologue server itself send an http request?↵Or have prologue receive a POST request?
05:29:09FromDiscord<elamandeep> In reply to @isofruit "As in make the": recieve post request
05:32:46FromDiscord<Phil> In reply to @elamandeep "recieve post request": https://planety.github.io/prologue/routing/↵https://planety.github.io/prologue/coreapi/application.html#addRoute%2CPrologue%2Cstring%2CHandlerAsync%2CopenArray%5BHttpMethod%5D%2Cstring%2CopenArray%5BHandlerAsync%5D↵↵Take a look at the addRoute procs (there are multiple variants depending on how you want your route to look like), basically just add a route-handler using addRoute that use
05:44:56FromDiscord<elamandeep> In reply to @isofruit "https://planety.github.io/prologue/routing/ https:/": I'm really I'm not getting how to use it.
05:45:09FromDiscord<elamandeep> (edit) "I'm really" => "Really"
05:46:33FromDiscord<elamandeep> they don't have something like decorator
05:47:00FromDiscord<elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4BFO
05:47:09FromDiscord<elamandeep> (edit)
05:48:06FromDiscord<odexine> Nim does not have Python-style decorators, only something similar
05:48:18FromDiscord<odexine> But I assume they’re not used equivalently in prologue either
05:56:10FromDiscord<Phil> sent a long message, see http://ix.io/4BFQ
05:56:48FromDiscord<Phil> (edit) "http://ix.io/4BFQ" => "http://ix.io/4BFR"
05:59:52FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BFS
06:29:03*kenran joined #nim
06:39:45FromDiscord<egomind> Could you technically make decorators a thing in Nim? :ArcueidCurious:
06:40:26FromDiscord<egomind> Or is the @ just a reserved symbol that can't be used in macros
06:40:42FromDiscord<egomind> Ahhh, I wanna play around with the language
06:41:27FromDiscord<odexine> In reply to @egomind "Or is the @": It’s not reserved
06:41:30*rockcavera quit (Remote host closed the connection)
06:41:42FromDiscord<odexine> But syntax wouldn’t allow the macro to capture the function below
06:41:45FromDiscord<Phil> In reply to @egomind "Could you technically make": You could, you could also use pragmas I think for compile-time known data
06:41:55FromDiscord<egomind> In reply to @odexine "But syntax wouldn’t allow": Not even with indentation?
06:42:03FromDiscord<odexine> In reply to @egomind "Not even with indentation?": With indentation yes
06:42:07FromDiscord<odexine> You can
06:42:11FromDiscord<egomind> I see
06:42:48FromDiscord<odexine> I guess it might collide with sequence proc @
06:42:55FromDiscord<odexine> Not sure how that would work but eh
06:43:00FromDiscord<Phil> But honestly I prefer not having to deal with decorator magic
06:43:17FromDiscord<Elegantbeef> Best just to use a different operator if one really wanted
06:43:47FromDiscord<egomind> Oh, yeah, I'd just do it for fun
06:43:55FromDiscord<egomind> I don't really like decorators most of the time
06:44:23FromDiscord<odexine> I’d say they’re fine
06:44:52FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/4u3Cw
06:45:22FromDiscord<Phil> Yeah, context stuff I think could be an okay way of expressing things
06:46:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BG0
06:46:43FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4BG0" => "https://play.nim-lang.org/#ix=4BG1"
06:48:33FromDiscord<Phil> And basically just have that mask generating an anonymous proc that you attach to `app` via an `addRoute` proc call.
06:49:20FromDiscord<Phil> (edit) "call." => "call for which you use the parameters passed to `HttpController`."
06:50:19FromDiscord<Phil> But still meh imo since it just hides some stuff
06:54:40FromDiscord<Phil> Funnily enough the mapping-proc-generator thing I started playing around with for a couple hours I originally tried to reimplement using pragmas for mapping annotations before thinking better of it and just writing a `Mapping` type that the mapping proc generator accepts
06:55:02FromDiscord<Phil> (edit) "Funnily enough the mapping-proc-generator thing I started playing around with for a couple hours I originally tried to reimplement using pragmas for mapping annotations before thinking better of it and just writing a `Mapping` type that the mapping proc generator accepts ... " added "directly.↵↵No dealing with pragmas involved because it's not necessary to make it that complicated"
06:55:10FromDiscord<Phil> (edit) "Funnily enough the mapping-proc-generator thing I started playing around with for a couple hours I originally tried to reimplement using pragmas for mapping annotations before thinking better of it and just writing a `Mapping` type that the mapping proc generator accepts directly.↵↵No dealing with pragmas ... involved" added "or annotations"
07:13:42*ntat joined #nim
09:02:35*ntat quit (Quit: leaving)
09:19:54*disso-peach joined #nim
09:24:12FromDiscord<mesosan> hello
09:25:35FromDiscord<mesosan> sent a code paste, see https://play.nim-lang.org/#ix=4BGv
09:25:41*junaid_ joined #nim
09:25:51FromDiscord<mesosan> like i know that nim can compile to js
09:26:09FromDiscord<mesosan> but can we use prewritten js modules in nim?
09:26:26FromDiscord<mesosan> cus otherwise writing everything for nim doesn't seem ideal
09:26:45FromDiscord<mesosan> also if yes, then say i compile this code to cpp, now would that be possible?
09:27:04FromDiscord<mesosan> since i am using a js module import in nim code and compiling to cpp
09:31:15FromDiscord<odexine> it kinda makes no sense that it would work in C++
09:31:24FromDiscord<odexine> In reply to @mesosan "guys does nim support": but yes its possible iirc
09:31:33FromDiscord<odexine> just use {.emit: "js code here".}
09:32:28FromDiscord<mesosan> In reply to @odexine "but yes its possible": damn
09:32:47FromDiscord<odexine> it needs a bit of setup but its possible
09:32:48FromDiscord<mesosan> so me calling a js function in nim that was imported from a js module was legal?
09:32:51FromDiscord<mesosan> wow
09:33:06FromDiscord<odexine> yeah you can call js implemented functions in nim
09:33:35FromDiscord<odexine> you just need to uh tell nim what the signature is via importc, theres a lot more details to this
09:33:36FromDiscord<mesosan> does nim have a ast transformer to nim and from nim for every lang
09:33:41FromDiscord<odexine> noi
09:33:41FromDiscord<mesosan> cus this is some mindblwoing stuff
09:33:48FromDiscord<mesosan> how does it do js to cpp then
09:33:55FromDiscord<odexine> wdym?
09:33:59FromDiscord<odexine> if you import js you must compile to js
09:34:04FromDiscord<mesosan> oh
09:34:18FromDiscord<mesosan> In reply to @odexine "it kinda makes no": i mean it may not working in js
09:34:22FromDiscord<mesosan> (edit) "js" => "cpp"
09:34:26FromDiscord<mesosan> but can i compile to cpp
09:34:38FromDiscord<odexine> i dont understand
09:34:54FromDiscord<odexine> you want to put javascript code into your nim code but then compile to c++?
09:35:06FromDiscord<mesosan> yes, maybe not imported javascript code
09:35:11FromDiscord<mesosan> explicitly written one if that helps
09:35:27FromDiscord<odexine> i dont really understand, do you just want to store the code as a string or something?
09:38:21FromDiscord<mesosan> sent a code paste, see https://play.nim-lang.org/#ix=4BGy
09:38:32FromDiscord<mesosan> (edit) "https://play.nim-lang.org/#ix=4BGy" => "https://play.nim-lang.org/#ix=4BGz"
09:38:32FromDiscord<mesosan> so can i compile this to cpp?
09:38:41FromDiscord<mesosan> like i haven't imported any external js
09:38:55FromDiscord<mesosan> and the js used is not depending on any special js runtime features
09:39:06FromDiscord<mesosan> (edit) "features" => "features/environment"
09:39:13FromDiscord<mesosan> so i am hoping that this can compile to cpp
09:39:27FromDiscord<mesosan> (edit) "https://play.nim-lang.org/#ix=4BGz" => "https://play.nim-lang.org/#ix=4BGA"
09:40:35FromDiscord<odexine> no
09:40:47FromDiscord<odexine> js code will not work in c++
09:40:55FromDiscord<odexine> nim makes no effort to translate anything like that
09:41:29FromDiscord<mesosan> okay
09:41:39FromDiscord<mesosan> do you any langs that allow this kind of thing
09:41:43*junaid_ quit (Remote host closed the connection)
09:41:52FromDiscord<mesosan> like they allow embeding other langs in their synyax
09:42:00FromDiscord<mesosan> and then transpile to diff langs
09:42:05FromDiscord<mesosan> (edit) "synyax" => "syntax"
09:42:11FromDiscord<mesosan> even if very limited in scop
09:42:13FromDiscord<mesosan> (edit) "scop" => "scope"
09:45:13FromDiscord<mesosan> In reply to @odexine "just use {.emit: "js": okk so this would just emit the code in {.emit} directly right?
09:45:26FromDiscord<mesosan> cus now that target lang is fixed there is no real transpiling involved
09:45:35FromDiscord<mesosan> except for the nim syntax
09:46:01FromDiscord<odexine> In reply to @mesosan "do you know any": no
09:46:07FromDiscord<odexine> because that's a herculean effort
09:47:15FromDiscord<mesosan> truly
09:47:45FromDiscord<mesosan> i think what could make it simpler would be writing ast transformers to and from the lang
09:48:01FromDiscord<mesosan> like nim to cpp already exists
09:48:16FromDiscord<mesosan> but if cpp to nim existed (even if with limited support)
09:48:26FromDiscord<mesosan> then nim to js could be performed by chaining
09:48:33FromDiscord<mesosan> so cpp to js would be possible
09:48:41FromDiscord<mesosan> like to and from for each lang with the arbitrary lang
09:49:00FromDiscord<mesosan> would that work? or am i just too new to this stuff to see what will fail
09:50:56FromDiscord<graveflo> It would "work" but it would be weird and there would have to be 0 non-agnostic code. The issues would be in nim compiler internal features like the pragmas. It's just not very feasible. Not worth the effort either
09:52:53FromDiscord<mesosan> In reply to @graveflo "It would "work" but": true, i think it can be feasiable in very small scoped enviornments like say simple scripting langs like bash and batch
09:52:57FromDiscord<mesosan> maybe not with a lang like nim
09:53:00FromDiscord<mesosan> maybe something simpler
09:53:20FromDiscord<graveflo> also C and C++ syntax is pretty complicated I think. It would be no small task to implement a lexer for that
09:53:40FromDiscord<mesosan> yeah, makes sense :((
09:53:56FromDiscord<mesosan> what do you think about the bash/bat thing i said above
09:54:08FromDiscord<mesosan> actually i wanna make my compiler course project this
09:54:14FromDiscord<mesosan> with bash and batch as the target langs
09:54:24FromDiscord<mesosan> that's why polling what's feasiable and what not
09:55:39FromDiscord<graveflo> can you reply to it?
09:55:43FromDiscord<graveflo> so i can see
09:58:53FromDiscord<graveflo> also look at futhark if you want an example if a macro that reads C syntax and emits Nim code. It's not what you are trying to do but at least it's relatable
09:59:07FromDiscord<graveflo> (edit) "if a macro" => "of macros"
10:01:10FromDiscord<mesosan> In reply to @graveflo "can you reply to": oh one sec
10:01:19FromDiscord<mesosan> In reply to @mesosan "true, i think it": this one
10:03:35FromDiscord<mesosan> sent a code paste, see https://play.nim-lang.org/#ix=4BGI
10:03:48FromDiscord<mesosan> (edit)
10:04:03FromDiscord<mesosan> so it is a lang that allows bash and batch embedding and compiles to bash and batch
10:04:29FromDiscord<mesosan> so my plan is to write ast transformer from this lang and to this lang from both bash and batch
10:05:27FromDiscord<mesosan> unfortunately this does mean that you can only use those features of bash in this if compiling to batch that exist in the new lang
10:05:48FromDiscord<mesosan> since it is gonna act as the middleware
10:08:38FromDiscord<graveflo> alright, well. That isn't impossible but I suppose that means you'll be implementing bash functions in Nim. At that point one could also just use Nim to call the bash functions. As far as Nim "as is" is concerned the meta-programming does not let you step out of the bounds of the syntax spec, so youll have to wrap direct bash embeds in strings unless you add a new level of meta programming to Nim. It's actually not hard to make a `proc`
10:09:27FromDiscord<graveflo> I'm not sure if the bash back end to Nim will work out just from a coverage standpoint but I'm not going to say impossible
10:11:11*ntat joined #nim
10:12:22*ntat quit (Remote host closed the connection)
10:12:49*ntat joined #nim
10:16:55FromDiscord<mesosan> In reply to @graveflo "alright, well. That isn't": that meks sense
10:17:00FromDiscord<mesosan> (edit) "meks" => "makes"
10:17:12FromDiscord<mesosan> ok considering nim to not be the middleware language
10:17:29FromDiscord<mesosan> let's say it's some arbitrary new lang made for just this purpose
10:18:31FromDiscord<mesosan> it's definitely not ideal to sue the new lang as the middleware tbh
10:18:59FromDiscord<mesosan> cus then what is even the point of having the option to write bash
10:19:02FromDiscord<mesosan> (edit) "bash" => "bash/batch"
10:19:32FromDiscord<mesosan> since you're limited by the functionality of the new lang
10:21:08FromDiscord<graveflo> its fine to use Nim as the middleware. I was just letting you know some limitations. I can't help you much otherwise since this is your idea. I would just write Nim funcs that do what I want and then use Nim instead of bash / other lang 😅
10:22:58FromDiscord<mesosan> that makes sense
10:23:04FromDiscord<mesosan> thanks for your time!
10:24:48*ntat quit (Quit: leaving)
10:58:44FromDiscord<gogolxdong666> Is waitForAll is still there or any replacement?
11:02:28FromDiscord<gogolxdong666> in another word is how to wait multiple Future
11:28:00*grom358 joined #nim
11:45:35FromDiscord<elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4BH7
11:46:17FromDiscord<elamandeep> unable to connect database
12:08:30*grom358 quit (Quit: Client closed)
12:10:22NimEventerNew post on r/nim by qtless: Big Components Update, see https://reddit.com/r/nim/comments/15bvotx/big_components_update/
12:21:37*jjido joined #nim
12:27:56*cyraxjoe quit (Ping timeout: 244 seconds)
12:34:42*kenran quit (Remote host closed the connection)
12:41:12*jmd_ quit (Ping timeout: 246 seconds)
13:02:26FromDiscord<Dale Y Pearlman> Do you know that you can earn $5,000 or more weekly from crypto Trading? With Just $500… 100% Inbox Admin on Telegram for more details 👇👇👇👇👇👇 https://t.me/PROFITSWITHSTEVE
13:18:21*azimut joined #nim
13:35:53*lucasta joined #nim
13:37:06*lucasta quit (Remote host closed the connection)
13:37:31*lucasta joined #nim
13:43:51*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
14:06:14*rockcavera joined #nim
14:36:45om3ga/qiot
14:41:15FromDiscord<odexine> whoops misspelled quit
14:41:17FromDiscord<odexine> 😛
14:41:23FromDiscord<odexine> (edit) "whoops ... misspelled" added "ya"
16:44:07*ntat joined #nim
16:50:00*lucasta quit (Quit: Leaving)
17:01:45*ntat quit (Quit: leaving)
17:02:18*ntat joined #nim
17:04:53*xet7 quit (Read error: Connection reset by peer)
17:09:00*jmdaemon joined #nim
17:37:05*jjido joined #nim
17:45:41*jjido quit (Ping timeout: 260 seconds)
17:51:01*ntat quit (Quit: leaving)
18:28:15*xet7 joined #nim
19:12:40NimEventerNew Nimble package! chatgptclient - Native gui client for OpenAI chatgpt, see https://github.com/jaredmontoya/chatgptclient
19:26:42*ntat joined #nim
19:54:28FromDiscord<Phil> Okay, time to head into battle.↵Somehow I want to turn `x, "y.z"` into `x.y.z` but basically the static string can be unknown levels deep.
19:54:41FromDiscord<Phil> (edit) "battle.↵Somehow" => "battle and expand the final piece of functionality to my mapping thing.↵Somehow"
19:55:31FromDiscord<Phil> I think first guess would be to turn "y.z" into a static seq and statically iterate over that seq (?)
19:55:55FromDiscord<Phil> (edit) "(?)" => "to do individual field fetches(?)"
20:04:49FromDiscord<Phil> Oh god do I need to solve this with a recursive macro?
20:25:39FromDiscord<Elegantbeef> Depends @Phil how complex will the string be?
20:25:52FromDiscord<Elegantbeef> it wont be like `x[0].y.z[3].w[a]`?
20:26:10FromDiscord<Phil> only ever "x.y.z", no index access
20:26:30FromDiscord<Phil> And I think also no map access, I think with what I recall from macros I'm getting somewhere
20:26:46FromDiscord<Phil> Since I think I can just loop over the elements and create a dot expression with a dot expression etc.
20:27:57FromDiscord<Phil> Macros can return the final expression in the shape of a NimNode that they want to generate, right?
20:29:03FromDiscord<Elegantbeef> Also insert an error
20:29:04FromDiscord<Elegantbeef> `result = a` whoops
20:29:10FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/0BJTs
20:29:42FromDiscord<Phil> Ah dang, you were faster
20:29:43FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BIW
20:30:08FromDiscord<Phil> And further ahead, hadn't done the transformation of static string to static seq yet
20:30:23FromDiscord<Elegantbeef> I'm just better 😛
20:30:42FromDiscord<Phil> Given that this is literally the first macro I wrote on my lonesome I'm pretty proud on how quickly I managed to throw that together
20:32:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BIY
20:32:55FromDiscord<Elegantbeef> I did say it's `result = a`
20:33:40FromDiscord<Phil> Okay yeah that did the thing
20:36:21*Guest__ joined #nim
20:47:27FromDiscord<Phil> ... is there a way to only have to define an object variant generic over a single field and treating the object variant as generic is only required when it is of that particular kind?↵... I know the answer is no but still
20:47:41FromDiscord<Phil> (edit) "kind?↵..." => "kind that has the generic field?↵..."
20:48:35*ntat quit (Quit: leaving)
20:52:10FromDiscord<huantian> that's a lotta words
20:54:22*ntat joined #nim
20:55:52FromDiscord<Elegantbeef> @Phil I assume you just want all the none generic delimited branches implicitly converted to another type?
20:56:49FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/WFo2U
20:56:53FromDiscord<Phil> Found a different way to do the thing, I'm good.↵It was that I wanted to store constant values of unknown types in a seq of the same object variant.↵But I solve it the same way I do it elsewhere now, by just using function pointers
20:57:11FromDiscord<Phil> Though now I need to figure out how to access the pointer to an anonymous function
20:57:14FromDiscord<Phil> (edit) "function" => "proc"
20:57:36FromDiscord<Elegantbeef> The anonymous proc is a pointer
20:57:56FromDiscord<Elegantbeef> Unless it's a closure
20:58:00FromDiscord<Elegantbeef> Then it's an `(env, proc)`
20:58:02FromDiscord<Phil> It is a closure
20:58:28FromDiscord<Elegantbeef> `rawProc`
20:58:33FromDiscord<Elegantbeef> `rawEnv`
20:59:21FromDiscord<Elegantbeef> Alternatively if possible only use nimcall and make your life easier
21:00:36FromDiscord<Phil> I mean, I'm essentially trying to turn a value into a proc that returns the value, closure seems like the only choice here
21:01:21FromDiscord<Elegantbeef> You're thunking
21:01:35FromDiscord<Elegantbeef> Depending on what you're doing that could be derived from the arguments of a procedure
21:02:08FromDiscord<Phil> One sec
21:03:37FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BJa
21:04:15FromDiscord<Phil> Later I'm casting pointer to a proc-type that I'm inferring it must be to map an inferred type A to an inferred type B, that is the operation that seems to fail here.
21:06:32*tiorock joined #nim
21:06:32*rockcavera is now known as Guest1370
21:06:32*Guest1370 quit (Killed (cadmium.libera.chat (Nickname regained by services)))
21:06:33*tiorock is now known as rockcavera
21:09:10FromDiscord<Phil> Essentially I don't really want the type, I'll infer it later which will blow up if the user throws in something invalid
21:20:10*ntat quit (Quit: leaving)
21:25:54*Guest__ quit (Remote host closed the connection)
21:32:10FromDiscord<Elegantbeef> You're doing type erasure so yea
21:33:18*Guest_ joined #nim
21:34:50FromDiscord<Phil> That's pretty much what I want to do, "Screw you type, I know what you will be later"
21:35:00FromDiscord<Elegantbeef> `pointer`
21:35:04*Guest_ is now known as ajunior
21:35:47FromDiscord<Phil> Yeah but how do I get the closure into a pointer without it blowing up in my face?↵I have to carry the environment around as well, right?
21:35:58FromDiscord<Elegantbeef> correct
21:36:16FromDiscord<Elegantbeef> Though I do have to ask what's the point in the closure?
21:36:24FromDiscord<Elegantbeef> You arent even thunking it properly
21:36:34FromDiscord<Phil> I dunno what you mean by thunking
21:36:44FromDiscord<Elegantbeef> At this point you should just use `ref T`
21:37:00FromDiscord<Elegantbeef> Thunking is a process of delaying a instantiation but using a procedure
21:37:05FromDiscord<Phil> But generally:↵I'm writing a proc that generates mapping procs, that transform type A to B
21:37:08FromDiscord<Elegantbeef> so instead of taking `T` you take `proc(): T`
21:37:48FromDiscord<Phil> For any fields for which I can't say "Oh, same name on both types and they both have the same type? just transfer the value over" I demand the user give me so called "Mapping" objects that define stuff
21:38:13FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4BJt
21:38:56FromDiscord<Phil> Like maybe one type has a field `name` and the other has `otherName`, they give me the MappingObject that expresses that contains both names and when generating the proc I transfer the value from `otherName` on type A to field `name` on type B
21:38:58FromDiscord<Elegantbeef> If you're making procs that convert between types why isnt there a parameter?
21:39:50FromDiscord<Elegantbeef> I do not get why this is done dynamically, but yea I do not get how this is converting anything
21:40:16FromDiscord<Phil> You might just want to define that a field on type B gets fed with a constant value instead of a value from type A
21:40:19FromDiscord<Phil> That's what I'm adding
21:40:49FromDiscord<Phil> So I need to store that constant value somewhere.↵If I store it in the `Mapping` object, I need to deal with `Mapping` suddenly becoming a generic object which is a PITA
21:41:51FromDiscord<Phil> The alternative I could think of was turning it into a proc, storing the pointer and cast the pointer into `proc(): <The Type of the Field where this mapping gets applied to>` later on then execute it
21:42:29FromDiscord<Elegantbeef> I'm a bit stupid cause I'm wondering why this isnt just `proc convertTo(a: MyType, dest: typedesc[Target]): Target`
21:43:11FromDiscord<Phil> Because it's a lib to generate mapping procs↵`proc generateMapper[SOURCETYPE, TARGETTYPE](x: typedesc[SOURCETYPE], y: typedesc[TARGETTYPE], mappings: static seq[Mapping]): MapProc[SOURCETYPE, TARGETTYPE] =`
21:44:08FromDiscord<Elegantbeef> This is in a whole different postal code from me, so I'll just shush
21:49:06FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4BJv
21:49:15FromDiscord<Chronos [She/Her]> (edit) "https://play.nim-lang.org/#ix=4BJv" => "https://play.nim-lang.org/#ix=4BJw"
21:50:53FromDiscord<Elegantbeef> No you shouldnt cause that's not Nim
21:51:50FromDiscord<Elegantbeef> Given that there's not much reason to have your smaller integers use a smaller sized integer there is no reason not to do `of IntLiterals: intVal: int`
21:51:52FromDiscord<Chronos [She/Her]> I can't remember the exact syntax rn but something like that
21:52:04FromDiscord<System64 ~ Flandre Scarlet> https://github.com/vanyle/NimPlus↵Is it nice?
21:52:39FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Given that there's not": Fair and makes sense
22:01:41FromDiscord<Elegantbeef> You also get to define what happens for overflow
22:08:16FromDiscord<Chronos [She/Her]> Unless it's int64
22:08:28FromDiscord<Chronos [She/Her]> Well, still can but with manual checks and stuff
22:08:43FromDiscord<Chronos [She/Her]> Preventing it from ever going beyond it's max value
22:08:50FromDiscord<Chronos [She/Her]> Idk what I'm saying I am sleep deprived
22:26:08*xet7 quit (Remote host closed the connection)