00:27:08 | * | jmdaemon quit (Ping timeout: 252 seconds) |
00:44:17 | * | vicfred quit (Quit: Leaving) |
01:01:39 | * | krux02 quit (Remote host closed the connection) |
01:10:57 | * | m5zs7k quit (Ping timeout: 256 seconds) |
01:18:11 | * | jmdaemon joined #nim |
01:27:25 | * | jmdaemon quit (Ping timeout: 240 seconds) |
01:28:40 | FromDiscord | <Arathanis> @ElegantBeef thanks for pointing me in that direction, its helped a lot. If you have some time tonight ( and I find the time) i was wondering if you could walk me through some of the finer points of how all this fits together.↵↵Also I don't know if you saw my previous message, but I believe you need to add `netty` as a requirement in nettyrpc's deps! |
01:28:51 | FromDiscord | <Evrensel Kişilik> sooooooooo |
01:29:11 | FromDiscord | <Evrensel Kişilik> is Nim bindings for Godot stable and full-featured? |
01:29:15 | FromDiscord | <Elegantbeef> Lol did i not have netty as a dep 😀↵(@Arathanis) |
01:29:24 | FromDiscord | <Elegantbeef> How the fuck did i manage to do that 😀 |
01:29:55 | FromDiscord | <Arathanis> its easy, nimble doesn't add them automatically |
01:30:00 | FromDiscord | <Arathanis> i struggle with it too |
01:30:07 | FromDiscord | <Elegantbeef> Nah that's not my point |
01:30:14 | FromDiscord | <Elegantbeef> I somehow didnt run into any compilation issues |
01:30:55 | FromDiscord | <Arathanis> oh, well it should work fine if netty is installed with nimble, since nimble access your global environment you wont see any areas. Its if you take a clean nim environment and do `nimble install` that you are in trouble |
01:31:10 | FromDiscord | <Elegantbeef> you're telling me things i know |
01:31:27 | FromDiscord | <Arathanis> i dont doubt it, but I am reinforcing my own knowledge by repeating it. it helps me |
01:31:34 | FromDiscord | <Elegantbeef> Ah |
01:31:51 | FromDiscord | <Arathanis> also you mentioned not having compilation issues so i was seeking to explain since I assumed that meant you were at least partially confused. I mean no disrespect |
01:32:27 | FromDiscord | <Arathanis> you clearly have a stronger grasp on nim than I do :P |
01:32:35 | FromDiscord | <Elegantbeef> It's no problem just my behaviour 😛 |
01:34:04 | FromDiscord | <Elegantbeef> Hey my pong still works! |
01:34:13 | FromDiscord | <Elegantbeef> Well thanks for that |
01:34:43 | FromDiscord | <Elegantbeef> So you had questions? |
01:34:52 | * | jmdaemon joined #nim |
01:34:53 | FromDiscord | <Evrensel Kişilik> @ElegantBeef |
01:34:56 | FromDiscord | <Evrensel Kişilik> hewwoooo |
01:35:09 | FromDiscord | <Evrensel Kişilik> :meat: |
01:35:14 | FromDiscord | <Evrensel Kişilik> beeeeeeeeeef |
01:35:16 | FromDiscord | <Elegantbeef> Hello |
01:35:21 | FromDiscord | <Evrensel Kişilik> soooooooooooooooooooooooooooooooooooooooooooooooooooo |
01:35:45 | FromDiscord | <Evrensel Kişilik> is Nim bindings mature enough? |
01:36:02 | FromDiscord | <Elegantbeef> I mean people have used them to make games |
01:36:11 | FromDiscord | <Elegantbeef> I've toyed with them a bit I havent used them much |
01:36:21 | FromDiscord | <Evrensel Kişilik> people are using Unity tooooooo 😱 |
01:36:24 | FromDiscord | <Elegantbeef> They seem to work although are underdocumented |
01:36:36 | FromDiscord | <Evrensel Kişilik> oh |
01:36:43 | FromDiscord | <Evrensel Kişilik> thank you |
01:41:52 | FromDiscord | <Elegantbeef> @Arathanis\: did you dieded? 😛 |
01:44:58 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
01:46:10 | FromDiscord | <Arathanis> In reply to @Elegantbeef "<@136570191038513152>\: did you dieded?": nope! |
01:46:11 | FromDiscord | <Arathanis> still around |
01:46:17 | FromDiscord | <Arathanis> oh sorry |
01:46:23 | FromDiscord | <Arathanis> your query about questions was for me hjaha |
01:46:26 | FromDiscord | <Arathanis> (edit) "hjaha" => "haha" |
01:47:07 | FromDiscord | <Arathanis> im just trying to parse all the specifics of how the macro works, especially how it can be applied to a ensuring the type of a proc is appropriate for loading into the handler sequence |
01:47:39 | FromDiscord | <Arathanis> i noticed you have a proc for creating a list of parameter names and a mapping of names to types |
01:49:02 | FromDiscord | <Elegantbeef> Ok so you want a compile time error if you attempt to load the wrong proc? |
01:49:16 | FromDiscord | <Elegantbeef> Do you by any chance have the macro i gave you yesterday? |
01:50:38 | Amun-Ra | hmm, is there a doNotOptimizeOutThisCode pragma in nim? |
01:51:03 | FromDiscord | <Elegantbeef> Not that i know of |
01:51:08 | * | jmdaemon joined #nim |
01:52:11 | FromDiscord | <Rika> Technically exportc in some way lol |
01:54:44 | Amun-Ra | the other (non portable way) is importc: "memset_s" |
01:56:47 | Amun-Ra | (I need to make sure I zero sensitive data at the end of a main) |
01:57:25 | FromDiscord | <Elegantbeef> Use orc and a destructor? |
01:58:22 | Amun-Ra | hmm |
01:58:36 | Amun-Ra | good idea |
01:58:52 | FromDiscord | <Elegantbeef> I have them occasionally |
01:59:34 | Amun-Ra | ;) |
02:00:56 | Amun-Ra | "/dev/null".writeFile buf |
02:00:58 | Amun-Ra | ;) |
02:01:06 | FromDiscord | <Evrensel Kişilik> 😱 |
02:01:10 | FromDiscord | <Evrensel Kişilik> nooooo () |
02:01:13 | FromDiscord | <Evrensel Kişilik> oh nooo |
02:01:31 | FromDiscord | <Evrensel Kişilik> it is terrible for code search |
02:01:59 | Amun-Ra | what do you mean? |
02:02:29 | Amun-Ra | the joke code as a whole or the order of args? |
02:03:04 | FromDiscord | <Evrensel Kişilik> i meaaaan |
02:03:20 | FromDiscord | <Evrensel Kişilik> im finding codes by searching patterns like `foo(` |
02:03:40 | FromDiscord | <Rika> Lol |
02:03:42 | FromDiscord | <Rika> Have fun |
02:03:44 | Amun-Ra | :> |
02:04:03 | FromDiscord | <Rika> You’re gonna have to account for MCS and style insensitivity I gues |
02:04:13 | Amun-Ra | I usually write (if it's doable): writeFile "arg1", arg2 |
02:05:38 | FromDiscord | <Elegantbeef> Depends on the procedure name but yea |
02:08:48 | FromDiscord | <Evrensel Kişilik> 😱 |
02:08:51 | FromDiscord | <Evrensel Kişilik> oh nooooooooooooo |
02:08:59 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3OZE |
02:09:00 | Amun-Ra | I'm team snake case and I would write write_file but there's no such option in vim and vscode plugins |
02:09:01 | FromDiscord | <Evrensel Kişilik> you are razy |
02:09:05 | FromDiscord | <Elegantbeef> There you go arathanis 😛 |
02:09:13 | FromDiscord | <Arathanis> In reply to @Elegantbeef "Ok so you want": pretty much, I want to pass in a proc to be a handler and get a compile time error if its function signature doesn't match, and at least stitch the function signature up so you can omit params you dont need but it will be patched into the function to ensure it type matches the handler sequence |
02:09:25 | FromDiscord | <Arathanis> sorry i had to step away |
02:09:34 | FromDiscord | <Arathanis> dog caught a mouse, had to clean up the aftermath >_>;; |
02:09:43 | FromDiscord | <Elegantbeef> My dogs would probably run away |
02:09:53 | FromDiscord | <Arathanis> haha |
02:10:05 | FromDiscord | <Elegantbeef> Well you can do the patching inside that if branch now |
02:10:19 | FromDiscord | <Elegantbeef> Hopefully it makes sense you can do `pdef[3]` or `allowedImpl[3]` to get the parameters |
02:10:22 | FromDiscord | <Elegantbeef> first one is the return type |
02:10:35 | FromDiscord | <Elegantbeef> If you havent played with macros before it might be confusing but i do have a basic writeup to explain tooling to make it easier |
02:10:46 | FromDiscord | <Arathanis> ohhhh a writeup would be very useful |
02:11:01 | FromDiscord | <Arathanis> I wish the nim nodes used named parameters instead of numerical indexes |
02:11:05 | FromDiscord | <Elegantbeef> I need to expand it more for typed macros but it atleast explains the basic API https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
02:11:05 | FromDiscord | <Arathanis> it would make code a lot more readable |
02:11:21 | FromDiscord | <Elegantbeef> For procedures you can do `.name` `.params` and a few other i think |
02:11:23 | FromDiscord | <Rika> In reply to @Arathanis "I wish the nim": There are third party libraries that do this |
02:11:27 | FromDiscord | <Elegantbeef> But you need to know it's a procedure node |
02:11:49 | FromDiscord | <Elegantbeef> Personally I wish NimNodes were 100% distinct, each node was it's own Node type |
02:12:09 | * | neurocyte0917090 quit (Ping timeout: 256 seconds) |
02:12:09 | FromDiscord | <Arathanis> In reply to @Rika "There are third party": i figured this would exist, shame it isn't the standard |
02:12:13 | FromDiscord | <Elegantbeef> I know there are some packages that have started with that |
02:12:23 | FromDiscord | <Rika> In reply to @Elegantbeef "Personally I wish NimNodes": Not feasible |
02:18:42 | FromDiscord | <Arathanis> In reply to @Elegantbeef "I need to expand": this is pretty great |
02:19:12 | FromDiscord | <Elegantbeef> When ever i see a response like that i expect a "but...." |
02:19:19 | FromDiscord | <Arathanis> not this time |
02:19:44 | FromDiscord | <Arathanis> now im just tossing the specifics around in my hea |
02:19:45 | FromDiscord | <Arathanis> (edit) "hea" => "head" |
02:21:30 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3OZH |
02:22:23 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3OZI |
02:22:39 | FromDiscord | <Elegantbeef> Yep |
02:23:28 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3OZL |
02:23:45 | FromDiscord | <Arathanis> rather than `s` |
02:24:11 | FromDiscord | <Arathanis> I suppose the easiest way would be to based it entirely on the type, and not the name and just make sure the parameter order is always the same |
02:24:21 | FromDiscord | <Elegantbeef> I mean any parameter they didnt define is `_: TheType` |
02:24:21 | FromDiscord | <Elegantbeef> They cannot use it internally if they didnt define it |
02:25:31 | FromDiscord | <Arathanis> your article helped me understand the real value of dumpTree |
02:25:42 | FromDiscord | <Arathanis> apply it to the result you want -> see your goal |
02:25:49 | FromDiscord | <Arathanis> apply it to what you want to type -> see your starting position |
02:26:32 | FromDiscord | <Elegantbeef> Since it has to compile before the macro gets it |
02:26:32 | FromDiscord | <Elegantbeef> since the AST is typed they can only use parameters they supplied |
02:26:53 | * | jmdaemon quit (Ping timeout: 256 seconds) |
02:27:32 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3OZM |
02:28:13 | FromDiscord | <Elegantbeef> Well you could just have an untyped macro |
02:28:25 | FromDiscord | <Rika> Macros can be pragmas if you still don’t know |
02:28:47 | FromDiscord | <Arathanis> yeah i think that is what ElegantBeef was referring to, we were initally discussing using `{.myMacro.}` |
02:28:55 | FromDiscord | <Rika> What happened then |
02:28:57 | FromDiscord | <Arathanis> but that means the proc has to be semantically valid |
02:29:10 | FromDiscord | <Elegantbeef> No only if it's a typed macro |
02:29:15 | FromDiscord | <Elegantbeef> Untyped macros do not have to be semantically checked |
02:29:23 | FromDiscord | <Arathanis> even when used as a pragma? |
02:29:35 | FromDiscord | <Elegantbeef> Even when used as a pragma |
02:29:48 | FromDiscord | <Arathanis> so the proc could be nonsense and it would be ok? lol that is amazing |
02:30:11 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3OZN |
02:30:17 | FromDiscord | <Elegantbeef> But if it's not semantically checked you dont get types |
02:30:27 | FromDiscord | <Elegantbeef> So that means you have to rely on names being the same |
02:31:15 | FromDiscord | <Elegantbeef> Which means things like type aliases will not work |
02:31:46 | FromDiscord | <Elegantbeef> Personally I'm very much on the "Try to not inject anything that's unclear" now |
02:32:16 | FromDiscord | <Arathanis> that's honestly probably for the best |
02:32:21 | FromDiscord | <Arathanis> explicit is better than implicit kind of thing |
02:32:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3OZQ |
02:33:07 | FromDiscord | <Elegantbeef> You know what arguments the procedure wants |
02:33:17 | FromDiscord | <Elegantbeef> So you can see which ones you need to pass and in what order |
02:33:58 | FromDiscord | <Arathanis> ohh turn it into a closure which automatically has the right signature and just introspect how to construct the internal call? |
02:34:06 | FromDiscord | <Arathanis> well |
02:34:06 | FromDiscord | <Elegantbeef> This does add another proc of indirection but it makes it so they can reuse the code without hidden variables |
02:34:07 | FromDiscord | <Arathanis> not a closure |
02:34:08 | FromDiscord | <Elegantbeef> It's not a closure, but yes |
02:34:09 | FromDiscord | <Arathanis> a wrapper |
02:34:16 | FromDiscord | <Elegantbeef> It's just a anonymous proc yes |
02:34:35 | FromDiscord | <Arathanis> i can dig that |
02:34:37 | FromDiscord | <Elegantbeef> It allows the most code reuse without introducing any funky shit |
02:34:42 | FromDiscord | <Arathanis> good advice |
02:35:02 | FromDiscord | <Elegantbeef> Funky shit isnt nice, i've learned that playing with macros 😀 |
02:35:09 | FromDiscord | <Arathanis> or, and hear me out, i could take the advice of Ruby and Perl devs and make it as obtuse as possible |
02:35:12 | FromDiscord | <Arathanis> :^) |
02:35:52 | FromDiscord | <Elegantbeef> Like you can do cool stuff with macros, but doing anything that introduces hidden things is kinda bad form, I strive to avoid it as much as possible where it makes sense |
02:36:48 | FromDiscord | <Elegantbeef> I find it funny to say given that this was pretty much my first usage of macros |
02:36:50 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/940435978038956093/image.png |
02:37:10 | FromDiscord | <Elegantbeef> Super unintuitive API brought to you by silly ideas |
02:38:11 | FromDiscord | <Elegantbeef> It's now replaced by the following |
02:38:12 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/940436322965946369/image.png |
02:38:31 | FromDiscord | <Elegantbeef> One is vastly more sensible due to not making a new language for something simple 😛 |
02:38:58 | FromDiscord | <Arathanis> so how am I supposed to know `expectRoutine` exists if its not in the docs for `std/macros` u_u |
02:40:04 | FromDiscord | <Elegantbeef> isnt it `.expect(Routines)`? |
02:40:22 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940436870205173760/unknown.png |
02:40:41 | FromDiscord | <Elegantbeef> It's not exported |
02:40:45 | FromDiscord | <Elegantbeef> So you arent supposed to know about it |
02:40:51 | FromDiscord | <Evrensel Kişilik> soooooooooo |
02:40:56 | FromDiscord | <Evrensel Kişilik> tell me a reason to use Nim |
02:40:57 | FromDiscord | <Evrensel Kişilik> plsss |
02:41:12 | FromDiscord | <Arathanis> In reply to @Elegantbeef "It's not exported": oh you are right lmao, im deep in the source code following def links |
02:41:17 | FromDiscord | <Arathanis> i followed it from `params` |
02:41:20 | FromDiscord | <Arathanis> which is exported |
02:41:30 | FromDiscord | <Elegantbeef> It's a nice to write language with a bunch of utilities to make pleasurable to write efficient code 😀 |
02:41:51 | FromDiscord | <Evrensel Kişilik> sooooooooooooooooooo |
02:41:57 | FromDiscord | <Evrensel Kişilik> it is garbage collected |
02:42:05 | FromDiscord | <Arathanis> yes |
02:42:08 | FromDiscord | <Elegantbeef> It has a GC and reference counting like RAII |
02:42:11 | FromDiscord | <Arathanis> but iirc you have full control over the GC |
02:42:12 | FromDiscord | <Evrensel Kişilik> and we can write code like scripting |
02:42:35 | FromDiscord | <Evrensel Kişilik> buuuuuuut we can use pointer arithmetic tooooo right? |
02:42:46 | FromDiscord | <Elegantbeef> It's a system progrraming language |
02:43:00 | FromDiscord | <Evrensel Kişilik> sooooooo is there an OS written in Nim? |
02:43:02 | FromDiscord | <Elegantbeef> It doesnt have pointer arithmetic built in since it prefers type safe things, but yes |
02:43:14 | FromDiscord | <Elegantbeef> https://github.com/dom96/nimkernel |
02:43:41 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "It doesnt have pointer": i don't like safe coding |
02:43:47 | FromDiscord | <Arathanis> ive been selling it to people by saying its like statically typed python, with the low level power of C or C++ but it puts the footguns behind a few doors that you have to open explicitly instead of just handing them to you |
02:43:58 | FromDiscord | <Evrensel Kişilik> even GDScript is not totally memory safe |
02:44:04 | FromDiscord | <Evrensel Kişilik> it is not garbage collected tooo |
02:44:07 | FromDiscord | <Evrensel Kişilik> 😱 |
02:44:20 | FromDiscord | <Elegantbeef> Who said memory safe |
02:44:25 | FromDiscord | <Elegantbeef> Typesafety is not memory safety |
02:44:29 | FromDiscord | <Evrensel Kişilik> oh |
02:44:35 | FromDiscord | <Evrensel Kişilik> you meant type safety? |
02:44:52 | FromDiscord | <Arathanis> type safety as in if you say a variable is an integer and assign anything but an integer to it it screams at you |
02:44:57 | FromDiscord | <Arathanis> its strong, statically typed |
02:44:57 | FromDiscord | <Evrensel Kişilik> sooooooo i can't interpret memory with structs in Nim? |
02:45:31 | FromDiscord | <Elegantbeef> Nim differentiates pointers from pointers to an array |
02:45:32 | FromDiscord | <Elegantbeef> `ptr int` is a pointer to a single int `ptr UncheckedArray[int]` is a pointer to an array of ints |
02:45:32 | FromDiscord | <Elegantbeef> You can index the latter the former you cannot |
02:45:32 | FromDiscord | <Elegantbeef> This is similar to what Odin and Zig also do |
02:45:45 | FromDiscord | <Elegantbeef> You can |
02:45:50 | FromDiscord | <Arathanis> In reply to @Evrensel Kişilik "sooooooo i can't interpret": my understanding is that you can, its just the memory unsafe procedures-- the footguns -- are behind doors.↵↵it defaults to safe, you can be unsafe but you have to say you are going to be unsafe |
02:45:56 | FromDiscord | <Elegantbeef> Nim allows you to do the same as you would in any other system language |
02:46:02 | FromDiscord | <Elegantbeef> It just prefers by default to be type safe |
02:46:07 | FromDiscord | <Arathanis> its one of the things i think a lot of people like |
02:46:13 | FromDiscord | <Arathanis> is that you can be super low level and unsafe |
02:46:15 | FromDiscord | <Elegantbeef> There are like 6 unsafe keywords in nim |
02:46:17 | FromDiscord | <Arathanis> but you have to be explicit about it |
02:46:21 | FromDiscord | <Arathanis> and the defaults are safe |
02:46:21 | FromDiscord | <Evrensel Kişilik> soooooooooooo |
02:46:23 | FromDiscord | <Evrensel Kişilik> i like it |
02:46:33 | FromDiscord | <Elegantbeef> `pointer/ptr` `addr` `cast` |
02:46:39 | FromDiscord | <Rika> Nim doesn’t like restricting by design lol |
02:46:40 | FromDiscord | <Evrensel Kişilik> i don't have time to play with Nim now |
02:46:41 | FromDiscord | <Elegantbeef> What else am i missing |
02:46:41 | FromDiscord | <Evrensel Kişilik> buuuuuut |
02:46:44 | FromDiscord | <Elegantbeef> `unsafeaddr` |
02:46:47 | FromDiscord | <Evrensel Kişilik> i will do something |
02:47:01 | FromDiscord | <Elegantbeef> Nim can be used just as you'd use C but with a better typesystem, macros, and CTE |
02:47:16 | FromDiscord | <Elegantbeef> You can do `--gc:none` all day long if you wished |
02:47:32 | FromDiscord | <Elegantbeef> But most people would say do `--gc:arc` and use the RAII inspired memory management |
02:47:36 | FromDiscord | <Evrensel Kişilik> soooooooooooo |
02:47:47 | FromDiscord | <Elegantbeef> Which is based off move semantics and destructors just like..... C++/Rust afaik |
02:47:56 | FromDiscord | <Evrensel Kişilik> i can build some specific things without GC and statically link them right? |
02:47:58 | FromDiscord | <Elegantbeef> Well C++'s smartptr or w/e they're called |
02:48:04 | FromDiscord | <Elegantbeef> Yes |
02:48:07 | FromDiscord | <Rika> Sure |
02:48:09 | * | jmdaemon joined #nim |
02:48:16 | FromDiscord | <Evrensel Kişilik> goooooooooooooooooooooooooooooooooooooooooooooooooooood |
02:48:25 | FromDiscord | <Rika> It’s not very nice looking but it’s possible |
02:48:32 | FromDiscord | <Elegantbeef> Though you could consider the arc instead since it's deterministic and a bit safer 😛 |
02:48:36 | FromDiscord | <Evrensel Kişilik> soooooooooooo |
02:48:43 | FromDiscord | <Elegantbeef> Well they're a C lover so not very nice looking is what they like 😛 |
02:48:52 | FromDiscord | <Evrensel Kişilik> if i don't have anything that needs to be garbage collected |
02:49:12 | FromDiscord | <Evrensel Kişilik> would it affect my code complexity |
02:49:13 | FromDiscord | <Evrensel Kişilik> (edit) "complexity" => "complexity?" |
02:49:18 | FromDiscord | <Rika> Oh that’s gonna look no different from normal GC on code I believe |
02:49:23 | FromDiscord | <Evrensel Kişilik> i mean compiled code |
02:49:55 | FromDiscord | <Elegantbeef> It may depend on the memory management you use |
02:49:58 | FromDiscord | <Rika> The GC will still initialise if it’s on, but the Nim code should be the same between the two |
02:50:24 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3OZS |
02:50:32 | FromDiscord | <Evrensel Kişilik> oh |
02:50:32 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/mm.html |
02:50:37 | FromDiscord | <Evrensel Kişilik> `ptr` and `ref` |
02:50:41 | FromDiscord | <Evrensel Kişilik> soooooooooooooooooooooooooooooooooo |
02:50:48 | FromDiscord | <Elegantbeef> `ref` is a managed pointer |
02:50:52 | FromDiscord | <Evrensel Kişilik> what is `ref`? |
02:50:54 | FromDiscord | <Elegantbeef> `ptr` is a unmanaged pointer |
02:50:55 | FromDiscord | <Evrensel Kişilik> sooooooooooooo? |
02:50:58 | FromDiscord | <Arathanis> reference |
02:51:03 | FromDiscord | <Arathanis> its like a pointer the GC manages iirc |
02:51:04 | FromDiscord | <Evrensel Kişilik> what is managed? |
02:51:06 | FromDiscord | <Elegantbeef> `ref` is managed by the GC and the "safe" way to do pointers in Nim |
02:51:12 | FromDiscord | <Arathanis> the GC will reference count it |
02:51:22 | FromDiscord | <Evrensel Kişilik> damn |
02:51:22 | FromDiscord | <Elegantbeef> I say GC but more memory manager |
02:51:24 | FromDiscord | <Arathanis> `ptr` is a ref and you are telling the GC to butt out |
02:51:31 | FromDiscord | <Evrensel Kişilik> what will the GC free? |
02:51:39 | FromDiscord | <Elegantbeef> Since people dont like GC when talking about determnistic RCs |
02:51:44 | FromDiscord | <Elegantbeef> Depends on the memory management you use |
02:51:47 | FromDiscord | <Elegantbeef> ARC is a deterministic memory management system |
02:51:58 | FromDiscord | <Arathanis> GC should free any non-ptr memory with no external reference... i think |
02:52:23 | FromDiscord | <Arathanis> pretty sure you can import the gc and turn it off and on during runtime too |
02:52:27 | FromDiscord | <Elegantbeef> ARC decrements the counter at end of scope and it it's 0'd it calls the destructor afaik |
02:52:39 | FromDiscord | <Evrensel Kişilik> sooooooooooo |
02:52:48 | FromDiscord | <Elegantbeef> Refc is deferred reference counter |
02:53:02 | FromDiscord | <Elegantbeef> The link to memory mangement explains the systems |
02:53:19 | FromDiscord | <Evrensel Kişilik> sent a code paste, see https://play.nim-lang.org/#ix=3OZW |
02:53:23 | FromDiscord | <Evrensel Kişilik> what is GC about? |
02:53:48 | FromDiscord | <Rika> ? |
02:53:55 | FromDiscord | <Rika> References cannot be stack pointers |
02:53:55 | FromDiscord | <Elegantbeef> the `ref` is stack allocated since it's a pointer but the `bar` would be heap allocated |
02:54:09 | FromDiscord | <Elegantbeef> `ref T` can only refer to values allocated on the heap |
02:54:22 | FromDiscord | <Evrensel Kişilik> sooooooooooooooooooooooooooooooooo |
02:54:30 | FromDiscord | <Evrensel Kişilik> what will be garbage collected? |
02:54:33 | FromDiscord | <Rika> If you don’t want the GC use ptr |
02:54:38 | FromDiscord | <Rika> All ref is GCed |
02:54:39 | FromDiscord | <Elegantbeef> The heap allocated object |
02:54:50 | FromDiscord | <Evrensel Kişilik> buuuuuuuut refs are stack variables |
02:54:59 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "The heap allocated object": oh |
02:55:00 | FromDiscord | <Evrensel Kişilik> damn |
02:55:00 | FromDiscord | <Rika> Yes, the data in ref |
02:55:02 | FromDiscord | <Evrensel Kişilik> sooooooooo |
02:55:04 | FromDiscord | <Elegantbeef> The pointer is stack allocated |
02:55:04 | FromDiscord | <Evrensel Kişilik> you mean |
02:55:07 | FromDiscord | <Evrensel Kişilik> oh wait |
02:55:09 | FromDiscord | <Evrensel Kişilik> damn |
02:55:12 | FromDiscord | <Evrensel Kişilik> you mean |
02:55:18 | FromDiscord | <Rika> ?? |
02:55:23 | FromDiscord | <Elegantbeef> Just like any other language the pointer is on the stack |
02:55:28 | FromDiscord | <Elegantbeef> The data it points to is on the heap |
02:55:33 | FromDiscord | <Evrensel Kişilik> i have an allocated thing |
02:55:39 | FromDiscord | <Evrensel Kişilik> and i don't use it anymore |
02:55:42 | FromDiscord | <Rika> Yes |
02:55:44 | FromDiscord | <Evrensel Kişilik> and it will be garbage collected |
02:55:47 | FromDiscord | <Evrensel Kişilik> buuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuut |
02:55:49 | FromDiscord | <Rika> If it is a reference |
02:55:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/TfA |
02:56:07 | FromDiscord | <Evrensel Kişilik> if i use the allocated variable |
02:56:09 | FromDiscord | <Elegantbeef> In the above case the integer will be freed when the GC system says to |
02:56:13 | FromDiscord | <Evrensel Kişilik> it would not be garbage collected |
02:56:15 | FromDiscord | <Evrensel Kişilik> buuuuuuuuuuuuuut also |
02:56:26 | FromDiscord | <Evrensel Kişilik> it is same if i use a reference to it |
02:56:36 | FromDiscord | <Evrensel Kişilik> it will not be garbage collected also |
02:56:38 | FromDiscord | <Evrensel Kişilik> right? |
02:56:50 | FromDiscord | <Rika> I don’t understand |
02:56:58 | FromDiscord | <Elegantbeef> Me either |
02:57:03 | FromDiscord | <Evrensel Kişilik> ban @Rika |
02:57:04 | FromDiscord | <Evrensel Kişilik> pls |
02:57:21 | FromDiscord | <Evrensel Kişilik> soooooooooooooooo i just mean |
02:57:31 | FromDiscord | <Evrensel Kişilik> using a ref to an allocated thing |
02:57:38 | FromDiscord | <Rika> Okay |
02:57:45 | FromDiscord | <Evrensel Kişilik> avoids garbage collection for that allocated thing |
02:57:46 | FromDiscord | <Evrensel Kişilik> right? |
02:57:49 | FromDiscord | <Elegantbeef> If you allocate a reference it's heap allocated and will be freed when the GC says so(nothing points to it) |
02:58:00 | FromDiscord | <haolian9 (高浩亮)> hi all, is there a guide on using log inside a library?↵i checked out some libraries which did not use log, what if i need some log info to debug those libraies? |
02:58:09 | FromDiscord | <Rika> If you have a reference and it’s still being used it will not be reallocated |
02:58:09 | FromDiscord | <Evrensel Kişilik> soooooooooooooo? |
02:58:10 | FromDiscord | <Evrensel Kişilik> yes or no? |
02:58:14 | FromDiscord | <Rika> Deallocated |
02:58:30 | FromDiscord | <Evrensel Kişilik> In reply to @Rika "If you have a": sooooooooooooooooooooooooo it is a yes |
02:58:31 | FromDiscord | <Rika> In reply to @haolian9 (高浩亮) "hi all, is there": Add logs then |
02:58:42 | FromDiscord | <Evrensel Kişilik> buuuuuuut it is not same for `ptr` |
02:58:53 | FromDiscord | <Rika> In reply to @Evrensel Kişilik "sooooooooooooooooooooooooo it is a": By the way, you cannot convert ptr to ref without reallocation |
02:59:02 | FromDiscord | <Evrensel Kişilik> hmmmmmmmmmmmmmm |
02:59:06 | FromDiscord | <Evrensel Kişilik> convert? |
02:59:11 | FromDiscord | <Rika> You must stay in one or the other |
02:59:22 | FromDiscord | <Rika> You can’t make a ptr into a ref and vice versa |
02:59:22 | FromDiscord | <Elegantbeef> pointers are unmanged the Nim memory management cannot know how many things point to the data |
02:59:44 | FromDiscord | <Elegantbeef> Pointers work just like they do in C |
02:59:48 | FromDiscord | <Rika> Pointers are plain pointers like in C |
02:59:49 | FromDiscord | <Rika> Yes |
02:59:55 | FromDiscord | <Elegantbeef> though in Nim they're 0-init'd |
02:59:56 | FromDiscord | <Elegantbeef> So they're always nil by default |
03:00:15 | FromDiscord | <Rika> So like calloc |
03:00:24 | FromDiscord | <Elegantbeef> Though like i mentioned before Nim doesnt have pointer arithmetic by default |
03:00:33 | FromDiscord | <Elegantbeef> Cause that's a very silly thing \: |
03:01:13 | FromDiscord | <Rika> You can make it do pointer arithmetic but it’s not pretty |
03:01:48 | FromDiscord | <Elegantbeef> https://github.com/kaushalmodi/ptr_math just use this 😛 |
03:01:58 | FromDiscord | <Evrensel Kişilik> high level things are always cauising unpredictable issues |
03:02:12 | FromDiscord | <Elegantbeef> Yea like lowlevel things never do |
03:02:31 | FromDiscord | <Evrensel Kişilik> low level things are always difficult |
03:02:31 | FromDiscord | <Elegantbeef> No one has ever accidently dereferenced a non 0-init'd pointer in C |
03:02:37 | FromDiscord | <Evrensel Kişilik> but never unpredictable |
03:02:45 | FromDiscord | <Elegantbeef> No one has ever forgot the `\0` inside a cstring 😀 |
03:02:53 | FromDiscord | <Elegantbeef> Well there is no unpredictable issues |
03:02:55 | FromDiscord | <Evrensel Kişilik> i left Unity and switched back to Godot |
03:03:05 | FromDiscord | <Evrensel Kişilik> the problam was being fucking high level |
03:03:06 | FromDiscord | <Rika> Unpredictability is not the only issue |
03:03:13 | FromDiscord | <Rika> Something being obtuse causes bugs too |
03:03:24 | FromDiscord | <Evrensel Kişilik> soooooooooooooo |
03:03:28 | FromDiscord | <Evrensel Kişilik> dooooon't worry |
03:03:29 | FromDiscord | <Elegantbeef> The problem with Unity isnt about highlevel but more about the fact the engine lacks anything but a rendering backend |
03:03:36 | FromDiscord | <Evrensel Kişilik> i will write some articles about my philosophy |
03:03:48 | FromDiscord | <Rika> Unity is pretty confusing ngl |
03:03:52 | FromDiscord | <Elegantbeef> Unity's biggest issue is that you have to make everything yourself or buy an asset |
03:04:08 | FromDiscord | <Evrensel Kişilik> simply |
03:04:11 | FromDiscord | <Evrensel Kişilik> it is broken |
03:04:12 | FromDiscord | <Elegantbeef> Anyone that uses Unity "properly" makes their own tooling, cause Unity lacks it |
03:04:31 | FromDiscord | <Evrensel Kişilik> Unity's Netcode thing is extremely buggy |
03:04:35 | FromDiscord | <Elegantbeef> All the people I know that use Unity just use it as a BGFX like library |
03:04:55 | FromDiscord | <Evrensel Kişilik> it doesn't support WebSocket and there is a community thing for that but it is not working for web exports |
03:05:08 | FromDiscord | <Evrensel Kişilik> ummmmm also web exports are totally buggy in Unity |
03:05:18 | FromDiscord | <Evrensel Kişilik> i was about to crazy today |
03:05:23 | FromDiscord | <Evrensel Kişilik> (edit) "i was about to ... crazy" added "go" |
03:05:25 | FromDiscord | <Evrensel Kişilik> buuuuut |
03:05:35 | FromDiscord | <Evrensel Kişilik> it is always same |
03:05:54 | FromDiscord | <Evrensel Kişilik> some people write some shit codes with shit architectures |
03:06:28 | FromDiscord | <Evrensel Kişilik> and other ones make something that will force them to write better architectured code |
03:06:33 | FromDiscord | <Elegantbeef> Hey i'm right here just say it to my face |
03:06:34 | FromDiscord | <Evrensel Kişilik> this is just a curse |
03:06:49 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "Hey i'm right here": what? |
03:07:04 | FromDiscord | <Elegantbeef> > some people write some shit codes with shit architectures |
03:07:10 | FromDiscord | <Evrensel Kişilik> oh |
03:07:12 | FromDiscord | <Evrensel Kişilik> lol |
03:07:15 | FromDiscord | <Evrensel Kişilik> i mean for example |
03:07:18 | FromDiscord | <Evrensel Kişilik> JavaScript |
03:07:32 | FromDiscord | <Evrensel Kişilik> tons of people write shit codes |
03:07:52 | FromDiscord | <Evrensel Kişilik> and damn virus frameworks are occuring |
03:08:02 | FromDiscord | <Evrensel Kişilik> frameworks are viruses |
03:08:26 | FromDiscord | <Evrensel Kişilik> soooooooooo breaking programmability |
03:08:31 | FromDiscord | <Evrensel Kişilik> this is the problem |
03:10:29 | FromDiscord | <Evrensel Kişilik> soooooooo GDScript is very high level yes |
03:10:43 | FromDiscord | <Evrensel Kişilik> but not in meaning of breaking programmability |
03:17:32 | * | arkurious quit (Quit: Leaving) |
03:28:13 | NimEventer | New thread by Haoliang: Best practice or guidelines on using log in a library?, see https://forum.nim-lang.org/t/8880 |
03:28:30 | FromDiscord | <Evrensel Kişilik> In reply to @NimEventer "New thread by Haoliang:": you are a real bot? |
03:28:35 | FromDiscord | <Evrensel Kişilik> i hope you are |
03:28:45 | FromDiscord | <Elegantbeef> That's a real bot |
03:28:57 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "That's a real bot": just like you!!!! |
03:29:11 | FromDiscord | <Evrensel Kişilik> your avatar scaring me |
03:29:18 | FromDiscord | <Elegantbeef> Leave my doggo alone |
03:29:18 | FromDiscord | <Evrensel Kişilik> plssss get out here |
03:29:31 | FromDiscord | <congusbongus> says the anime dp guy |
03:29:54 | FromDiscord | <Evrensel Kişilik> 😱 |
03:30:16 | FromDiscord | <congusbongus> just kidding |
03:30:37 | FromDiscord | <Evrensel Kişilik> im hungry |
03:30:43 | FromDiscord | <Evrensel Kişilik> please make me some fooods |
03:31:02 | FromDiscord | <Evrensel Kişilik> maybe a beef toast |
03:31:06 | FromDiscord | <evoalg> Sometimes I think I'm the only human here |
03:31:15 | FromDiscord | <Elegantbeef> Clearly you're not human |
03:31:24 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "Clearly you're not human": yes |
03:31:27 | FromDiscord | <Evrensel Kişilik> yesssssssssssssssssssss |
03:31:55 | FromDiscord | <Evrensel Kişilik> sooooooooo this 1440p monitor is not enough |
03:31:56 | FromDiscord | <congusbongus> Tell me more about Sometimes I think I'm the only human here |
03:32:00 | FromDiscord | <Rika> Sometimes I think |
03:32:10 | FromDiscord | <Rika> Only sometimes though |
03:32:30 | FromDiscord | <Evrensel Kişilik> i will get a 4K monitor |
03:32:47 | FromDiscord | <Evrensel Kişilik> buuuuuut curved one |
03:34:34 | FromDiscord | <Elegantbeef> You're a programmer you dont need horizontal display you need vertical display |
03:37:13 | FromDiscord | <Evrensel Kişilik> In reply to @Elegantbeef "You're a programmer you": oh |
03:37:23 | FromDiscord | <Evrensel Kişilik> it is correct |
03:37:26 | FromDiscord | <Evrensel Kişilik> buuuuuuuuuut |
03:37:46 | FromDiscord | <Evrensel Kişilik> im using soooo many windows |
03:38:02 | FromDiscord | <Evrensel Kişilik> it is correct while coding |
03:39:03 | * | m5zs7k joined #nim |
03:39:03 | FromDiscord | <Evrensel Kişilik> buuuuuuut sometimes |
03:39:07 | FromDiscord | <Evrensel Kişilik> for example debugging |
03:39:17 | FromDiscord | <Evrensel Kişilik> we need horizontal space |
03:39:25 | FromDiscord | <Evrensel Kişilik> ummmmmmm there are soooo many times |
03:39:29 | FromDiscord | <Evrensel Kişilik> that we need horizontal space |
03:40:38 | FromDiscord | <Evrensel Kişilik> this new monitor's feet is not gooooooood it only has vertical movement |
03:40:57 | FromDiscord | <Evrensel Kişilik> i need a custom monitor feet |
03:43:03 | FromDiscord | <Evrensel Kişilik> why do i love Godot this much? |
03:43:34 | FromDiscord | <Rika> That’s an idea soup if I’ve ever seen one |
03:43:47 | FromDiscord | <Evrensel Kişilik> In reply to @Rika "That’s an idea soup": whaaaaaaaaaaaaaaaaaaaat |
03:43:53 | FromDiscord | <Evrensel Kişilik> whatt soup?? |
03:44:02 | FromDiscord | <Evrensel Kişilik> will you make a soup for me? |
03:44:05 | FromDiscord | <Evrensel Kişilik> you mean that? |
04:12:48 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=3P0i |
04:13:10 | FromDiscord | <creikey> if I wanted to create a windy window like this and return it from a function, how should I capture the window for the resize callback? |
04:13:18 | FromDiscord | <creikey> doing this results in a compile error about memory safety |
04:13:31 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix= |
04:15:37 | FromDiscord | <Elegantbeef> One way would be to make the `result` type a `ref T` |
04:16:03 | FromDiscord | <Elegantbeef> The issue is that `result` is a stack variable so once the procedure is done it's unsafe to reference it i assume |
04:16:41 | FromDiscord | <Elegantbeef> Really the `onResize` should probably take a parameter `window` so you can access that stuff internally |
04:17:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P0j |
04:20:10 | FromDiscord | <creikey> In reply to @Elegantbeef "The issue is that": it's only referenced by a function also tied to the lifetime of the window |
04:20:57 | FromDiscord | <Elegantbeef> What? |
04:21:17 | FromDiscord | <creikey> like the `window.onResize` proc will also be freed with the `window` variable |
04:21:39 | FromDiscord | <Elegantbeef> Sure but that's not related to what i said |
04:21:41 | FromDiscord | <creikey> so it should be fine to capture `window` in it as when window dies it dies |
04:21:46 | FromDiscord | <creikey> I mean I guess you can still copy the function |
04:21:49 | FromDiscord | <Elegantbeef> It's not capturing window |
04:21:59 | FromDiscord | <Elegantbeef> It's capturing the window on the result |
04:22:04 | FromDiscord | <creikey> it's capturing result which is a Window ooh wait |
04:22:06 | FromDiscord | <creikey> I see what you're saying |
04:22:29 | FromDiscord | <Elegantbeef> What is the type of `result`? |
04:29:17 | FromDiscord | <creikey> In reply to @Elegantbeef "What is the type": I stashed those changes as I decided refactoring everything into a separate file and api wasn't really worth it but it was just an object with window in it |
04:29:45 | FromDiscord | <Elegantbeef> Ah so i was right that it was a stack variable |
04:29:59 | FromDiscord | <creikey> yeah returned from the function |
04:30:24 | FromDiscord | <creikey> I can just git submodule nimble packages from a fork if I want to edit them right |
04:30:25 | FromDiscord | <Elegantbeef> Then yea i'm 99% certain the bug would've went away with the ref change or the direct reference of the window |
04:30:31 | FromDiscord | <Elegantbeef> Well compile error |
04:30:40 | FromDiscord | <Elegantbeef> Uhh i just fork clone and `nimble develop` which symlinks it |
04:30:47 | FromDiscord | <creikey> oh yo that sounds nice |
04:56:40 | FromDiscord | <noow> any way to mark an import used, when importing it has a side effect |
04:57:14 | FromDiscord | <noow> i know i know importing modules mutating global variables is not the best design, but sometimes it's convenient in a module-loadingy thingy |
04:58:18 | FromDiscord | <Elegantbeef> You can do `import x {.used.}` |
04:58:31 | FromDiscord | <Elegantbeef> you can also put `{.used.}` inside the body of the proc |
04:58:35 | FromDiscord | <Elegantbeef> i mean module |
04:58:39 | FromDiscord | <noow> thank |
04:58:45 | FromDiscord | <noow> i guess i could also use includes |
04:58:49 | FromDiscord | <noow> but this one seems fine for now |
04:58:52 | FromDiscord | <Elegantbeef> No |
04:58:57 | FromDiscord | <Elegantbeef> Dont use include unless you actually need it |
04:59:30 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#pragmas-used-pragma |
05:00:16 | FromDiscord | <noow> Error: invalid pragma, expected: {all} |
05:01:05 | FromDiscord | <Elegantbeef> Guess you cannot use it on imports |
05:01:09 | FromDiscord | <Elegantbeef> So just throw it inside the module |
05:01:18 | FromDiscord | <noow> oki |
06:23:30 | * | Gustavo6046 joined #nim |
06:28:37 | * | Gustavo6046 quit (Ping timeout: 250 seconds) |
06:33:29 | * | lain quit (Quit: brb) |
06:35:09 | * | lain joined #nim |
06:35:14 | * | cyraxjoe quit (Quit: I'm out!) |
06:36:55 | * | cyraxjoe joined #nim |
06:38:55 | * | cyraxjoe quit (Client Quit) |
06:40:45 | * | cyraxjoe joined #nim |
07:00:22 | FromDiscord | <Someone.one> is it possible to have non-continuous range types? |
07:00:34 | FromDiscord | <Elegantbeef> No |
07:01:08 | FromDiscord | <Elegantbeef> You could use a `sequence[Slice[T]]` |
07:01:13 | FromDiscord | <Elegantbeef> jeez |
07:01:16 | FromDiscord | <Elegantbeef> `seq[Slice[T]]` |
07:04:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P0G |
07:04:59 | * | PMunch joined #nim |
07:12:55 | FromDiscord | <Arathanis> whats the best way to make a new expression node? Specifically a ExprEqExpr? |
07:13:12 | FromDiscord | <Elegantbeef> `nnkExprEqExpr.newTree(a, b)` |
07:16:57 | FromDiscord | <Phil> reads the bit about "you can just turn on the gc arc flag with your currently written code |
07:16:59 | FromDiscord | <Phil> squints |
07:17:10 | FromDiscord | <Phil> (edit) "code" => "code"" |
07:17:37 | FromDiscord | <Phil> Are you sure I wouldn't have to do some code adjustments here or there to make different GC's such as ARC work? |
07:18:06 | FromDiscord | <Phil> Like, I haven't tried, but I'd be willing to bet the compiler explodes somewhere if I turned that flag on right now |
07:18:23 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P0H |
07:18:35 | FromDiscord | <Elegantbeef> You shouldnt need to do anything to make ORC work |
07:18:42 | FromDiscord | <Elegantbeef> With ARC you have to ensure you dont have cycles |
07:18:48 | FromDiscord | <Elegantbeef> But it will "work" without that |
07:19:11 | FromDiscord | <Elegantbeef> Arc/Orc should not require changing code |
07:21:23 | FromDiscord | <Phil> Wait, can arc compile even if I have cycles or does it explode as would be appropriate? |
07:21:33 | FromDiscord | <Elegantbeef> It compiles it just doesnt free |
07:21:50 | FromDiscord | <Phil> Well... that's unfortunate for me |
07:21:51 | FromDiscord | <Phil> hm |
07:21:58 | FromDiscord | <Elegantbeef> You leak cycles |
07:22:02 | FromDiscord | <Arathanis> does `ident` not let you make arbitrary identifier nodes? |
07:22:06 | FromDiscord | <Elegantbeef> Use orc or handle cycles yourself |
07:22:13 | FromDiscord | <Elegantbeef> "arbitrary identifiers"? |
07:22:20 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940507822846771210/unknown.png |
07:22:22 | FromDiscord | <Phil> I don't know if I leak cycles, having the compiler check for me would be nice ^^' |
07:22:24 | FromDiscord | <Elegantbeef> `genSym` is what you want |
07:22:36 | FromDiscord | <Arathanis> ohhhh ok |
07:22:44 | FromDiscord | <Elegantbeef> I mean i thin kti's what you want |
07:22:49 | FromDiscord | <Elegantbeef> Do you want to be able to access the symbol? |
07:23:21 | FromDiscord | <Phil> Was just a matter of whether it could've been a low-hanging-fruit optimization - Just enable the flag, adjust the parts of your code where the compiler screams and enjoy having arc |
07:24:20 | FromDiscord | <Arathanis> In reply to @Elegantbeef "Do you want to": im trying to use it to make a `ExprEqExpr` |
07:24:50 | FromDiscord | <Elegantbeef> so then `ident"number", yourValHere` |
07:24:54 | FromDiscord | <Arathanis> sent a code paste, see https://paste.rs/jd0 |
07:25:15 | FromDiscord | <Elegantbeef> Oh you've fallen for the trap |
07:25:28 | FromDiscord | <Arathanis> getting trapped is part of learning :] |
07:25:32 | FromDiscord | <Arathanis> (edit) "https://play.nim-lang.org/#ix=3P0L" => "https://play.nim-lang.org/#ix=3P0K" |
07:25:37 | FromDiscord | <Elegantbeef> inside an arg list it's not a `nnkExprEqExpr` it's a `nnkIdentDef` |
07:25:50 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/macros.html#newIdentDefs%2CNimNode%2CNimNode |
07:26:13 | FromDiscord | <Elegantbeef> Wait you're doing named parameters |
07:26:13 | FromDiscord | <Elegantbeef> I'm dumb |
07:26:30 | FromDiscord | <Elegantbeef> What's the compiler error? |
07:26:45 | FromDiscord | <Arathanis> undeclared identifier: "number" |
07:26:52 | FromDiscord | <Elegantbeef> do me a favour and do `echo result.repr` at the end of the macrro |
07:26:53 | FromDiscord | <Arathanis> same for message |
07:26:56 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940508982026592276/unknown.png |
07:27:01 | FromDiscord | <Arathanis> it has a problem there |
07:27:12 | FromDiscord | <Elegantbeef> Like i said `echo result.repr` |
07:27:30 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P0M |
07:27:44 | FromDiscord | <Elegantbeef> Yea then run the code |
07:27:47 | FromDiscord | <Elegantbeef> Or attempt to compile it |
07:27:53 | FromDiscord | <Elegantbeef> it'll give you the generated Nim code out |
07:27:56 | FromDiscord | <Elegantbeef> I want to see that |
07:28:44 | FromDiscord | <Arathanis> k let me make sure its cleaned up so im only giving you relevant output |
07:28:49 | FromDiscord | <Arathanis> scratchpaper folder lol |
07:29:27 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P0O |
07:29:40 | FromDiscord | <Elegantbeef> Ah there you go |
07:29:42 | FromDiscord | <Elegantbeef> You can probably see the issue now |
07:30:09 | FromDiscord | <Arathanis> oh its in the uhh |
07:30:16 | FromDiscord | <Arathanis> genAst call isnt it |
07:30:18 | FromDiscord | <Elegantbeef> `genAst` gensyms symbols by default, so you need to do `genAst(..., number = ident"number", message = ident"message")` |
07:30:40 | FromDiscord | <Elegantbeef> Dont know if it respects `{.inject.}` |
07:30:48 | FromDiscord | <Elegantbeef> you could try that aswell |
07:31:02 | FromDiscord | <Arathanis> how would i try inject? |
07:31:07 | FromDiscord | <Elegantbeef> `proc (number {.inject.}: int, message {.inject.}: string)` |
07:31:16 | FromDiscord | <Arathanis> ohhh |
07:31:19 | FromDiscord | <Arathanis> ill try that |
07:31:23 | FromDiscord | <Arathanis> also your first idea totally worked |
07:31:37 | FromDiscord | <Elegantbeef> Who'd i be if i couldnt write macros |
07:32:02 | FromDiscord | <Elegantbeef> Where's rika to say "Useful" |
07:32:13 | FromDiscord | <Arathanis> it does respect inject |
07:32:48 | FromDiscord | <Arathanis> it also autoformats things really terribly |
07:32:56 | FromDiscord | <Arathanis> this looks awful https://media.discordapp.net/attachments/371759389889003532/940510496233234472/unknown.png |
07:33:04 | FromDiscord | <Arathanis> apparently it wants it to look that way lol |
07:33:20 | FromDiscord | <Elegantbeef> I mean you can disable nimpretty |
07:33:37 | FromDiscord | <Elegantbeef> Or increase the line limit |
07:33:40 | FromDiscord | <Elegantbeef> 80 is quite small |
07:33:53 | FromDiscord | <Elegantbeef> Someone is writting a fucking essay and i'm scared |
07:34:08 | FromDiscord | <Elegantbeef> Oh did the bridge just glitch |
07:34:23 | FromDiscord | <Arathanis> nah i decided i didnt need to hit enter :P |
07:34:37 | FromDiscord | <Arathanis> extended the line length to 120 |
07:34:39 | FromDiscord | <Arathanis> and now its sane |
07:34:43 | FromDiscord | <Elegantbeef> Not you the person that asked about the ranges |
07:34:47 | FromDiscord | <Arathanis> ohhhh |
07:34:57 | FromDiscord | <Elegantbeef> Just dont go too wild with the horizontal size |
07:35:03 | FromDiscord | <Elegantbeef> Vertical \> horizontal |
07:35:49 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/jCB |
07:36:08 | FromDiscord | <Elegantbeef> If you dont want the random `add` that is |
07:36:30 | FromDiscord | <Arathanis> that seems, almost weird |
07:36:42 | FromDiscord | <Elegantbeef> Macros really benefit from the fun Nim syntax imo |
07:36:46 | FromDiscord | <Arathanis> haha |
07:36:58 | FromDiscord | <Elegantbeef> You come to love the block call logic Nim has |
07:37:10 | FromDiscord | <Arathanis> oh i do, its just about internalizing it all |
07:37:19 | FromDiscord | <Arathanis> lots of... i think the word is currying |
07:37:34 | FromDiscord | <Arathanis> well i really appreciate the help |
07:37:37 | FromDiscord | <Elegantbeef> Currying is different but we'll take it 😀 |
07:37:45 | FromDiscord | <Elegantbeef> No problem |
07:37:50 | FromDiscord | <Arathanis> im finally at the point where i understand macros enough to be dangerous lmao |
07:37:55 | FromDiscord | <Arathanis> now i can experiment |
07:38:04 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P0R |
07:38:06 | FromDiscord | <Elegantbeef> Personally I view `error` much better than `expect` |
07:38:37 | FromDiscord | <Arathanis> i agree, but I was going for quick and dirty get it working before working on, "now that it works, make it better" |
07:39:08 | FromDiscord | <Elegantbeef> Ah ok |
07:39:15 | FromDiscord | <Elegantbeef> Getting that wonderful line information is one thing i wanted to push in the recent additions i did to that tutorial |
07:39:21 | FromDiscord | <Elegantbeef> Getting line information is so much nicer than just not compiling |
07:39:38 | FromDiscord | <Elegantbeef> If you want more macros to look at i have no shortage of them 😛 |
07:40:02 | FromDiscord | <Elegantbeef> Oh right i did link a bunch of my macro projects on that writeup |
07:40:39 | FromDiscord | <Arathanis> so "error" lets pass a string and the node causing the error, so you get better line number indication of where the actual problem is? |
07:40:49 | FromDiscord | <Elegantbeef> Yep |
07:41:00 | FromDiscord | <Elegantbeef> You also can give a custom error message which helps more than just a "Bitch this wrong" |
07:41:19 | FromDiscord | <Elegantbeef> If you have error message reporting for the line number (code lens in vscode) it's glorious |
07:41:24 | FromDiscord | <Arathanis> how smart is it, could i for example see that the first parameter in the wrapped function's type is incorrect and raise an error on that specific node? |
07:41:32 | FromDiscord | <Elegantbeef> Yes |
07:41:36 | FromDiscord | <Arathanis> beautiful |
07:41:38 | * | crem1 quit (Ping timeout: 260 seconds) |
07:41:41 | FromDiscord | <Elegantbeef> It copies the line information of the Nimnode |
07:42:02 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/940512782493814804/image.png |
07:42:04 | FromDiscord | <Elegantbeef> I mean it's wonderful |
07:42:15 | FromDiscord | <Arathanis> ha |
07:42:18 | FromDiscord | <Arathanis> it totally works |
07:42:40 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940512944402350110/unknown.png |
07:42:49 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940512980955705414/unknown.png |
07:43:03 | FromDiscord | <Elegantbeef> Yea it really makes the macros feel like compiler extensions rather than some silly procs |
07:43:17 | FromDiscord | <Elegantbeef> I highly suggest codelens since it seems you're using vscode |
07:43:36 | FromDiscord | <Arathanis> yeah this solves the problem i experienced with macros before |
07:43:39 | FromDiscord | <Arathanis> extension? |
07:43:44 | FromDiscord | <Elegantbeef> Yea |
07:43:57 | FromDiscord | <Elegantbeef> Sorry it's called errorlens |
07:44:03 | FromDiscord | <Elegantbeef> codelens is just the feature |
07:44:22 | FromDiscord | <Arathanis> i see two, im guessing the 500k+ one is the good one and the other is a horrible fork |
07:44:38 | FromDiscord | <Elegantbeef> No clue i'm on vscodium using openvsix so i have 1 |
07:45:01 | FromDiscord | <Arathanis> ah thats really nice, ngl |
07:45:03 | FromDiscord | <Arathanis> looks good |
07:45:26 | FromDiscord | <Elegantbeef> The thing i'd suggest to do now is make that macro a `typed` one then inspect the arguments to see if they match the definition |
07:45:51 | FromDiscord | <Arathanis> can you elaborate on that just a tad? im gonna have to go to bed so I can work tomorrow. |
07:45:53 | FromDiscord | <Elegantbeef> Then support nothing, `string` `string, int` `int` |
07:46:26 | FromDiscord | <Elegantbeef> Well use typed macros so you can see if they have a `string, int` parameter and then when you call the event pass the argument in the proper order |
07:46:59 | FromDiscord | <Elegantbeef> This way you can do `proc myProc(a: string, b: int)` or `proc myProc(a: int, b: string)` 😀 |
07:47:16 | FromDiscord | <Elegantbeef> The reason you'd want typed is so you can support aliases |
07:48:52 | FromDiscord | <Elegantbeef> then also handle nice error reporting if they have a return type, if they have too many parameters or none of the right kind 😛 |
07:49:01 | FromDiscord | <Arathanis> i guess im just not quite sure how to do that and exactly what typed buys me |
07:49:04 | FromDiscord | <Elegantbeef> Then you can say "I've done it" |
07:49:34 | FromDiscord | <Elegantbeef> `typed` macros are semantically checked, so you can get what the types are from the `parameter[^2]` ast |
07:49:55 | FromDiscord | <Elegantbeef> you can do `parameter[^2].sameType(bindSym"string")` for instance |
07:52:37 | FromDiscord | <Arathanis> what does `sameType` do |
07:53:11 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/macros.html#sameType%2CNimNode%2CNimNode |
07:53:12 | FromDiscord | <Arathanis> oh it ensures they are the same |
07:53:13 | FromDiscord | <Elegantbeef> It's supposed to compare the type of two semantically checked nodes |
07:53:30 | FromDiscord | <Arathanis> so i will also have to make my idents semantically checked as well |
07:55:06 | FromDiscord | <Elegantbeef> No your output ones dont need to be |
07:55:06 | FromDiscord | <Elegantbeef> The compiler is what semantically checks them |
07:55:47 | FromDiscord | <Arathanis> ok, i will have to follow up on this tomorrow after work |
07:55:56 | FromDiscord | <Arathanis> thanks again, this has helped a lot |
07:56:28 | FromDiscord | <Elegantbeef> Here's an example anyway |
07:56:34 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P0V |
07:56:56 | FromDiscord | <Elegantbeef> You probably wont need the `getType` stuff, but for this example it was needed |
07:57:03 | FromDiscord | <Elegantbeef> Go to sleep now! |
08:04:22 | * | crem1 joined #nim |
08:11:25 | FromDiscord | <Someone.one> In reply to @Elegantbeef "You encouraged me to": this is quite helpful, thanks. is it possible to get and set `a` without using a discrete method? kind of like a transparent replacement for something like `var z: range[1..10]` ? |
08:12:36 | FromDiscord | <Elegantbeef> Nope that'd require return type inference |
08:12:56 | FromDiscord | <Elegantbeef> Atleast i dont think so |
08:14:27 | * | krux02 joined #nim |
08:15:07 | FromDiscord | <Elegantbeef> we can steal `:=` https://play.nim-lang.org/#ix=3P11 |
08:15:24 | FromDiscord | <Elegantbeef> Nim would be more expressive if we could write custom `=` for non equivalent types though |
08:17:11 | FromDiscord | <Someone.one> In reply to @Elegantbeef "we can steal `:=`": ah, this is nice. but the situation for the getter would still be the same, no? |
08:17:14 | FromDiscord | <Elegantbeef> Though `..=` might make sense as it's "range assign" |
08:17:28 | FromDiscord | <Elegantbeef> What? |
08:21:04 | FromDiscord | <Someone.one> In reply to @Elegantbeef "What?": to get the value we still need to do a.val |
08:21:15 | FromDiscord | <Elegantbeef> Yes |
08:21:28 | * | Gustavo6046 joined #nim |
08:23:50 | * | Zevv joined #nim |
08:23:53 | Zevv | PMunch: moin |
08:24:09 | PMunch | Mornin' Zevv |
08:24:20 | FromDiscord | <Elegantbeef> Morning |
08:24:36 | Zevv | i believe you'd like to have `[]` on the capture object, right? |
08:25:15 | Zevv | I forgot the details, but I remember struggling with that for some reason |
08:25:29 | FromDiscord | <Elegantbeef> Context? |
08:25:55 | Zevv | a ticket on npeg from pmunch : https://github.com/zevv/npeg/issues/40 |
08:26:42 | FromDiscord | <Elegantbeef> Ah |
08:28:48 | PMunch | Yes, so that you could still do captures[1..^1] |
08:29:10 | FromDiscord | <Elegantbeef> Yea i dont see any reason why you could not do `[1..^1]` |
08:29:25 | Zevv | right. i'll have to look into that, I had a fight with nim over that IIRC |
08:30:03 | PMunch | Wouldn't the simple implementation just be a template which passes it on to the sequence? |
08:30:28 | FromDiscord | <Elegantbeef> `proc `[]`[S](cs: Captures[S], i: Slice[Natural]): Capture[S]` and `proc `[]`[S](cs: Captures[S], i: HSlice[Natural, BackwardsIndex]): Capture[S]` should work |
08:30:36 | Zevv | *should* work, yes |
08:30:56 | FromDiscord | <Elegantbeef> Could it been an iterator you were trying? |
08:31:10 | Zevv | i have no idea |
08:31:22 | PMunch | Zevv, haha yes I remember struggling with those myself at some point |
08:31:36 | PMunch | There are (or at least was) some dragons there |
08:31:38 | FromDiscord | <Elegantbeef> Well if it doesnt work anymore ping me and i'll look into it |
08:31:52 | FromDiscord | <Elegantbeef> Well `[]` should work for an iterator now |
08:32:04 | FromDiscord | <Elegantbeef> I never ran into an bug with `[]` operators |
08:32:28 | Zevv | there is https://github.com/zevv/npeg/blob/master/src/npeg/capture.nim#L80-L87 now |
08:32:42 | Zevv | but no slices, true |
08:37:51 | Zevv | hm ok, there still is something dragoning me, the naive implementation does not work, I only get type mismatches and nim is not able to find the proper proc for doing the slice |
08:38:01 | Zevv | I'll shelve this for now, need to do $work first |
08:43:39 | PMunch | Zevv, this is apparently what it gets now: <Captures[system.char], HSlice[system.int, system.int]> |
08:43:57 | PMunch | Not sure if Slices/Hslices would cause the mistmatch |
08:44:03 | PMunch | Or if it's Natural vs. int |
08:44:29 | FromDiscord | <Elegantbeef> The natural/int shouldnt matter |
08:44:36 | Zevv | yeah, the ints was the mismatch - but I can't seem to remember why I changed the Capture type in the first place |
08:44:42 | Zevv | natrual/int does matter |
08:45:18 | Zevv | the commit message was not helpful: "refactoring captures" |
08:45:21 | Zevv | thank you Zevv |
08:45:29 | Zevv | past zevv is a bitch, sometimes |
08:45:49 | Zevv | I always tell people to put the *why* in the commit messages, not the *what* |
08:45:54 | Zevv | but for some reason, I do not do as I preach |
08:46:59 | PMunch | It looks like you wanted better error messages |
08:48:11 | Zevv | i guess i did :) |
08:49:19 | FromDiscord | <Elegantbeef> Ah the generic first parameter is causing an weird behaviour |
08:50:58 | FromDiscord | <Elegantbeef> Ah guess i was wrong Natural does cause issues due to the slice creation |
08:51:20 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3P1b for posterity this seems to work fine |
08:51:28 | Zevv | while you're at it, could you fix PMunch's issue and PR it :) |
08:53:21 | FromDiscord | <Elegantbeef> I spose |
08:53:21 | FromDiscord | <Elegantbeef> Not doing anything else atm |
08:53:27 | Zevv | hehe |
08:56:35 | FromDiscord | <Elegantbeef> I have 0 clue how to test this though |
08:57:05 | PMunch | But now you have to deref Elegant :( |
08:57:23 | FromDiscord | <Elegantbeef> No |
08:57:44 | FromDiscord | <Elegantbeef> `proc `[]`[S](cs: Captures[S], slice: HSlice[int, BackwardsIndex] or Slice[int]): Captures[S] = Captures[S](capList: cs.s[slice])` should be it |
08:58:48 | FromDiscord | <Elegantbeef> I have 0 idea the API here so i dont know how to fix it nor test it |
08:58:52 | FromDiscord | <Elegantbeef> So i'll just leave it with pmunch |
09:00:16 | PMunch | I was thinking something like this: https://play.nim-lang.org/#ix=3P1c |
09:00:42 | PMunch | But not entirely sure if returning a seq[Capture[S]] is the right way to go |
09:00:46 | FromDiscord | <Elegantbeef> I mean i'm looking at Zevv's code |
09:00:58 | FromDiscord | <Elegantbeef> I dont know the API so i can only copy it based of what `[]` does |
09:01:06 | PMunch | You do lose the Captures bit |
09:01:12 | FromDiscord | <Elegantbeef> I have 0 clue what it should do or how it should behave |
09:05:04 | * | jjido joined #nim |
09:31:29 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
09:54:42 | NimEventer | New thread by Drkameleon: NImScript task and using a shebang line, see https://forum.nim-lang.org/t/8881 |
10:36:40 | * | Vladar joined #nim |
11:09:51 | NimEventer | New post on r/nim by mavavilj: Any place where we could focus on comparing how Nim does or does not replace Java/C#?, see https://reddit.com/r/nim/comments/snhp05/any_place_where_we_could_focus_on_comparing_how/ |
12:09:04 | FromDiscord | <haxscramper> sent a long message, see http://ix.io/3P1I |
12:09:53 | FromDiscord | <haxscramper> (edit) "http://ix.io/3P1I" => "http://ix.io/3P1J" |
12:12:17 | FromDiscord | <haxscramper> the "good error message" request for the compiler is a multi-month refactoring at best |
12:26:36 | * | jjido joined #nim |
12:42:23 | FromDiscord | <Clonkk> Okay, I didn't know that. I thought the information was abstracted and the formatted (that would have made sense conceptually)↵(@haxscramper) |
12:46:37 | FromDiscord | <haxscramper> Yes, that would ceratinly make a lot more sense |
12:47:47 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3P1T |
12:47:47 | FromDiscord | <haxscramper> format strings in-place |
12:56:03 | FromDiscord | <rishav> sent a code paste, see https://play.nim-lang.org/#ix=3P1Y |
12:57:09 | FromDiscord | <haxscramper> `var` in arguments means that parameter is mutable |
12:57:53 | FromDiscord | <haxscramper> `var ps: ParseStack` is a statement declaring mutable variable, `(ps: var ParseStack)` is an mutable argument |
12:59:30 | FromDiscord | <rishav> Thank! |
12:59:36 | FromDiscord | <rishav> (edit) "Thank!" => "Thanks!" |
13:25:59 | * | krux02 quit (Remote host closed the connection) |
13:47:02 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:47:27 | * | jmdaemon quit (Ping timeout: 256 seconds) |
14:12:13 | * | vicfred joined #nim |
14:32:48 | * | Vladar quit (Quit: Leaving) |
14:43:06 | * | arkurious joined #nim |
15:07:40 | nixfreaknim[m] | I want to find all vowels in a string , with C I can just call char but how do I do that with nim |
15:10:13 | nixfreaknim[m] | so basically I create an echo asking for a string then use readLine to scanf the string and use a case statement to look for the vowels |
15:12:19 | FromDiscord | <xx_ns> maybe use find? |
15:12:23 | FromDiscord | <xx_ns> https://nim-lang.org/docs/strutils.html#find,string,set%5Bchar%5D,Natural,int |
15:14:28 | nixfreaknim[m] | hmm , is there no other way to do this without a builtin function ? |
15:16:16 | FromDiscord | <xx_ns> I mean there's loads of ways |
15:16:45 | FromDiscord | <xx_ns> you iterate over each character in the string and see if it's in your predefined set of wovels for example |
15:18:20 | FromDiscord | <xx_ns> see the second example here |
15:18:22 | FromDiscord | <xx_ns> https://nim-lang.org/docs/sequtils.html |
15:20:42 | * | PMunch quit (Quit: Leaving) |
15:22:24 | * | nrds quit (Remote host closed the connection) |
15:40:09 | * | jjido joined #nim |
15:44:15 | * | jjido quit (Client Quit) |
15:47:39 | FromDiscord | <eqf0> Why can't you do it the same way as in C?↵(<@709044657232936960_nixfreaknim=5b=4datrix=5d>) |
15:50:59 | FromDiscord | <huantian> Yeah you can just iterate though each character in the string and check if it’s a vowel |
15:51:43 | * | nrds joined #nim |
15:57:04 | NimEventer | New post on r/nim by Familiar_Ad_8919: apparently summing floats as part of tuples is a sin, see https://reddit.com/r/nim/comments/snnh4t/apparently_summing_floats_as_part_of_tuples_is_a/ |
16:02:02 | FromDiscord | <Rika> ??? |
16:06:33 | FromDiscord | <huantian> I wonder what that post was about lmao |
16:09:35 | nixfreaknim[m] | <FromDiscord> "<huantian> Yeah you can just..." <- every time i do that I get mismatch string and char |
16:10:04 | FromDiscord | <huantian> Are you for looping? |
16:10:51 | nixfreaknim[m] | yes , then use a case statement |
16:12:05 | FromDiscord | <xx_ns> can you post your code on play.nim-lang.org |
16:13:41 | nixfreaknim[m] | https://play.nim-lang.org/#ix=3P37 |
16:14:40 | nrds | <Prestige99> https://play.nim-lang.org/#ix=3P38 ? |
16:17:49 | nixfreaknim[m] | yeah that doesn't work , I have tried thtat |
16:17:53 | nixfreaknim[m] | s/thtat/that/ |
16:18:08 | nixfreaknim[m] | /Users/aaronm/.env/nim/practice/vowels.nim(5, 10) Error: type mismatch: got <char, char> |
16:18:26 | nrds | <Prestige99> It works in the playground, what are you trying to do? |
16:18:51 | nixfreaknim[m] | vowels.nim(5, 10) Error: type mismatch: got <char, char> |
16:19:13 | nixfreaknim[m] | am I missing a module ? |
16:20:01 | nrds | <Prestige99> show your code |
16:21:25 | nixfreaknim[m] | yeah thats not search through the string to find the vowels though |
16:22:06 | nrds | <Prestige99> I'm not sure what you want to do, add all the vowels to a seq or something? |
16:22:23 | nixfreaknim[m] | ok , I thought you had to do of 'a' in volume |
16:22:30 | nixfreaknim[m] | s/volume/vowel:/ |
16:22:47 | nixfreaknim[m] | its just of 'a': |
16:24:53 | nixfreaknim[m] | ok so you can't use "in" in a case statement |
16:25:25 | FromDiscord | <xx_ns> what would that even do? |
16:26:11 | FromDiscord | <xx_ns> case statements match a value against different cases... |
16:53:11 | NimEventer | New thread by Tubbs: Webscrape, see https://forum.nim-lang.org/t/8882 |
16:54:55 | * | jjido joined #nim |
17:11:22 | * | PMunch joined #nim |
17:18:06 | FromDiscord | <TurtleP> sent a long message, see http://ix.io/3P3s |
17:24:35 | FromDiscord | <Clonkk> Have you tried https://nim-lang.org/docs/parsecfg.html ? INI and Toml syntax are mostly identical↵(@TurtleP) |
17:26:21 | FromDiscord | <TurtleP> I haven't |
17:26:44 | PMunch | Uuh, I'd advise using anything but a TOML parser for parsing TOML files.. |
17:27:29 | FromDiscord | <Clonkk> Is there some wierd specificity to toml ?↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
17:27:36 | FromDiscord | <TurtleP> I think their point was more "try using an INI file instead because this is easier" |
17:27:42 | PMunch | You could probably write a macro that tries to read the fields of the objects you pass in from the runtime-parsed TOML file |
17:27:46 | FromDiscord | <Clonkk> Well if it's just config you want, then yeah |
17:27:47 | Amun-Ra | Clonkk: indentation, array, etc. |
17:28:01 | FromDiscord | <Clonkk> Yeah but are you using those ?↵(<@709044657232936960_=41mun-=52a=5b=49=52=43=5d>) |
17:28:10 | PMunch | Ooh there's plenty |
17:28:29 | PMunch | And I would know, I'm the one who rewrote the TOML parser |
17:29:14 | FromDiscord | <TurtleP> hmm.. I mean afaik I don't need anything specific about the TOML format to use it |
17:29:23 | FromDiscord | <TurtleP> versus a regular INI file, but idk |
17:29:41 | PMunch | INI files are terrible, use TOML |
17:29:48 | PMunch | Do you have a sample I could work with? |
17:29:55 | FromDiscord | <TurtleP> toml file? |
17:30:37 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
17:31:00 | PMunch | Yes |
17:31:07 | FromDiscord | <TurtleP> <https://github.com/lovebrew/lovebrew/blob/dev/next/src/data/resources/lovebrew.toml> |
17:31:14 | FromDiscord | <TurtleP> this is the toml file I'm using |
17:31:21 | FromDiscord | <Clonkk> Terrible is a bit strong. INI is nice when you need something simple.↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
17:31:55 | PMunch | Well apart from that INI isn't really one format, so it's terrible to write a parser for that handles anything but a single format |
17:32:12 | PMunch | TOML is essentially INI properly specified with a couple added niceties |
17:32:57 | FromDiscord | <Clonkk> It looks simple enough. I'm fairly confident, you should be able to parse it with `std/parsecfg`↵(@TurtleP) |
17:33:47 | FromDiscord | <Clonkk> That's the one ? https://github.com/NimParsers/parsetoml↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
17:34:50 | PMunch | Yes |
17:35:02 | PMunch | @TurtleP, just give me a minute, I'll whip you up something nice |
17:35:08 | FromDiscord | <TurtleP> aight |
17:35:48 | FromDiscord | <TurtleP> cause I might rearrange this toml file a tiny bit, so hopefully whatever you come up with will be generic :p |
17:35:57 | PMunch | It will be |
17:44:46 | * | pro joined #nim |
17:45:03 | nixfreaknim[m] | Yeah I need to read more about that |
18:02:31 | nixfreaknim[m] | ahh in only works in collections |
18:02:51 | nixfreaknim[m] | let collection = {'a', 'x', 'r'} |
18:02:51 | nixfreaknim[m] | assert 'a' in collection |
18:03:04 | nixfreaknim[m] | easier to find in the book then the manual |
18:08:58 | * | Gustavo6046 quit (Quit: Leaving) |
18:14:07 | * | pro quit (Quit: pro) |
18:17:01 | PMunch | @TurtleP, here you go: http://ix.io/3P3L |
18:17:44 | FromDiscord | <TurtleP> jesus that looks complex haha |
18:17:52 | PMunch | It handles objects, nested objects, sequences, and enums |
18:17:58 | FromDiscord | <TurtleP> oooh |
18:18:00 | PMunch | But not objects in sequences I believe |
18:18:24 | PMunch | If you look at the compile-time output you can see what it does |
18:18:42 | PMunch | http://ix.io/3P3M |
18:19:29 | PMunch | It just recursively generates calls to itself until it gets to the base types it can read, then it simply outputs a statement like: `config.build.searchPath = toml["build"]["searchPath"].getStr()` |
18:20:50 | FromDiscord | <TurtleP> huh, neat |
18:22:06 | PMunch | As an exercise to the reader you can try to check that the TOML value is in fact the correct type (now it just uses a default value if it's the wrong type) |
18:22:12 | * | jjido joined #nim |
18:22:54 | PMunch | And of course handle more types |
18:23:03 | PMunch | By the way you had two misnamed fields |
18:23:35 | FromDiscord | <TurtleP> oh, heh |
18:24:06 | PMunch | config.output.asRaw was called "rawData" and config.build.searchPath was called binSearchPath |
18:24:32 | PMunch | Those will give you an error because the key doesn't exist |
18:25:06 | FromDiscord | <TurtleP> yeah, it's some breaking changes I did |
18:27:11 | * | pro joined #nim |
18:31:50 | * | pro quit (Client Quit) |
18:32:33 | FromDiscord | <TurtleP> thanks again! 🙂 |
18:32:52 | PMunch | No problem, always fun to write a small macro :) |
18:33:30 | * | PMunch quit (Quit: leaving) |
18:34:00 | FromDiscord | <TurtleP> though wouldn't it also be useful for this to be part of the `parsetoml` library? |
18:43:47 | NimEventer | New post on r/nim by _SleepingOwl: Nim for game development? What are some good frameworks & libs?, see https://reddit.com/r/nim/comments/snrgdc/nim_for_game_development_what_are_some_good/ |
20:01:38 | * | noeontheend joined #nim |
20:16:31 | * | neurocyte0917090 joined #nim |
20:25:04 | FromDiscord | <vindaar> toml is awesome |
20:51:16 | * | krux02 joined #nim |
21:09:37 | * | noeontheend quit (Ping timeout: 240 seconds) |
21:12:09 | NimEventer | New Nimble package! networkutils - Various networking utils, see https://github.com/Q-Master/networkutils.nim |
21:20:40 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:35:10 | * | jjido joined #nim |
22:03:08 | NimEventer | New thread by Tmsa04: (Linux) removeDir fails on directory without rw permission, see https://forum.nim-lang.org/t/8883 |
22:04:40 | * | lumo_e joined #nim |
22:09:02 | * | lumo_e quit (Read error: Connection reset by peer) |
22:10:00 | * | lumo_e joined #nim |
22:20:46 | * | jmdaemon joined #nim |
22:32:28 | FromDiscord | <planetis> does the docker nimlang/nim include clang? |
22:34:26 | FromDiscord | <planetis> dump question I've never used containers |
22:40:00 | euantorano | This probably doesn't get said enough, but darn does the standard library have some useful tools |
22:41:11 | euantorano | Like, I was just using `strtabs` with a format string and wondered what options there were to handle missing keys - and it turns out they can be pulled from environment variables (which, as it happens is exactly what I wanted!) and you can also specify whether to error, use a blank string, or use the variable name if still missing |
22:41:22 | euantorano | For anybody wondering, see: https://nim-lang.org/docs/strtabs.html#%25%2Cstring%2CStringTableRef%2Cset%5BFormatFlag%5D |
22:42:47 | euantorano | And `strscans` continues to be one of my favourite hidden gems, which I don't think enough people know about |
22:43:22 | FromDiscord | <Elegantbeef> strscans lovely |
22:43:32 | FromDiscord | <Elegantbeef> What's your favourite part of it? |
22:44:40 | euantorano | The sheer simplicity |
22:45:05 | euantorano | It's so easy to use if all you want to do is quickly parse some value from a string |
22:46:49 | FromDiscord | <Elegantbeef> Yay that's what i love aswell, too many people grasp for regex |
22:49:39 | FromDiscord | <Waldecir Santos> do we have any equivalent to python descriptors (https://docs.python.org/3/howto/descriptor.html) in Nim ? |
22:50:46 | FromDiscord | <Elegantbeef> are descriptors just properties? |
22:52:52 | FromDiscord | <Waldecir Santos> They are "classes" that define how the field behave. we can kind do the same overloading the operators, but I'm missing a way to set "defaults" to it |
22:53:14 | FromDiscord | <Waldecir Santos> This is a clear example: https://docs.python.org/3/howto/descriptor.html#orm-example |
22:54:10 | FromDiscord | <Elegantbeef> That's properties afaict |
22:54:48 | FromDiscord | <Waldecir Santos> Kind of yes, do you know how does models ? |
22:55:08 | FromDiscord | <Waldecir Santos> (edit) "Kind of yes, do you know how ... does" added "Django" |
22:55:16 | FromDiscord | <Elegantbeef> Npe |
22:55:32 | FromDiscord | <Waldecir Santos> This is why I'm trying to reproduce: |
22:55:40 | FromDiscord | <Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P4K |
22:56:02 | FromDiscord | <Waldecir Santos> It creates a property that also have some "porperties/options" within it |
22:56:32 | FromDiscord | <Elegantbeef> Ah i see |
22:58:20 | FromDiscord | <b4mbus> sent a code paste, see https://paste.rs/6BV |
22:58:55 | FromDiscord | <b4mbus> The compiler is very helpful and says `Error: type expected` 🙂 |
23:00:34 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3P4R here you go wald |
23:00:52 | FromDiscord | <Elegantbeef> named parameters use `=` not `:` |
23:01:04 | FromDiscord | <Elegantbeef> should be `headers = newHttpHeaders(...)` |
23:01:40 | FromDiscord | <b4mbus> yeah it does seem to compile nicely now |
23:01:42 | FromDiscord | <b4mbus> Thanks a lot 🙏 |
23:02:09 | FromDiscord | <xigoi> This is a really weird inconsistency in Nim's syntax. I always get it wrong. |
23:02:24 | FromDiscord | <Elegantbeef> It's `=` everywhere but typedefs |
23:02:37 | FromDiscord | <Elegantbeef> and constructors |
23:03:06 | FromDiscord | <xigoi> Yeah, and it's the constructors that trip me up most of the time. |
23:06:33 | FromDiscord | <Waldecir Santos> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=3P4R here you go": I need to store more data within the field `nameBacker` I'ld need something like this |
23:06:41 | FromDiscord | <xigoi> I think the Nim equivalent would be just specialized types…↵(@Waldecir Santos) |
23:07:03 | FromDiscord | <Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P4U |
23:07:06 | FromDiscord | <Elegantbeef> Well make a new type 😀 |
23:07:36 | FromDiscord | <Elegantbeef> Nim allows you to make as many types as you little heart can desire |
23:07:42 | FromDiscord | <Waldecir Santos> Yeap I know but I'm not sure how to make a "configurable" type in the type block |
23:08:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P4V |
23:08:35 | FromDiscord | <congusbongus> Char is a confusing type name |
23:09:03 | FromDiscord | <Elegantbeef> I dont disagree but i was being lazy |
23:09:05 | FromDiscord | <Waldecir Santos> I got that far, how would you use it/instantiate in a new type declaration ? |
23:09:30 | FromDiscord | <xigoi> sent a code paste, see https://paste.rs/Pg1 |
23:09:45 | FromDiscord | <Elegantbeef> Really depends what you're after |
23:10:01 | FromDiscord | <Waldecir Santos> This is what I'm missing https://play.nim-lang.org/#ix=3P4Y |
23:10:47 | FromDiscord | <Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P4Z |
23:10:56 | FromDiscord | <Elegantbeef> `LimitedString[30]` |
23:11:03 | FromDiscord | <Elegantbeef> This would be statically typed by the way |
23:11:22 | FromDiscord | <Elegantbeef> so `LimitedString[30]` cannot be assigned by a `LimitedString[20]` |
23:11:26 | FromDiscord | <xigoi> `[]` is Nim's syntax for generic types. Just like Python.↵(@Waldecir Santos) |
23:11:36 | FromDiscord | <Elegantbeef> Python has generics? |
23:12:19 | FromDiscord | <Waldecir Santos> @ElegantBeef it dosen't work https://play.nim-lang.org/#ix=3P51 |
23:12:29 | FromDiscord | <Waldecir Santos> `Error: initialization not allowed here`` |
23:12:40 | FromDiscord | <Elegantbeef> `field: LimitedString[20, 10]` |
23:13:03 | FromDiscord | <xigoi> sent a code paste, see https://play.nim-lang.org/#ix=3P52 |
23:13:37 | FromDiscord | <xigoi> sent a code paste, see https://play.nim-lang.org/#ix=3P54 |
23:17:55 | FromDiscord | <nothratal (nothratal)> sent a long message, see https://paste.rs/MfL |
23:18:17 | FromDiscord | <nothratal (nothratal)> I probably didn't understand how to evaluate at compile time |
23:18:27 | FromDiscord | <Elegantbeef> `const fileCOntent = staticRead("file.txt")` |
23:19:00 | FromDiscord | <Elegantbeef> You can do `var fileContent {.compileTime.} = staticRead("file.txt")` aswell |
23:19:12 | FromDiscord | <Elegantbeef> Depends what you're doing though |
23:20:29 | FromDiscord | <Waldecir Santos> In reply to @xigoi "Then you would do": I don't need to really do any check these values are going to be used when I need to communicate with the DB server, I'm trying to create a ORM like django on top of nim, that is my goal |
23:21:14 | FromDiscord | <Waldecir Santos> I need either a way to "instantiate" the property in the type declaration block or create a type with "internal values" |
23:21:57 | FromDiscord | <Waldecir Santos> I think that the only way right would be to create a macro with a custom block for model declaration and with that I can inject some procs to handle this at run time |
23:23:15 | FromDiscord | <Waldecir Santos> or I can probably create something like a "procvar" that could work, hmmmm |
23:23:20 | FromDiscord | <Elegantbeef> You can use generics to instantiate it |
23:23:34 | FromDiscord | <Elegantbeef> Like there isnt much reason to use macros here afaict |
23:28:00 | FromDiscord | <Waldecir Santos> Sorry I don get it, can you show me what you mean ? |
23:29:24 | FromDiscord | <nothratal (nothratal)> thanks all, all nice ideas, but I stick to the const-version. Just read that const enforces compile time evaluation |
23:29:43 | FromDiscord | <Elegantbeef> I mean i need a more elaborate example of what you're after |
23:29:57 | FromDiscord | <Elegantbeef> I'm a dullard so i can only have understand you want to put restrictions on types |
23:30:01 | FromDiscord | <Elegantbeef> half understand |
23:31:15 | FromDiscord | <nothratal (nothratal)> I just wanted to embed the content of a file into the code as string, so it doesn't need to be present at runtime. |
23:31:23 | FromDiscord | <Elegantbeef> Not you |
23:31:25 | FromDiscord | <Elegantbeef> Wald |
23:31:30 | FromDiscord | <nothratal (nothratal)> 😃 |
23:31:32 | FromDiscord | <nothratal (nothratal)> sorry |
23:31:58 | FromDiscord | <Waldecir Santos> @ElegantBeef No I don't want to add restrictions I want types with Hidden values so I can use to build the DB query/tables |
23:32:12 | FromDiscord | <Waldecir Santos> like in here: https://docs.djangoproject.com/en/4.0/topics/db/models/#quick-example |
23:42:23 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3P59 |
23:42:28 | FromDiscord | <Elegantbeef> I dont know this seems like what you'd want |
23:42:37 | FromDiscord | <Elegantbeef> I dont know the actual API so not a clue |