00:16:26 | FromDiscord | <Alea> sent a code paste, see https://play.nim-lang.org/#ix=3xuE |
00:18:59 | FromDiscord | <RattleyCooper> Can you escape the quotes? `"\"src/nanovg.c\""` |
00:20:55 | FromDiscord | <Alea> no that seems to cause some other issue https://media.discordapp.net/attachments/371759389889003532/882057322816503848/unknown.png |
00:24:40 | * | watzon1 joined #nim |
00:24:58 | FromDiscord | <RattleyCooper> Escapes and `strformat` don't like to play together |
00:25:14 | FromDiscord | <RattleyCooper> You may need to escape the quotes outside the `fmt` |
00:25:51 | FromDiscord | <RattleyCooper> Beyond that I'm not sure how to do it |
00:28:46 | FromDiscord | <impbox [ftsf]> try using & instead of fmt |
00:28:47 | FromDiscord | <Alea> sent a code paste, see https://play.nim-lang.org/#ix= |
00:29:34 | FromDiscord | <Alea> do I need the c lib installed for this? |
00:29:51 | FromDiscord | <Alea> It kind of seemed like the nim version came with the c version packaged |
00:30:56 | FromDiscord | <impbox [ftsf]> how did you install nim? |
00:31:26 | FromDiscord | <impbox [ftsf]> if you can build with nim you've probably got a c build environment set up |
00:32:26 | FromDiscord | <Alea> sent a code paste, see https://play.nim-lang.org/#ix=3xuF |
00:32:35 | FromDiscord | <Alea> which makes it seem like something on the c side is missing |
00:33:25 | FromDiscord | <impbox [ftsf]> it is, the linker can't find that function |
00:33:49 | FromDiscord | <impbox [ftsf]> could be you're not linking to the library that contains it |
00:34:45 | * | watzon1 quit (Quit: watzon1) |
00:35:05 | * | watzon joined #nim |
00:35:51 | FromDiscord | <Alea> The function seems to be defined in one of the packaged .h files |
00:36:09 | FromDiscord | <Alea> is there something specific I need to compile with to link it? |
00:37:19 | FromDiscord | <impbox [ftsf]> i'm not familiar with that library, are you using nim-nanovg? |
00:37:37 | FromDiscord | <Alea> yeah |
00:39:40 | FromDiscord | <impbox [ftsf]> can you build the demo? |
00:40:44 | FromDiscord | <Alea> installed through nimble, so I haven't got the whole repo cloned |
00:41:12 | FromDiscord | <Alea> but I'll say no because I just copied out a section of the demo to test |
00:41:23 | FromDiscord | <Alea> so if that doesn't work... |
00:42:18 | FromDiscord | <impbox [ftsf]> i'd clone the repo and try running `nimble examples` as suggested and see if that works |
00:42:57 | FromDiscord | <Bren> What is the simplest way to use regex in a conditional? |
00:43:26 | FromDiscord | <impbox [ftsf]> (edit) "i'd clone the repo and try running `nimble examples` as suggested and see if that works ... " added "(looks like it's `nimble examplesGL3` now" |
00:44:13 | FromDiscord | <impbox [ftsf]> @bren what is the condition you want to check? |
00:44:46 | FromDiscord | <Elegantbeef> as someone that avoids regex, what's the pattern? |
00:44:47 | FromDiscord | <Elegantbeef> Also which regex |
00:47:11 | FromDiscord | <Bren> sent a code paste, see https://play.nim-lang.org/#ix=3xuJ |
00:47:30 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xuK |
00:48:41 | FromDiscord | <impbox [ftsf]> `if "ABCD1234".match(re"[a-zA-Z0-9]{8}").isSome:` |
00:49:19 | FromDiscord | <Bren> what about false |
00:49:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3xuM |
00:49:28 | FromDiscord | <Elegantbeef> Atleast i think `{8}` is length |
00:49:42 | FromDiscord | <impbox [ftsf]> @bren `if not ...` |
00:49:48 | FromDiscord | <impbox [ftsf]> or `.isNone` |
00:49:55 | FromDiscord | <Bren> cool sorry |
00:50:02 | FromDiscord | <Elegantbeef> `isNone` is the better way |
00:50:24 | FromDiscord | <impbox [ftsf]> or add an else section |
00:50:40 | FromDiscord | <Bren> That is why I asked |
00:50:40 | FromDiscord | <Bren> thank you |
00:51:56 | FromDiscord | <impbox [ftsf]> hmm are static res compiled at compiletime i wonder? |
00:52:08 | FromDiscord | <Elegantbeef> I'm going to go find duct tape so i can prevent myself insulting regex for a bit 😀 |
00:52:23 | FromDiscord | <Elegantbeef> `re` cannot be used at CT |
00:52:54 | FromDiscord | <Elegantbeef> nim regex is what you'd use for compile time |
00:53:42 | FromDiscord | <impbox [ftsf]> i mean, compiling the re at compile time to use at runtime |
00:54:08 | FromDiscord | <impbox [ftsf]> _doesn't really care since they don't use re much_ |
00:54:18 | FromDiscord | <Elegantbeef> !eval import std/nre; const match = re"Hello" |
00:54:20 | NimBot | Compile failed: /playground/nim/lib/impure/nre.nim(280, 25) Error: cannot 'importc' variable at compile time; compile |
00:54:31 | FromDiscord | <impbox [ftsf]> but i imagine it'd be handy if you used regular expressions a lot for say a webserver or something |
01:15:14 | FromDiscord | <RattleyCooper> Ok, so my Rpi4 version of Nim throws this error when I try to use `netty`. The conversion of a `uint32` to `int` is invalid for some reason? |
01:15:23 | FromDiscord | <RattleyCooper> `Error: conversion from uint32 to int is invalid` |
01:15:51 | FromDiscord | <Elegantbeef> is the rpi4 64 bit? |
01:15:56 | FromDiscord | <RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3xuS |
01:16:28 | FromDiscord | <RattleyCooper> The chip is but I have 32bit os installed bc apparently the official 64bit os isn't really working well |
01:16:48 | FromDiscord | <Elegantbeef> Well then there is your issue uint32.high \> int32.high |
01:17:07 | FromDiscord | <RattleyCooper> Ah, is there a way to update the code so it can work on 32bit and 64bit? |
01:17:30 | FromDiscord | <Elegantbeef> `.int64` instead of `int32` |
01:17:45 | * | neurocyte3 joined #nim |
01:17:45 | * | neurocyte3 quit (Changing host) |
01:17:45 | * | neurocyte3 joined #nim |
01:17:54 | FromDiscord | <RattleyCooper> instead of `uint32` or in place of the `int`? |
01:19:57 | * | neurocyte quit (Ping timeout: 250 seconds) |
01:19:57 | * | neurocyte3 is now known as neurocyte |
01:21:53 | FromDiscord | <Elegantbeef> in place of `int` |
01:25:14 | FromDiscord | <RattleyCooper> `reactor.r.rand(uint32.high.int64).uint32` now throws `conversion from int64 to Natural is invalid` |
01:26:53 | FromDiscord | <impbox [ftsf]> use int32 instead of int64 |
01:27:17 | FromDiscord | <impbox [ftsf]> does `reactor.r.rand(uint32.high).uint32` work? |
01:27:22 | FromDiscord | <RattleyCooper> It's weird bc that throws the same error |
01:27:24 | FromDiscord | <RattleyCooper> `conversion from uint32 to int32 is invalid` |
01:27:26 | FromDiscord | <RattleyCooper> Let me see |
01:27:30 | FromDiscord | <impbox [ftsf]> sorry yes my mistake |
01:28:10 | FromDiscord | <RattleyCooper> Conversion to Natural is invalid. wth? lol |
01:28:39 | FromDiscord | <impbox [ftsf]> what's the full error? |
01:28:51 | FromDiscord | <Elegantbeef> natural is `high(int)` |
01:29:05 | FromDiscord | <RattleyCooper> /home/pi/.nimble/pkgs/netty-0.2.0/netty.nim(108, 24) Error: conversion from uint32 to Natural is invalid |
01:29:15 | FromDiscord | <Elegantbeef> do yourself a favour and do `rand(0u32..uint32.high)` |
01:30:11 | FromDiscord | <RattleyCooper> Hey, that worked! |
01:31:26 | FromDiscord | <RattleyCooper> Thanks for the help guys! |
01:31:36 | FromDiscord | <Elegantbeef> you also could do `rand(uint32)` |
01:34:05 | * | Pyautogui joined #nim |
01:38:17 | FromDiscord | <Bren> Whats a way I can get a random string of `[a-zA-Z0-9]` chars should I have some runes and select them with random until I get the length or is there a better way? |
01:41:34 | FromDiscord | <Elegantbeef> Here you go https://play.nim-lang.org/#ix=3xuX |
01:41:56 | FromDiscord | <impbox [ftsf]> https://play.nim-lang.org/#ix=3xuY |
01:42:02 | FromDiscord | <Elegantbeef> That uses the global state of course |
01:42:35 | FromDiscord | <Elegantbeef> Cmon impbox be quicker/cooler 😛 |
01:42:46 | FromDiscord | <impbox [ftsf]> at least mine gives different results each time =p |
01:43:07 | FromDiscord | <Elegantbeef> Hey i'm not going to call randomize unless it's needed 😛 |
01:44:03 | * | arkurious quit (Quit: Leaving) |
01:53:23 | * | Pyautogui quit (Quit: Connection closed) |
01:55:20 | FromDiscord | <RattleyCooper> Is there a big performance impact of setting the seed the random number generator? |
01:56:09 | FromDiscord | <impbox [ftsf]> no, but you should probably do it just once at the start of your app |
01:57:20 | FromDiscord | <RattleyCooper> Well in my procedural generation stuff I hash the coordinates of a tile and use it as an rng seed then roll a number between 0 and 1 |
01:57:30 | FromDiscord | <RattleyCooper> For choosing tiles to spawn trees |
01:57:45 | FromDiscord | <RattleyCooper> That way it's always the same 😛 |
01:57:54 | FromDiscord | <RattleyCooper> and I don't have to save the coordinates to a file |
01:58:04 | FromDiscord | <impbox [ftsf]> you could just do it once at the start of your procgen |
01:58:10 | FromDiscord | <impbox [ftsf]> with the procgen seed |
01:58:12 | FromDiscord | <impbox [ftsf]> rather than per tile |
01:58:15 | FromDiscord | <RattleyCooper> No, because if you wander back into the area |
01:58:20 | FromDiscord | <impbox [ftsf]> as long as you do each tile in the same order |
01:58:21 | FromDiscord | <cabboose> oh god I scrolled up too far and saw some python code |
01:58:21 | FromDiscord | <RattleyCooper> It will be different then the initial load |
01:58:22 | FromDiscord | <cabboose> vomit |
01:58:24 | * | auxym_ quit (Ping timeout: 244 seconds) |
02:00:15 | FromDiscord | <impbox [ftsf]> yeah that works, for that kind of thing i'd probably use a noise algorithm that takes a coordinate as input and returns a float |
02:00:47 | FromDiscord | <impbox [ftsf]> you set the seed for the noise once, then you can sample it at any point to get your output |
02:00:52 | FromDiscord | <RattleyCooper> In reply to @impbox "as long as you": Yeah, when I did my version I only had simplex noise to work with |
02:01:18 | FromDiscord | <RattleyCooper> So I either had to calculate a bunch of distances to keep the trees separated or just set the rng seed |
02:02:33 | FromDiscord | <RattleyCooper> but that was in godot. I want to try again with different noise algorithms bc I know they exist for placing trees. |
02:03:01 | FromDiscord | <impbox [ftsf]> for placing things like that check out possion disc sampling |
02:03:19 | FromDiscord | <impbox [ftsf]> (edit) "possion" => "poisson" |
02:03:20 | FromDiscord | <RattleyCooper> Gotcha! |
02:04:09 | FromDiscord | <impbox [ftsf]> combine that with simplex or perlin noise |
02:04:37 | FromDiscord | <RattleyCooper> Yeah, get some biome action going. |
02:05:39 | FromDiscord | <impbox [ftsf]> could do voronoi regions to define biome boundaries |
02:05:48 | FromDiscord | <impbox [ftsf]> lots of cool tools to play with in procgen |
02:06:34 | FromDiscord | <RattleyCooper> Never heard of that |
02:06:52 | FromDiscord | <RattleyCooper> I found poisson disk implementation in nim |
02:06:53 | FromDiscord | <RattleyCooper> https://github.com/nonvirtualthunk/nledgine/blob/f6329e8727864715dedc0b9256c81a4685b18cea/src/core/poisson_disk.nim |
02:10:40 | FromDiscord | <impbox [ftsf]> http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ |
02:13:46 | FromDiscord | <RattleyCooper> Oh nice, I am going to check this out right now 😄 |
02:45:40 | FromDiscord | <retkid> anyway to send and receive without hosting 2 servers? |
02:50:03 | FromDiscord | <impbox [ftsf]> you only need one server and one client? |
02:50:07 | FromDiscord | <impbox [ftsf]> or just two clients peer to peer |
02:53:37 | FromDiscord | <retkid> I've been running a server on bothsides and encountering kernel issues |
02:53:38 | FromDiscord | <retkid> :\ |
02:54:35 | * | sagax quit (Excess Flood) |
02:54:36 | FromDiscord | <impbox [ftsf]> which issues? |
02:55:05 | FromDiscord | <Elegantbeef> I'd wager trying to listen on the same socket as they're hosting on |
02:55:16 | FromDiscord | <retkid> its not a same socket issue |
02:55:29 | FromDiscord | <retkid> running multiple servers on the same IP in the same process |
02:55:36 | FromDiscord | <retkid> either way it wasn't needed |
02:55:50 | FromDiscord | <impbox [ftsf]> by server do you mean listening socket? |
02:56:13 | FromDiscord | <retkid> is there 1 socket per process |
02:56:15 | FromDiscord | <retkid> if so, yes |
02:56:39 | FromDiscord | <impbox [ftsf]> i don't know what you've done so i can't say, "server" is very vague |
02:56:48 | FromDiscord | <retkid> just socket listening |
02:56:59 | FromDiscord | <retkid> basic stuff just trying to get stuff to wkork |
02:57:04 | FromDiscord | <impbox [ftsf]> you can create many sockets on the same process |
02:57:23 | FromDiscord | <impbox [ftsf]> you'd only be limited by number of open files i guess which should be in the thousands |
02:57:25 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3xv9 |
02:57:28 | FromDiscord | <retkid> (edit) "https://play.nim-lang.org/#ix=3xv9" => "https://paste.rs/e7S" |
02:57:38 | FromDiscord | <retkid> thats all i really got |
02:57:52 | FromDiscord | <impbox [ftsf]> ok, so you're using unix sockets? |
02:58:05 | FromDiscord | <impbox [ftsf]> and the socket file you're trying to open doesn't exist? |
02:58:15 | FromDiscord | <impbox [ftsf]> you'd need to create that socket file first |
02:58:31 | FromDiscord | <retkid> well, this problem only happens when i have the 2 servers running at the same time |
02:58:36 | FromDiscord | <impbox [ftsf]> or maybe you don't have permission to access it, not sure if that gets its own error |
02:58:43 | FromDiscord | <retkid> either way |
02:58:46 | FromDiscord | <retkid> im doing it the wrong way |
02:59:08 | FromDiscord | <impbox [ftsf]> `/var/run/nscd/socket` is this something you created? |
02:59:19 | FromDiscord | <retkid> no |
02:59:41 | FromDiscord | <impbox [ftsf]> "Nscd is a daemon that provides a cache for the most common name service requests" |
02:59:48 | FromDiscord | <impbox [ftsf]> are you doing domain name lookups? |
03:00:28 | FromDiscord | <impbox [ftsf]> also, what's the actual problem that happens when you do what? |
03:02:35 | FromDiscord | <retkid> In reply to @impbox "are you doing domain": something to do with threading and spamming connecting but i'm looking into doing a P2P and if not i'll do threading with stdin and stdout |
03:15:33 | * | rockcavera quit (Remote host closed the connection) |
03:23:53 | * | Guest19 joined #nim |
03:24:09 | * | Guest19 quit (Client Quit) |
04:01:47 | FromDiscord | <SandwichBop> Nim looks really comfy and want to get into it, but I'm curious to why you all use it? |
04:01:56 | FromDiscord | <SandwichBop> (edit) "it?" => "it/what projects do u often use it for?" |
04:02:35 | FromDiscord | <SandwichBop> (edit) "it/what" => "over other langs in the first place? what" |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:30 | * | supakeen joined #nim |
04:08:19 | FromDiscord | <Rika> everything, because its one of the only languages i seriously enjoy writing stuff in |
04:09:20 | FromDiscord | <SandwichBop> that's great to hear, I plan on doing the same |
04:09:28 | FromDiscord | <SandwichBop> it looks so neat, just wish it were more popular |
04:09:43 | FromDiscord | <SandwichBop> don't know anyone at University that has even heard of the language 😢 |
04:09:52 | FromDiscord | <RattleyCooper> Spread the word |
04:10:01 | FromDiscord | <InventorMatt> that is why we must evangelize to everyone we meet |
04:10:01 | FromDiscord | <SandwichBop> lol imma try as soon as I get a good grasp of it first |
04:10:32 | FromDiscord | <RattleyCooper> Show them how to interop with python using nimpy |
04:10:40 | FromDiscord | <SandwichBop> I love that u can do that with nim |
04:10:55 | FromDiscord | <SandwichBop> lots of the data science peeps would use that |
04:11:12 | FromDiscord | <RattleyCooper> Yeah, everyone knows python so it should be easy to show them the benefits |
04:13:18 | FromDiscord | <Arathanis> Yeah I came to Nim because of its syntactical similarity to python. |
04:13:24 | FromDiscord | <Arathanis> That definitely helps to get people to look at it. |
04:14:02 | FromDiscord | <Rika> theres a lot of differences |
04:14:25 | FromDiscord | <RattleyCooper> And even though it's not as popular it's so much easier to read. You can look at most nim source code and figure out how to do what you need to do. |
04:15:07 | FromDiscord | <Arathanis> There are always differences but in this case its similar enough. The syntax they chose is, imo, very inspired from python and I can appreciate that. |
04:15:25 | FromDiscord | <Arathanis> In reply to @RattleyCooper "And even though it's": I think its pretty easy to read Python source code and figure out what the business is tbh. |
04:15:28 | FromDiscord | <Rika> imo its not as "python like" as you think, theres plenty of differences |
04:15:35 | FromDiscord | <Arathanis> Nim is nice cause its similar. |
04:15:40 | FromDiscord | <Rika> and many similarities are likely coincidental |
04:16:02 | FromDiscord | <RattleyCooper> Not when there are 50 classes in 15 files |
04:16:31 | FromDiscord | <RattleyCooper> It really depends on who wrote it, like in most cases.. |
04:16:48 | FromDiscord | <Arathanis> That's true of every language. |
04:17:32 | FromDiscord | <Arathanis> I don't think the similarities are coincidental at all. |
04:17:38 | FromDiscord | <Arathanis> I see them as very much intential |
04:17:45 | FromDiscord | <Arathanis> and then branching in its own direction |
04:17:48 | FromDiscord | <Arathanis> which I always think is best |
04:17:55 | FromDiscord | <Arathanis> i think its good that they took it in their own direction. |
04:18:09 | FromDiscord | <Rika> no, nim is mostly influenced by pascal and its ancestors and successors |
04:18:27 | FromDiscord | <Rika> i would be led to believe that python only influenced the indentation style blocks |
04:18:31 | FromDiscord | <Arathanis> And I like a lot of the alternative choices they made. |
04:19:41 | FromDiscord | <ElegantBeef> Cursory they look a lot a like but the overall image is two vastly different languages |
04:19:49 | FromDiscord | <Arathanis> Oh yes. |
04:20:07 | FromDiscord | <Arathanis> If they weren't wildly different there would be no point. |
04:20:08 | FromDiscord | <Arathanis> :] |
04:22:00 | FromDiscord | <Rika> there can be a point in a "new" language that isnt wildly differeent |
04:22:10 | FromDiscord | <Rika> as long as the primary change is substantial |
04:22:17 | FromDiscord | <Rika> eg. typescript |
04:23:15 | FromDiscord | <Arathanis> Sure. Though I am not sure i think that typescript is a great example. I see typescript as someone trying to add typing to JS not trying to be adjacent to JS. |
04:24:01 | FromDiscord | <Rika> well its a superset |
04:24:03 | FromDiscord | <Arathanis> Either way, love the pythonic syntax inspiration. Keeps the language expressive, and free of "character noise" |
04:24:10 | FromDiscord | <Rika> not as much as C++ is to C but it is a superset |
04:24:33 | FromDiscord | <Arathanis> C++ makes it harder to shoot yourself in the foot than C, but when you do it blow the whole leg off. |
04:24:49 | FromDiscord | <Rika> harder is debatable |
04:25:00 | FromDiscord | <impbox [ftsf]> new exciting ways to shoot yourself in the foot |
04:25:02 | FromDiscord | <Arathanis> also true, im not sure who the quote is attributed to |
04:25:08 | FromDiscord | <Arathanis> still humorous lol |
04:25:32 | FromDiscord | <SandwichBop> haven't check myself yet, but does Nim have good support on any of the JetBrain IDEs? |
04:25:37 | FromDiscord | <Rika> no |
04:25:37 | FromDiscord | <impbox [ftsf]> currently writing C and i have no idea where all these bullets are coming from, but there's not much foot left |
04:25:40 | FromDiscord | <SandwichBop> rip |
04:25:43 | FromDiscord | <Rika> support? yes |
04:25:45 | FromDiscord | <Rika> good? no |
04:26:10 | madprops | vscode support is not too bad |
04:26:26 | madprops | i'd even say it's good |
04:26:35 | FromDiscord | <SandwichBop> o that's nice to know |
04:26:46 | FromDiscord | <SandwichBop> https://plugins.jetbrains.com/plugin/15128-nim↵seems like JetBrains has their own plugin for nim, that's a good sign ig |
04:26:50 | FromDiscord | <Rika> i cannot comment on that because it has been a few months since i seriously used vsc |
04:27:06 | FromDiscord | <Rika> In reply to @SandwichBop "https://plugins.jetbrains.com/plugin/15128-nim seem": as i said, support exists but it is not good |
04:27:17 | FromDiscord | <SandwichBop> what do you use Rika? |
04:27:21 | FromDiscord | <Rika> neovim |
04:27:30 | FromDiscord | <SandwichBop> lol should had remembered, vim prolly best bet |
04:31:03 | FromDiscord | <SandwichBop> sorry, last dumb question, anyone know how well nim runs on apple sillicon? (if it doesn't, I'll just dev on windows) |
04:32:17 | FromDiscord | <SandwichBop> (edit) "sillicon?" => "sillicon (seems like based the github only x86, x86_64 and ppc64 work on mac but maybe people have tried apple silicon)?" |
04:37:17 | FromDiscord | <xflywind> > Just like our devel branch, v1.4.8 is built using csources_v1, which means you can use it on Apple M1 chips. |
04:37:21 | FromDiscord | <xflywind> https://forum.nim-lang.org/t/8031 |
04:37:55 | FromDiscord | <xflywind> see also https://github.com/nim-lang/Nim/issues/16211 |
04:38:47 | FromDiscord | <SandwichBop> awesome, that's so great to know :nim1: |
04:57:40 | FromDiscord | <garett> Is there a convenient way to infer the type of a proc or var? Something akin to gcc/clang typeof()? |
04:58:27 | FromDiscord | <impbox [ftsf]> `typeof` |
04:58:40 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/manual.html#special-types-typeof-operator |
05:00:21 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://paste.rs/7U5 |
05:09:53 | * | watzon quit (Remote host closed the connection) |
05:09:58 | FromDiscord | <garett> Thank you, impbox! |
05:10:12 | * | watzon joined #nim |
05:10:58 | NimEventer | New thread by Puruneko: Can't run on UNC path, see https://forum.nim-lang.org/t/8383 |
05:11:00 | FromDiscord | <impbox [ftsf]> np, keep in mind typeof gives the _compile time type_, not the runtime type |
05:12:55 | * | ozzz joined #nim |
05:25:17 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
06:14:46 | Gustavo6046 | Is there composition without the concept type? |
06:16:55 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xvx |
06:18:11 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xvy |
06:19:34 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3xvA |
06:38:17 | * | max22- joined #nim |
06:43:23 | * | PMunch joined #nim |
07:46:00 | FromDiscord | <enthus1ast> does one have a good idea how to detect/guess an unknown source encoding of a dataset?↵I already tried to loop through all encodings in "encodings" and convert from every to ut-8 to maybe identify the source encoding, but yeah, no sucess.↵↵Bia\\u00c5\\u0082ystok-Krywlany Airport -\> Białystok-Krywlany Airport |
07:46:45 | FromDiscord | <enthus1ast> and i do not know unicode enough to make a more educated guess |
07:55:09 | FromDiscord | <enthus1ast> it is oc. possible that the source dataset is rubbish... |
08:00:08 | PMunch | Well it's hard to just detect |
08:01:19 | PMunch | But that encoding seems to be UTF-8 |
08:01:35 | PMunch | ł is 0xC5 0x81 in UTF-8 |
08:04:03 | PMunch | @enthus1ast |
08:06:11 | FromDiscord | <enthus1ast> mhh |
08:17:03 | FromDiscord | <enthus1ast> it seems this is the solution\:↵`echo convert(ss, "iso-8859-1", "utf-8")` |
08:18:25 | FromDiscord | <enthus1ast> it is indeed utf-8 but somehow wrongly encoded |
08:20:46 | PMunch | Is it actually 0x00 0xC5 0x00 0x82? |
08:24:03 | FromDiscord | <enthus1ast> this gives the wrong result |
08:27:15 | FromDiscord | <enthus1ast> another option would be to replace `\u00` with `\x` but convert from "utf-8" to "iso-8859-1" result in correct utf-8 |
08:28:54 | FromDiscord | <enthus1ast> encodings are shi□ |
08:29:43 | PMunch | Haha :P |
08:36:01 | PMunch | Hmm, as a function argument is `proc` and `ptr proc` the same? |
08:37:18 | FromDiscord | <Elegantbeef> Can you even get a proc's address? |
08:37:39 | PMunch | Sure |
08:37:51 | PMunch | How else do you think it's passed as an argument? |
08:38:17 | FromDiscord | <Elegantbeef> That's not what i meant |
08:38:38 | FromDiscord | <Elegantbeef> I mean in Nim can you explictly get a proc as a `ptr proc` without casting |
08:38:49 | PMunch | I think so? |
08:39:21 | FromDiscord | <Elegantbeef> How both `addr` and `unsafeaddr` cannot be used |
08:39:24 | PMunch | Hmm, seems you can't |
08:39:26 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3xw0 |
08:39:52 | FromDiscord | <Elegantbeef> Yes you can cast anything to anything, but that wasnt the question 😀 |
08:39:53 | FromDiscord | <enthus1ast> then i guess a proc is a ptr |
08:40:23 | FromDiscord | <enthus1ast> a pointer not ptr |
08:40:56 | PMunch | The question really is what do I convert `void lruhash_traverse(struct lruhash* h, int wr, void (*func)(struct lruhash_entry*, void*), void* arg);` to in Nim |
08:42:04 | PMunch | proc lruhash_traverse(h: ptr lruhash, wr: cint, func: proc(a0: ptr lruhash_entry, a0: pointer) {.cdecl.}, arg: pointer)` I guess |
08:42:20 | PMunch | Well, `func` would have to be a different name |
08:42:21 | FromDiscord | <Elegantbeef> Yea that's what i'd go with |
08:43:29 | FromDiscord | <Elegantbeef> Wonder if the first arg could be `var lruhash` |
08:44:15 | PMunch | Hmm, possibly.. |
08:44:31 | FromDiscord | <Elegantbeef> I know it works in many cases but dont know if it's "proper" |
08:45:49 | PMunch | Would be interesting to know |
08:46:01 | PMunch | Certainly more idiomatic Nim to use var if it works |
08:53:46 | PMunch | Hmm, how do I handle a typedef to a procedure that isn't a pointer then though? |
08:54:37 | PMunch | It's obviously only ever used as a pointer type.. |
08:57:37 | * | Vladar joined #nim |
09:04:41 | PMunch | Hmm, can you do inline unions in a type definitions in Nim? |
09:05:05 | PMunch | ie: http://ix.io/3xw7/c |
09:05:45 | FromDiscord | <Elegantbeef> The union would need it's own typedef |
09:17:08 | * | flynn quit (Read error: Connection reset by peer) |
09:18:15 | * | flynn joined #nim |
09:21:37 | FromDiscord | <impbox [ftsf]> yay! I got my weird dither generator working just how i wanted |
09:22:15 | FromDiscord | <Elegantbeef> Congrats |
09:23:02 | FromDiscord | <impbox [ftsf]> horribly inefficient but it can be cached |
09:23:06 | FromDiscord | <impbox [ftsf]> https://play.nim-lang.org/#ix=3xwd |
09:23:34 | FromDiscord | <Elegantbeef> Kashae, kashae! |
09:24:14 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xwe |
09:25:19 | FromDiscord | <Rika> What does it either |
09:25:25 | FromDiscord | <Elegantbeef> Imp i will get your code snippets to have `std/` eventually |
09:25:30 | FromDiscord | <Elegantbeef> Yes rika but english |
09:25:44 | FromDiscord | <Rika> I didn’t realise I miswrote |
09:25:46 | FromDiscord | <Rika> Dither |
09:25:51 | FromDiscord | <impbox [ftsf]> the new version is more balanced =) |
09:25:52 | FromDiscord | <Rika> What does it dither |
09:26:04 | FromDiscord | <impbox [ftsf]> it's how many pixels a thing should move per frame |
09:27:38 | FromDiscord | <Elegantbeef> I'll make an issue tomorrow impbox but nico doesnt like this palette https://lospec.com/palette-list/aurora png fails for an index reason, and gpl fails due to it not using consistent seperators between numbers |
09:27:50 | FromDiscord | <Elegantbeef> "Tomorrow" is what i should've said |
09:28:10 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xwh |
09:28:55 | FromDiscord | <impbox [ftsf]> which png are you using? 1x? |
09:29:01 | FromDiscord | <impbox [ftsf]> i'll see if i can repro |
09:29:10 | FromDiscord | <Elegantbeef> 1x yea |
09:29:30 | * | max22- quit (Ping timeout: 250 seconds) |
09:29:36 | FromDiscord | <Elegantbeef> It worked previously so i imagine something changed recently to cause it but didnt hunt it down |
09:30:01 | arkanoid | is it possible with a proc pragma to generate AST or 2 procs instead of one? |
09:31:16 | FromDiscord | <Elegantbeef> You can use a pragma on a proc to do anything |
09:31:26 | arkanoid | long story short, I have tons of importc procs that all have C format "int f(arg1,arg2,return)", and I want to turn them in more idiomatic nim format |
09:31:46 | FromDiscord | <Elegantbeef> You want to make it a type definition feel free to |
09:32:15 | FromDiscord | <Rika> In reply to @arkanoid "is it possible with": I don’t think it can make two |
09:32:26 | FromDiscord | <Rika> Or can it? I forget |
09:32:30 | FromDiscord | <Rika> I recall not being able to |
09:32:38 | arkanoid | one possibility was to use proc pragma on them and use the macro to returns 2 procs: the unmodified c style importc version, and the new one with proper nim idiomatic syntax that calls the first one |
09:32:40 | FromDiscord | <Elegantbeef> a proc pragma gets the proc definition so can emit code outside of a proc statement |
09:34:13 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3xwj |
09:34:33 | FromDiscord | <Rika> Has anyone tried integrating Nim with an existing Android application code base? Would there be any different procedures to do for such a case versus a from-scratch application? |
09:34:56 | arkanoid | yeah! thanks Elegantbeef |
09:35:07 | FromDiscord | <Rika> And what resources do you refer to when doing so, I’ve never tried compiling Nim code for Android |
09:35:19 | FromDiscord | <Elegantbeef> Arkanoid taking the tedious route of writing my entire name |
09:35:31 | FromDiscord | <Elegantbeef> Impbox might be able to help with the latter part |
09:36:00 | FromDiscord | <Rika> Are there Android SDK requirements since I have a hard minimum of Android 6 |
09:36:31 | FromDiscord | <Rika> Thanks in advance lol |
09:37:50 | arkanoid | what is impbox? |
09:41:25 | FromDiscord | <Rika> Person |
09:41:31 | FromDiscord | <Rika> He is a person |
09:42:16 | arkanoid | oh! Very toolish name |
10:05:44 | FromDiscord | <impbox [ftsf]> @Rika i've made nim+android applications using the SDL2 Android base |
10:06:20 | FromDiscord | <Rika> I don’t remember if your projects are open source, if they are, are they easy to dissect for me to understand how they’re built ? |
10:15:13 | FromDiscord | <impbox [ftsf]> you can try doing a nico android build |
10:16:01 | FromDiscord | <Rika> I’m already lost lol what do you mean by such |
10:18:01 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3xwu |
10:18:37 | FromDiscord | <Rika> Okay I’ll look at such |
10:18:47 | FromDiscord | <impbox [ftsf]> if the stars align maybe you'll end up with an apk |
10:19:02 | PMunch | @Elegant, that's what I feared.. |
10:19:20 | PMunch | @impbox, ooh do you have an image of the dithering? I need to implement a ditherer soon myself |
10:19:50 | FromDiscord | <impbox [ftsf]> @PMunch it's dithering in time, so not great for an image |
10:20:02 | FromDiscord | <impbox [ftsf]> though i've done bayer dithering in nico |
10:20:18 | PMunch | Dithering in time? |
10:21:00 | FromDiscord | <impbox [ftsf]> how many pixels something should move each frame |
10:21:39 | FromDiscord | <Rika> In reply to @impbox "if the stars align": 😓 |
10:22:02 | FromDiscord | <impbox [ftsf]> @Rika i just ran it on my machine and it gave me an apk, so it's looking good |
10:22:09 | FromDiscord | <Rika> In reply to @impbox "<@392962235737047041> it's dithering in": Ah that’s cool, temporal dithering is difficult |
10:22:22 | FromDiscord | <Rika> In reply to @impbox "<@!259277943275126785> i just ran": Windows or Linux ? |
10:22:26 | FromDiscord | <impbox [ftsf]> Windows |
10:23:03 | FromDiscord | <Rika> Hmm I’m on Linux though, let’s see once I can use my desktop |
10:30:22 | FromDiscord | <linux user> rikea use linox :o |
10:32:42 | PMunch | Aah similar to the stuff I used for my masters to implement some machine-learning without floating point support |
10:34:19 | FromDiscord | <Rika> Huh? What topic are we on right now?? |
10:34:46 | FromDiscord | <Rika> Oh the temporal dithering |
10:35:08 | FromDiscord | <Rika> How the hell do you start with implementing machine learning given no floating points what the hell |
10:37:18 | FromDiscord | <impbox [ftsf]> dithering? i guess |
10:43:39 | * | max22- joined #nim |
10:43:54 | PMunch | It was a very simple kind of machine learning, nothing with neural nets or anything like that |
10:44:35 | PMunch | Basically the way I did dithering was that instead of subtracting 0.5 I subtracted 1 with 50% probability |
10:44:43 | PMunch | And similar for other fractions |
10:45:12 | PMunch | And for the random chance I basically just masked of bits of a nanoscale time |
10:48:51 | FromDiscord | <Rika> Ah I see |
10:48:55 | FromDiscord | <Rika> How well did it work |
10:49:09 | PMunch | Pretty well actually |
10:49:40 | PMunch | I used it to classify whether internet traffic was good or bad |
10:49:47 | FromDiscord | <Rika> Actually I just realised that this Android project thing I was going to do is also related to dithering but just image dithering |
10:49:53 | PMunch | Or rather normal or abnormal |
10:50:05 | PMunch | I'm going to need image dithering soon |
10:50:10 | PMunch | Probably |
10:50:14 | FromDiscord | <Rika> Normal as in not malicious? |
10:50:32 | PMunch | Normal as in whatever the network was used to seeing |
10:50:48 | FromDiscord | <Rika> In reply to @PMunch "I'm going to need": Then I should upload that program I made that dithers images to GitHub then |
10:51:03 | PMunch | Definitely |
10:51:12 | PMunch | I mean implementing one in OpenGL isn't exactly hard |
10:51:59 | FromDiscord | <Rika> Ah in my case it was implemented as a read in PNG write out PNG |
10:52:09 | FromDiscord | <Rika> But it should be easier to port given existing code lol |
10:54:09 | PMunch | What kind of dithering did you do? |
10:54:18 | FromDiscord | <Rika> All sorts of them |
10:54:37 | FromDiscord | <Rika> The ones listed on Wikipedia lol |
10:54:37 | PMunch | All sorts? |
10:55:33 | FromDiscord | <Rika> Floyd-Steinberg and Sierra are the ones I remember |
10:57:13 | PMunch | Hmm, problem is that I need to be able to dither parts of the image |
10:57:26 | PMunch | So I can't use most of the error-diffusion ones.. |
10:57:45 | FromDiscord | <Rika> Hmm what method would that use them |
10:57:47 | FromDiscord | <Rika> Then |
10:58:29 | PMunch | That's what I'm trying to figure out :P |
10:58:38 | PMunch | I mean the obvious one is a basic ordered approach |
10:59:17 | * | arkurious joined #nim |
10:59:48 | FromDiscord | <Rika> Was gonna say but that doesn’t provide good quality IMO |
11:00:00 | PMunch | Yeah quality is poor |
11:00:12 | FromDiscord | <Rika> Oh wait there’s the noise ordered one |
11:00:26 | FromDiscord | <Rika> http://cv.ulichney.com/papers/1993-void-cluster.pdf |
11:25:42 | * | flynn quit (Read error: Connection reset by peer) |
11:26:50 | * | flynn joined #nim |
11:42:24 | PMunch | Hmm, I think a little cleanup now and my clang auto-wrapping thing should be useable |
11:46:42 | * | rockcavera joined #nim |
11:46:42 | * | rockcavera quit (Changing host) |
11:46:42 | * | rockcavera joined #nim |
11:46:54 | PMunch | Is it possible to read passC and passL? |
11:47:39 | FromDiscord | <haxscramper> What do you mean "read"? |
11:47:56 | PMunch | Get the value of |
11:48:02 | PMunch | From inside my Nim program |
11:49:24 | FromDiscord | <haxscramper> No, without parsing whole module. `std/compilesettings` might have access to this, in theory https://nim-lang.org/docs/compilesettings.html |
11:49:32 | FromDiscord | <haxscramper> ` linkOptions, ## additional options passed to the linker` |
11:56:21 | FromDiscord | <trenta3> In reply to @Elegantbeef "It's simply writing code": Hi! I started trying to build some macros, but I'm having a bit of problems in understanding the error message "expression '...' has no type (or is ambiguous)".↵What does that mean? What could the problem be?↵The macro code itself is a bit long and has some context as well, but I will post it. |
11:56:55 | PMunch | Hmm, doesn't seem to give me passL or passC |
11:58:27 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xwW |
11:59:30 | FromDiscord | <haxscramper> PMunch\: then it only gives direct arguments to `nim --passl/passc` |
12:03:55 | FromDiscord | <Cark> hum so let's say i have an object type A and its ref counterpart ARef. now I have an instance of A on the stack, but i need to call a proc which requires an ARef, is there a way to do it ? |
12:04:37 | FromDiscord | <Cark> or should i go with pointers ? |
12:05:17 | FromDiscord | <Rika> In reply to @Cark "hum so let's say": Yes, make a new ref and copy the contents into it and pass to the function |
12:05:32 | FromDiscord | <Rika> Don’t go with a pointer unless you know why you need it |
12:05:56 | FromDiscord | <Rika> There’s likely a reason it takes a ref, the proc |
12:05:56 | FromDiscord | <Cark> ah but the whole point was to avoid copying |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:04 | FromDiscord | <Rika> There is no other way |
12:06:07 | FromDiscord | <Cark> i control the proc |
12:06:19 | FromDiscord | <Rika> Then why do you need a ref? |
12:06:30 | * | supakeen joined #nim |
12:06:56 | FromDiscord | <Cark> it made sense to use refs in order to avoid copying, but i can start from refs on the stack or just use ptr |
12:07:17 | FromDiscord | <Cark> i can see how making a ref out of a stack object is dangerous |
12:07:32 | FromDiscord | <Rika> You shouldn’t avoid copying unless you can measurably see there is a difference, and even then you shouldn’t change to ref just because of that… |
12:07:46 | FromDiscord | <Rika> Nim already automatically passes via pointer if it is faster for the size of the object |
12:08:18 | FromDiscord | <Cark> but if the semantics is to pass by value, there surely has some copying going on ? |
12:08:28 | FromDiscord | <Cark> (edit) "has some" => "issome" |
12:08:33 | FromDiscord | <Cark> (edit) "issome" => "is some" |
12:08:37 | FromDiscord | <Rika> Yes, but so what if there is? |
12:08:51 | FromDiscord | <Rika> Pass by reference is not always significantly faster than pass by value |
12:09:31 | FromDiscord | <Cark> ok i get that, but what if the passed object has some state that might change, and i need it reflected in the copies ? |
12:09:34 | FromDiscord | <Rika> Do you observably see the difference in speed if using one or the otherV |
12:09:43 | FromDiscord | <Rika> In reply to @Cark "ok i get that,": Use var |
12:09:44 | FromDiscord | <Cark> i'm not arguing about speed |
12:09:50 | * | max22- quit (Ping timeout: 250 seconds) |
12:10:03 | FromDiscord | <Rika> In reply to @Cark "i'm not arguing about": Yes I just sent that before I read the newest message |
12:10:11 | FromDiscord | <Cark> =) |
12:10:20 | FromDiscord | <Cark> my problem statement is ill specified |
12:10:35 | FromDiscord | <Cark> what i want is to model my application state |
12:10:49 | FromDiscord | <Rika> Okay |
12:11:13 | FromDiscord | <Cark> but i have already writen a bunch of procs that are using values rather than refs |
12:11:41 | FromDiscord | <Rika> Yeah and you can use var for mutability of regular object parameters |
12:11:42 | FromDiscord | <Cark> now it looks like one of my substates would be better specified with refs |
12:12:35 | FromDiscord | <Cark> ok i need to think a bit on that, thanks for your help |
12:12:39 | FromDiscord | <Rika> Okay |
12:13:29 | FromDiscord | <Cark> var can be seen as passing the address of the object |
12:13:34 | FromDiscord | <Cark> just like in c |
12:30:59 | FromDiscord | <Rika> Yes but you don’t need to manage it yourself |
12:42:04 | * | Helios quit (Quit: Bridge terminating on SIGTERM) |
12:42:05 | * | nixfreak_nim[m] quit (Quit: Bridge terminating on SIGTERM) |
12:42:09 | * | happycorsair[m]1 quit (Quit: Bridge terminating on SIGTERM) |
12:45:31 | * | nixfreak_nim[m] joined #nim |
12:47:28 | * | lain quit (Ping timeout: 252 seconds) |
12:48:24 | * | lain joined #nim |
12:56:34 | FromDiscord | <Rika> this is a kind of strange question |
12:56:35 | * | Helios joined #nim |
12:56:35 | * | happycorsair[m] joined #nim |
12:56:47 | FromDiscord | <Rika> are there libraries that can produce both a parser and a generator |
12:57:26 | FromDiscord | <Rika> eg. parse this format, then also write out this format |
12:57:51 | * | max22- joined #nim |
13:03:13 | PMunch | Like what binaryparse does? |
13:04:06 | * | max22- quit (Ping timeout: 256 seconds) |
13:05:06 | FromDiscord | <Rika> i guess? but text |
13:13:33 | PMunch | None that I know of |
13:14:52 | FromDiscord | <Rika> not a problem, the generation part is much easier to make i guess |
13:36:28 | * | krux02 quit (Ping timeout: 252 seconds) |
13:45:09 | FromDiscord | <pietroppeter> https://github.com/sealmove/binarylang |
13:45:12 | nrds | <R2D299> itHub: 7"Binary parser/encoder DSL" |
13:45:34 | FromDiscord | <pietroppeter> it says binary but it actually works fine with text (see tutorials by Ajusa) |
13:56:37 | * | krux02 joined #nim |
14:04:55 | * | PMunch quit (Quit: Leaving) |
14:07:58 | * | max22- joined #nim |
14:16:41 | NimEventer | New thread by Enthus1ast: Nimja; compiled and statically typed template engine (like twig or jinja2), see https://forum.nim-lang.org/t/8384 |
14:45:48 | FromDiscord | <trenta3> Sorry for insisting, can someone explain to me what does the error "expression '...' has no type (or is ambiguous)" mean? How can I diagnose the problem when the exact same printed content seems correct to me? |
14:52:20 | FromDiscord | <haxscramper> It means that expression ... has no type. Usually? Like `let varname = echo 123` |
14:52:25 | FromDiscord | <haxscramper> In your particular case you just defined a function |
14:52:33 | FromDiscord | <haxscramper> Not assigned it, and it is not written in expression form |
14:52:40 | FromDiscord | <haxscramper> `proc name()` is a declaration |
14:53:02 | FromDiscord | <haxscramper> `let callback = proc() = ...` is an expression, specifically `proc() = ...` part of it |
14:53:33 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3xxV |
14:53:59 | FromDiscord | <haxscramper> Or construct proc via `nkLambda`, or `nnkProcDef` without arguments |
14:54:07 | FromDiscord | <haxscramper> I don't remember which one it is exactly, so you need to look at treeDump for expression specifically |
14:54:12 | FromDiscord | <haxscramper> @trenta3\: |
14:55:52 | * | flynn quit (Read error: Connection reset by peer) |
14:56:57 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xxW |
14:56:59 | * | flynn joined #nim |
14:57:18 | FromDiscord | <trenta3> I honestly cannot understand exactly what you mean |
14:57:22 | FromDiscord | <haxscramper> Your macro generates statement not an expression |
14:57:30 | FromDiscord | <haxscramper> try pasting echoed code |
14:57:50 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xxX |
14:58:02 | FromDiscord | <trenta3> This is the code echoed at the end of the macro for a specific case |
14:58:18 | FromDiscord | <Rika> that is a statement |
14:58:58 | FromDiscord | <trenta3> Ouch, what would an equivalent expression be like?↵Can't I just assign a proc to a variable? |
14:59:04 | FromDiscord | <Rika> you can |
14:59:20 | FromDiscord | <Rika> what is the typedef of `Parser`? |
14:59:27 | FromDiscord | <Rika> i assume parseApply is your macro |
14:59:49 | FromDiscord | <Rika> a proc expression has the same syntax as a proc statement, just without the proc name |
15:00:08 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xy0 |
15:00:12 | FromDiscord | <Rika> remove the proc name |
15:00:22 | FromDiscord | <haxscramper> Should be sufficieng |
15:00:22 | FromDiscord | <haxscramper> Should be sufficient |
15:00:23 | FromDiscord | <haxscramper> I just provided two examples↵(@trenta3) |
15:00:31 | FromDiscord | <Rika> oh yes that works too |
15:00:42 | FromDiscord | <haxscramper> Sometimes this errors out on parsing↵(@Rika) |
15:00:44 | FromDiscord | <Rika> (hax your messages just got here now) |
15:01:00 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/eeD |
15:01:12 | FromDiscord | <haxscramper> No, I re-send it↵(@Rika) |
15:01:13 | FromDiscord | <trenta3> In reply to @Rika "remove the proc name": Thanks a lot |
15:01:21 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/8Yl |
15:01:48 | FromDiscord | <trenta3> sent a code paste, see https://paste.rs/RWE |
15:02:10 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xyf |
15:02:14 | FromDiscord | <haxscramper> At least that's a simplest fix, though it produces rather ugly `.repr()` when used |
15:02:24 | FromDiscord | <haxscramper> So I usually try to actually generate closure expression |
15:02:36 | FromDiscord | <haxscramper> But that needs more `.newTree()`, |
15:02:39 | FromDiscord | <trenta3> When removing the proc name from the quote do I get ` Error: identifier expected, but got '('` |
15:02:53 | FromDiscord | <haxscramper> Can you try the code I sent? |
15:03:20 | FromDiscord | <haxscramper> I mean the one which simply adds `parse` at the end |
15:03:43 | FromDiscord | <trenta3> sent a code paste, see https://paste.rs/ryE |
15:03:50 | FromDiscord | <trenta3> Thank! I initially did not notice the name at the end |
15:05:39 | FromDiscord | <trenta3> Now I can try to continue writing the macro.↵And I will probably have to look more carefully at the difference between statements and expressions in nim, which I find extremely different from other languages. |
15:06:37 | FromDiscord | <haxscramper> No, it is not really different, we just allow more in expressions |
15:06:52 | FromDiscord | <haxscramper> Just C-style langs don't do `if/case` expressions |
15:07:09 | FromDiscord | <haxscramper> And `block` expressions |
15:07:40 | FromDiscord | <haxscramper> Lisp/\<insert FP lang\>/Rust/ etc. have almost the same expression concepts, for `if/match/for` |
15:08:02 | FromDiscord | <haxscramper> lisp especially |
15:09:49 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xyp |
15:10:06 | FromDiscord | <trenta3> Ok, so maybe I get it: the inner `proc` is a statement. |
15:10:19 | FromDiscord | <trenta3> But then what would be an equivalent expression to return a function/proc? |
15:10:48 | FromDiscord | <trenta3> sent a code paste, see https://play.nim-lang.org/#ix=3xyq |
15:10:53 | FromDiscord | <haxscramper> Yes, procedure block is a statement, and if the last entry in block is an expression than it is returned |
15:11:19 | FromDiscord | <haxscramper> Remove `proc inc`, just `return proc()` is enoug↵(@trenta3) |
15:11:58 | FromDiscord | <trenta3> Ok thanks, this clarification was really useful |
15:12:27 | FromDiscord | <haxscramper> So the error about `(` that you got earlier was just because we can't easily determine whether random `proc` in the midle of nowhere is an expression |
15:12:49 | FromDiscord | <haxscramper> So when used in places that are clearly not expressions |
15:13:24 | FromDiscord | <haxscramper> E.g. `return, let, var, const` assign to any kind ... basically anything that is not a standalone statement |
15:13:31 | FromDiscord | <haxscramper> THen you can easily do `let a = proc()` |
15:13:45 | FromDiscord | <haxscramper> But when you do `proc()` without anything else nim tries to parse it as statement |
15:13:51 | FromDiscord | <haxscramper> Probably the only caveat |
15:14:02 | FromDiscord | <haxscramper> Python has explicit `lambda` |
15:14:03 | FromDiscord | <haxscramper> Rust has `||` for closures |
15:14:24 | FromDiscord | <haxscramper> But we reuse the same `proc()` for all encounters, which leads to this difference |
15:14:39 | FromDiscord | <trenta3> Ok, but then the error I got before was that I was returning a block generated by `quote do`? |
15:15:11 | FromDiscord | <haxscramper> You generated statemetn that was basically `StmtList[ProcDeclaration]`, and `ProcDeclaration` cannot be an expression |
15:15:33 | FromDiscord | <haxscramper> After you added `parse` at the end it became `StmtList[ProcDef, Ident]` and `Ident` can be an expression |
15:15:51 | FromDiscord | <haxscramper> So "block expression" triggers |
15:16:13 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#statements-and-expressions-block-expression |
15:16:38 | FromDiscord | <trenta3> Ok, now I get it. So I could also take my `result` and extract just the ProcDeclaration using `result = result[0]` and return that? |
15:16:43 | FromDiscord | <haxscramper> The manual is a bit to dry on examples in this case, but basically `Stmt[ ????, Ident/Lit/Other-Expr]` can be expr |
15:17:00 | FromDiscord | <haxscramper> No, the ast is more involved, and proc declaration cannot be split↵(@trenta3) |
15:17:23 | FromDiscord | <haxscramper> Because again, `ProcDef` (I used wrong name the first time) is not an expression |
15:17:38 | FromDiscord | <haxscramper> Proc/Iterator/Macro/Type/Const/Let/Var declarations are not expressions |
15:17:48 | FromDiscord | <trenta3> In reply to @haxscramper "The manual is a": Yes I totally agree on this, resources on the web are scarce too for a language that is around by such a long time (compare it to the number of examples for Golang e.g.) |
15:17:52 | FromDiscord | <haxscramper> While/For statements are not expressions either |
15:18:13 | FromDiscord | <haxscramper> If/Try/Case/Block can be an expression dependoning on context |
15:18:30 | FromDiscord | <haxscramper> The context is - is it a part of bigger expression or not? |
15:18:55 | FromDiscord | <haxscramper> Enumerating all combinations will take some time but I hope you get general idea |
15:19:03 | FromDiscord | <haxscramper> @trenta3) |
15:19:20 | FromDiscord | <haxscramper> No the language to compare anything to |
15:19:26 | FromDiscord | <haxscramper> Except maybe ruse |
15:19:27 | FromDiscord | <haxscramper> rust |
15:19:28 | FromDiscord | <trenta3> In reply to @haxscramper "Enumerating all combinations will": Yes, I definitely get it |
15:20:03 | FromDiscord | <trenta3> In reply to @haxscramper "No the language to": Agree, I'm definitely not comparing the languages, just the number of examples that one can find on the web. |
15:22:19 | FromDiscord | <trenta3> But then thanks again, having places to ask for help is great |
15:26:07 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3xyw |
15:29:18 | FromDiscord | <Rika> `...[T: AnyVector3](a: T): T`? |
15:29:49 | FromDiscord | <Rika> or what you just wrote, does it not work? |
15:34:33 | FromDiscord | <Ayy Lmao> In reply to @Rika "`...[T: AnyVector3](a: T): T`?": That seems to make `V` as the value type become undeclared. |
15:34:53 | FromDiscord | <Ayy Lmao> In reply to @Rika "or what you just": When I do `typeof(a)` it's apparently `void` |
15:35:06 | FromDiscord | <Rika> concepts spicy |
15:35:43 | FromDiscord | <Ayy Lmao> Yeah I'm finding them hard to wrap my head around but I like the idea. Is anyone using them extensively? |
15:37:04 | FromDiscord | <Rika> i bet this is a bug of some sorts |
15:54:40 | FromDiscord | <Cark> sent a code paste, see https://play.nim-lang.org/#ix=3xyF |
15:54:58 | FromDiscord | <Cark> there is no r =) |
15:55:17 | FromDiscord | <Rika> look at the filename |
15:55:22 | FromDiscord | <Rika> its not your module |
15:55:53 | FromDiscord | <Cark> yeah but ".nim(32, 18) template/generic instantiation of `new` from here" which is the line with nex(ImageDataRef) |
15:56:04 | FromDiscord | <Cark> (edit) "nex(ImageDataRef)" => "new(ImageDataRef)" |
15:56:55 | FromDiscord | <Cark> what i'm trying to achieve : those init functions are returning regulare objects |
15:57:13 | FromDiscord | <Cark> and i want these to be in those refs |
15:57:29 | FromDiscord | <Cark> (edit) "regulare" => "regular" |
15:58:48 | FromDiscord | <Cark> the program works correctly despite the warning, but i can't leave a warning dangling there, there must be a correct way to do this |
16:04:48 | FromDiscord | <Rika> pmunch: I forgot, i also implemented a dither https://pippin.gimp.org/a_dither/ |
16:05:46 | FromDiscord | <Rika> actually it still recommends void and cluster for speed |
16:13:34 | FromDiscord | <Cark> from the height of my ignorance i'll call this a compiler bug and disable the warning there |
16:14:23 | FromDiscord | <gerwy> How can i read some specific place in file? |
16:14:40 | FromDiscord | <gerwy> without looping over every line |
16:16:43 | FromDiscord | <Rika> specific place as in specific byte? setposition |
16:19:35 | FromDiscord | <gerwy> i mean like, i know the line, and how many characters i want to get from it |
16:19:56 | FromDiscord | <gerwy> ah in streams? |
16:21:15 | FromDiscord | <Cark> there is no getting to a line in a text file without scanning for it, unless you have an index of some sort |
16:21:50 | * | xet7 quit (Remote host closed the connection) |
16:22:34 | * | xet7 joined #nim |
16:23:26 | FromDiscord | <Rika> "lines" do not exist in files |
16:23:33 | FromDiscord | <Rika> you need to know the exact byte |
16:23:39 | FromDiscord | <Rika> and if you dont then you need to scan the whole file |
16:23:58 | FromDiscord | <Rika> well, the file until the specific line more accurately |
16:24:05 | FromDiscord | <gerwy> and it works Thanks<3 |
16:24:27 | FromDiscord | <gerwy> In reply to @Rika "you need to know": and i know it so its working |
16:48:15 | * | Vladar quit (Quit: Leaving) |
16:50:39 | FromDiscord | <tandy> I have overloaded a function from a library i have `include`d and i get this warning `overloaded '' leads to ambiguous calls`, anything i could do to stop it? |
16:53:05 | FromDiscord | <haxscramper> Use import |
16:53:09 | FromDiscord | <Rika> are you sure what you wrote is an overload? check the types and if they are aliases |
16:53:31 | FromDiscord | <haxscramper> First solution, otherwise what is the problem you are trying to solve with `include` specifically? |
16:57:46 | FromDiscord | <tandy> i have tried another solution for now, but im using that to import types, etc |
16:59:43 | FromDiscord | <haxscramper> Using `include` is highly discoraged unless you want it's specific functionality. `import` is preferred in almost all use cases |
17:00:28 | FromDiscord | <haxscramper> And unconstrained use of `include` can easily lead to this specific error you are getting (overloaded function and ambiguous calls) |
17:00:51 | * | flynn quit (Read error: Connection reset by peer) |
17:01:59 | * | flynn joined #nim |
17:02:04 | FromDiscord | <tandy> what is its specific functionality? |
17:02:15 | FromDiscord | <haxscramper> include does dumb copy-paste of the code |
17:03:00 | FromDiscord | <haxscramper> thus you can split file into multiple small ones without need to import-export "internal" things |
17:03:26 | FromDiscord | <haxscramper> compiler uses this for `sem` implementation that would otherwise be around 15k SLOC total (\~) |
17:03:26 | FromDiscord | <tandy> oh interesting |
17:03:34 | FromDiscord | <haxscramper> Also `system` does `include` for certain parts |
17:03:49 | FromDiscord | <haxscramper> But if you do `include` anything twice it would declare it's contents twice as well |
17:03:58 | FromDiscord | <haxscramper> Because it is a dumb copy-paste |
17:05:42 | FromDiscord | <haxscramper> And if you have copy-pasted things twice, it naturally leads to ambiguous overloads, because there is actually multiple identical implementations in the same scope |
17:05:43 | FromDiscord | <haxscramper> So try `import` first, if it fails somewhere else check whether you have appropriate export markers in place |
17:07:36 | FromDiscord | <tandy> im just using it so i dont have to import something multiple times across a large codebase |
17:07:43 | FromDiscord | <tandy> so i just include it in a file where its always needed |
17:07:53 | FromDiscord | <haxscramper> Yes, that's the wrong usage |
17:07:54 | FromDiscord | <tandy> then i import that file and i can access its stuff |
17:08:08 | FromDiscord | <haxscramper> We have `import`/`export` pair for that |
17:08:53 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3xz2 |
17:09:41 | FromDiscord | <haxscramper> A little more tedious to write, but you control what is being exported etc. But mostly you need to use `import-export` because `include` is just was not meant for that |
17:13:44 | FromDiscord | <tandy> i see |
17:18:59 | FromDiscord | <tandy> i dont really know how to fix that atm, but il add it to my todo |
17:21:20 | FromDiscord | <Clonkk> What would be the "best" way to get a typedesc based on an enum value ? |
17:22:09 | FromDiscord | <haxscramper> as in `nnkSym` with `skEnumField` to `typedesc[EnumType]`? |
17:22:39 | FromDiscord | <haxscramper> Probably `getType()`, `getImpl()`, `getTypeImpl()` in random combinations will get you there after some tries |
17:22:56 | FromDiscord | <Clonkk> As in, I have a runtime integer -\> enum vamue and ideally I'd like to use a typedesc |
17:24:02 | FromDiscord | <haxscramper> I don't exactly understand what exactly you want to use typedesc for |
17:24:16 | FromDiscord | <haxscramper> Automate writing of `int -> enum` mapping? |
17:24:31 | FromDiscord | <haxscramper> Or map `int` to typedesc |
17:24:46 | FromDiscord | <deech> How do I set the Nim C++ compiler? I have both `clang` and `gcc` and want to switch between them. |
17:25:12 | FromDiscord | <Clonkk> I have a numpy array obtained from a big Nimpy black box (that can't easily be ported to Nim for now) that I convert to `pt UncheckedArray[T]` for some supported types. |
17:26:12 | FromDiscord | <Clonkk> So from a PyObject (in Nim) I can access the attributes `num` of the dtypes (which is an integer); and this enum would ideally be converted to a typedesc to be used for type dispatch / generic obect creation (if possible) |
17:26:24 | FromDiscord | <Clonkk> `when defined(cpp):`↵(@deech) |
17:26:43 | FromDiscord | <Yardanico> gcc.cpp.exe |
17:26:43 | FromDiscord | <Clonkk> To check if it exists |
17:26:44 | FromDiscord | <Clonkk> -b\:cpp for backend switch |
17:26:48 | FromDiscord | <Yardanico> and gcc.cpp.linkerexer |
17:26:49 | FromDiscord | <Yardanico> (edit) "gcc.cpp.linkerexer" => "gcc.cpp.linkerexe" |
17:27:07 | FromDiscord | <Yardanico> ah right |
17:27:10 | FromDiscord | <deech> So something like `switch("gcc.cpp.exe", "clang")`? |
17:27:11 | FromDiscord | <Yardanico> you just want to switch between clang and gcc right? |
17:27:16 | FromDiscord | <Yardanico> In reply to @deech "So something like `switch("gcc.cpp.exe",": nonono, it's not needed in your case |
17:27:25 | FromDiscord | <Yardanico> just do nim cpp --cc:clang to use clang++ |
17:27:31 | FromDiscord | <Yardanico> and nim cpp --gcc:gcc to use g++ (default) |
17:27:39 | FromDiscord | <Yardanico> (edit) "--gcc:gcc" => "--cc:gcc" |
17:28:04 | FromDiscord | <deech> Nice! Thanks! |
17:29:03 | FromDiscord | <haxscramper> In that case, you need some form of reverse mapping for enum values via manual annotations. If I understand correctly, you basically need to get "type id to typedesc" |
17:29:14 | FromDiscord | <Clonkk> Yup |
17:29:16 | FromDiscord | <Clonkk> Basically |
17:30:30 | FromDiscord | <haxscramper> In cases like these, the simplest form would be to just declare `func as(npBox: NumpyBox, target: typedesc[T]): T = npBox.unpackForTypeT(T)`. SO you can write `np[0, 2] as float` |
17:30:44 | FromDiscord | <haxscramper> But some form of manual wrapping has to be done |
17:30:59 | FromDiscord | <haxscramper> You can automate construction of the `as` using templates for example |
17:31:23 | FromDiscord | <RattleyCooper> Are the nightly builds fairly stable? Not exactly sure what to expect but want to give it a shot so I can use a couple libraries that require nim >= 1.5 . |
17:31:24 | FromDiscord | <haxscramper> And do runtime validation of the input data, to make sure it matches ID |
17:32:46 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3xz6 |
17:33:22 | FromDiscord | <haxscramper> Or `float from <numpy box>` if you want it differently |
17:34:03 | FromDiscord | <haxscramper> Usually stuff either builds and runs correctly or does not even compile↵(@RattleyCooper) |
17:34:12 | FromDiscord | <haxscramper> So there are not hidden unstable runtime footguns |
17:34:14 | FromDiscord | <Clonkk> Yeah, okay I get the gist |
17:34:59 | FromDiscord | <RattleyCooper> In reply to @haxscramper "So there are not": Thanks! |
17:35:28 | FromDiscord | <Clonkk> I was hoping I could construct something like `nnkBrakcetExpr(eqIdent "typedesc", eqIdent "int8") inside a big `case of\`\` but I can't use that as a generic |
17:45:21 | * | euantorano quit (Ping timeout: 250 seconds) |
17:45:30 | * | euantorano joined #nim |
18:07:56 | * | watzon quit (Quit: watzon) |
18:14:42 | * | watzon joined #nim |
18:15:18 | arkanoid | Is it possible to have an inner "aux" proc that is a importc? |
18:16:59 | arkanoid | I mean proc foo() =proc aux() {.importc: "foo".} aux() |
18:29:06 | FromDiscord | <haxscramper> yes, the only limitation on inner procs it that they can't be exported |
18:31:22 | * | watzon quit (Quit: WeeChat 3.2) |
18:42:08 | FromDiscord | <tandy> can you parse an int64 from a string? |
18:47:34 | * | watzon joined #nim |
18:47:50 | FromDiscord | <haxscramper> `std/strutils.parseInt()` |
18:56:09 | FromDiscord | <RattleyCooper> What's the deal with custom pragmas on a type def? If I try to turn a TypeSection/TypeDef into a statement list I get an illformed AST error even though it appears to be valid? |
18:56:15 | FromDiscord | <RattleyCooper> sent a code paste, see https://paste.rs/EjM |
18:56:59 | FromDiscord | <RattleyCooper> This works, but if you try to apply `{.t.}` to the `Bob` typeDef it errors out |
18:57:13 | FromDiscord | <RattleyCooper> `type Bob {.t.} = ref object of RootObj` |
18:57:37 | arkanoid | Thanks! |
18:58:25 | FromDiscord | <RattleyCooper> Am I missing something here? I thought that it was having issues with the pragma details not existing but even if I modify the AST to add the pragma details and make sure the type is in a `typeSection`, it still says it's illformed AST |
18:59:28 | FromDiscord | <RattleyCooper> I need to add some boilerplate code after my `typeDef`s |
19:00:04 | FromDiscord | <RattleyCooper> I'm not actually declaring types in a proc, was just doing that so I could get the full AST with the pragma in the treeRepr |
19:01:32 | * | PMunch joined #nim |
19:24:49 | * | flynn quit (Read error: Connection reset by peer) |
19:26:04 | * | flynn joined #nim |
19:59:45 | FromDiscord | <tandy> `Exception message: invalid integer: "1630429373"` |
19:59:47 | FromDiscord | <tandy> when using regular `int` |
20:00:52 | FromDiscord | <tandy> `getBiggestInt` works tho |
20:01:19 | FromDiscord | <tandy> oh it runs but it just returns 0 |
20:10:23 | * | PMunch quit (Quit: leaving) |
20:21:47 | * | watzon quit (Quit: WeeChat 3.2) |
20:38:35 | * | watzon joined #nim |
20:48:27 | * | auxym_ joined #nim |
20:51:54 | * | max22- quit (Remote host closed the connection) |
20:52:19 | * | max22- joined #nim |
20:53:26 | * | max22- quit (Remote host closed the connection) |
20:53:48 | * | max22- joined #nim |
20:56:28 | NimEventer | New thread by Oden: An equivalent to JAI's "use"?, see https://forum.nim-lang.org/t/8385 |
21:04:37 | * | auxym_ quit (Ping timeout: 245 seconds) |
21:14:27 | * | supakeen quit (Remote host closed the connection) |
21:14:50 | * | supakeen joined #nim |
21:20:10 | nixfreak_nim[m] | The files I am greping out are too large and kill my memory , I actually have to split them up then run a loop to compare them. How would I write a grep -f file file2 program like that? |
21:22:13 | FromDiscord | <Elegantbeef> iterate over each line and do it line by line instead of loading the entire file into memory |
21:25:15 | FromDiscord | <SandwichBop> is it unorthodox to use Nim for GUI work? (I can see SDL wrapper going well with Nim tho don't want to go against the grain) |
21:25:30 | FromDiscord | <SandwichBop> (edit) "grain)" => "grain, maybe there's something like Electron for Nim)" |
21:26:21 | FromDiscord | <Elegantbeef> Unorthodox? It's a programming language so i'd hope GUI isnt against the grain \:D |
21:27:22 | FromDiscord | <Elegantbeef> There are bindings for gtk, qml, webview. Then also pure nim solutions/multiplatform stuff like Nimx, Fidget, nigui(might be best to look at if you want to use windows native gui, but also want gtk on unix) |
21:27:30 | FromDiscord | <kaushalmodi> Hello, I have no background in socket or TCP/IP programming. If I want to convert this code to Nim ( https://github.com/amiq-consulting/amiq_blog/blob/master/amiq_sv_python_non_blocking_socket_communication_in_systemverilog_using_dpi_c/client.cc ), which Nim library should I start looking at? Would it be the `net` library? |
21:28:10 | FromDiscord | <kaushalmodi> Once I tackle that, I would like to also convert this Python code ( https://github.com/amiq-consulting/amiq_blog/blob/master/amiq_sv_python_non_blocking_socket_communication_in_systemverilog_using_dpi_c/server.py ) to Nim as well. |
21:29:51 | FromDiscord | <SandwichBop> In reply to @Elegantbeef "There are bindings for": Never knew there were so many solutions, thank you Elegantbeef 🙏 ↵Going to check out Nimx/Fidget/Nigui, never heard of em before but sound worth reading into |
21:31:40 | FromDiscord | <Elegantbeef> Yea kaushal seems like the `net` module would be the best, unless you want lower level stuff |
21:31:56 | FromDiscord | <Elegantbeef> There is also asyncnet if that ticles your fancy |
21:34:20 | FromDiscord | <kaushalmodi> In reply to @Elegantbeef "Yea kaushal seems like": Thanks, I will start reading the `net` doc then. |
21:35:08 | FromDiscord | <kaushalmodi> > unless you want lower level stuff↵I just want to receive data over a socket and pass it on to another system via a C API function |
21:35:22 | FromDiscord | <Elegantbeef> Then yea net should be fine |
21:41:41 | NimEventer | New post on r/nim by wrestlingwithbadgers: Problem with dom.EmbedElement, see https://reddit.com/r/nim/comments/pffjky/problem_with_domembedelement/ |
21:43:50 | FromDiscord | <RattleyCooper> Is it possible to define a template within a template so that the nested template only "exists" if the outer templates conditions are met? |
21:44:16 | FromDiscord | <RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3xA8 |
21:44:49 | FromDiscord | <RattleyCooper> I'm trying to recreate the pandas dataframe filter syntax: `df[df.someCol == 5]` to filter values |
21:44:52 | FromDiscord | <Elegantbeef> when statements |
21:45:39 | FromDiscord | <RattleyCooper> Ok, I will look into it |
21:45:41 | FromDiscord | <RattleyCooper> Thanks! |
21:46:35 | FromDiscord | <kaushalmodi> I think I will need to start with `asyncnet` as I need "non-blocking socket communication". |
21:46:39 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3xA9 |
21:46:52 | FromDiscord | <Elegantbeef> Notice where the error is in that example rattley |
21:47:06 | FromDiscord | <Elegantbeef> It's in the second block due to passing false |
21:47:30 | FromDiscord | <RattleyCooper> Gotcha |
21:48:45 | FromDiscord | <RattleyCooper> The issue is that `e` should end up equating to the AST for `df.someCol == 5]` but the template that handles `==` doesn't exist |
21:48:56 | FromDiscord | <RattleyCooper> (edit) "5]`" => "5`" |
21:49:11 | FromDiscord | <RattleyCooper> (edit) "exist" => "exist, even though I defined it within the outer template" |
21:53:03 | FromDiscord | <RattleyCooper> I can link to the playground but for some reason the playground doesn't display the error (or anything) |
21:54:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/cB5 |
21:54:10 | FromDiscord | <RattleyCooper> Oh wow, I'm a fool lol. I had another code snippet that was interfering.. |
21:54:38 | FromDiscord | <RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3xAb |
21:59:26 | * | max22- quit (Quit: Leaving) |
22:26:44 | FromDiscord | <RattleyCooper> Do templates have their own scope? |
22:37:02 | FromDiscord | <RattleyCooper> not exactly sure how to apply `when` to my problem. Right now I have: |
22:37:14 | FromDiscord | <RattleyCooper> sent a code paste, see https://paste.rs/3kp |
22:37:56 | FromDiscord | <RattleyCooper> to stop the template from redefining that `==` proc in the global scope. But it's just redefining that proc into a new block every time... |
22:40:03 | FromDiscord | <Recruit_main707> templates are basically copying that code and pasting it wherever you use it, so it will be defined in that scope afaik |
22:40:41 | * | oprypin quit (Quit: Bye) |
22:40:52 | * | oprypin joined #nim |
22:41:45 | FromDiscord | <RattleyCooper> Yeah, I'm just trying to figure out how I can get this syntax to work, while only defining that `==` proc once. The issue is that if I define it outside the `[]` template it can run anywhere |
22:41:52 | FromDiscord | <RattleyCooper> not just in the `[]` |
22:43:24 | FromDiscord | <Recruit_main707> what are you trying to acomplish with this? |
22:46:13 | FromDiscord | <RattleyCooper> In reply to @Recruit_main707 "what are you trying": I want to make a pandas dataframe filter syntax for an object. Mostly just learning more about templates/macros |
22:46:57 | FromDiscord | <RattleyCooper> in pandas you can do `d[d.someColumn == 5]` to get filtered data where any value in the column is equal to 5 |
22:47:24 | FromDiscord | <RattleyCooper> and I just want to see if it's possible in nim. It totally is, I just want to figure out how to do it better. |
22:49:13 | FromDiscord | <RattleyCooper> What's odd though is the nim playground doesn't like to show any output, even though it works locally with the same version of nim |
22:50:43 | FromDiscord | <RattleyCooper> oh wow, nvm the playground just decided to tab all my echos over XD |
22:50:59 | FromDiscord | <rb3.nim> Is there a way to disable constructor calls (`Object(a: 1, b: 2)`), using term-rewriting macros for example? I want to enforce usage of init functions, for my c++-interop library |
22:51:44 | FromDiscord | <Elegantbeef> do not export the type but it's not a great way |
22:52:02 | FromDiscord | <rb3.nim> The old trick doesn't seem to work anymore https://forum.nim-lang.org/t/3445 |
22:52:19 | FromDiscord | <Elegantbeef> @RattleyCooper\: https://play.nim-lang.org/#ix=3xAn |
22:52:35 | FromDiscord | <rb3.nim> Ah ya, but my init functions look like `Object.init(1, 2)` |
22:52:48 | FromDiscord | <rb3.nim> So they take a type 😱 |
22:53:00 | FromDiscord | <Elegantbeef> So rewrite them as `initObject` |
22:53:53 | FromDiscord | <Elegantbeef> But yea not overly nice |
22:53:57 | FromDiscord | <rb3.nim> The `init` function is actually generated by a separate library I wrote, and is meant to be reusable everywhere, so thats not an option |
22:54:08 | FromDiscord | <rb3.nim> (edit) "library" => "macro" |
22:54:35 | FromDiscord | <rb3.nim> there must be a way with term rewriting macros... |
22:55:13 | FromDiscord | <Elegantbeef> I think there is |
22:55:25 | FromDiscord | <Elegantbeef> I recall doing something similar before |
22:56:25 | FromDiscord | <rb3.nim> sent a code paste, see https://play.nim-lang.org/#ix=3xAo |
22:57:44 | FromDiscord | <RattleyCooper> In reply to @Elegantbeef "<@408056314342932491>\: https://play.nim-lang.org/": Wow, that is freaking sweet |
23:02:28 | FromDiscord | <RattleyCooper> I feel like that should be in sequtils if there isn't something similar |
23:02:39 | FromDiscord | <Elegantbeef> it's already in called `filterit` |
23:02:46 | FromDiscord | <RattleyCooper> Ah, perfect 😄 |
23:03:45 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3xAt |
23:04:30 | FromDiscord | <Elegantbeef> As long as you move your `constDestr` to after all your init procs you'll be fine to prevent the user from doing such |
23:07:07 | * | arkurious quit (Quit: Leaving) |
23:09:03 | FromDiscord | <Recruit_main707> In reply to @Elegantbeef "<@408056314342932491>\: https://play.nim-lang.org/": Are you forced to use `{}` instead of `[]`? |
23:09:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/d34 |
23:09:40 | FromDiscord | <RattleyCooper> In reply to @Recruit_main707 "Are you forced to": I think if the base type is a seq |
23:09:40 | FromDiscord | <Elegantbeef> I think the `[]` is reasoned to be the generic accessing proc and as such it complains about `it` |
23:10:28 | FromDiscord | <Elegantbeef> Since `proc [](s: seq, index: IndexType)` is more specific than `template [](s: seq, index: untyped)` |
23:10:45 | FromDiscord | <Elegantbeef> Remember untyped/typed do not support overloading |
23:10:46 | FromDiscord | <RattleyCooper> Doesn't proc overloading not work super well with untyped? |
23:10:52 | FromDiscord | <RattleyCooper> Oh lol guess so |
23:11:09 | FromDiscord | <Recruit_main707> the answer before the question xd |
23:11:19 | FromDiscord | <Elegantbeef> I'm just that good 😛 |
23:11:46 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#overloading-resolution-lazy-type-resolution-for-untyped |
23:12:26 | FromDiscord | <tandy> when using karax + prologue i cant get css / assets to work when using a route like /home |
23:12:42 | FromDiscord | <Recruit_main707> sent a code paste, see https://play.nim-lang.org/#ix=3xAx |
23:12:45 | FromDiscord | <tandy> anyone know how to fix that? |
23:13:15 | FromDiscord | <Elegantbeef> TRM are post semantic checking so the code has to be valid before it gets to them↵(@Recruit_main707) |
23:14:48 | FromDiscord | <Recruit_main707> and where is it invalid, at `[bool]`? |
23:15:11 | FromDiscord | <Elegantbeef> `it` isnt valid in the context of `seq[it > 20]` |
23:15:22 | FromDiscord | <Elegantbeef> there is no `it` variable declared |
23:16:57 | FromDiscord | <Recruit_main707> ah right mb, and despite using a trm, `[]` as a function is considered more specific and we get to the same problem? |
23:17:28 | FromDiscord | <Elegantbeef> Well like i said `trm` is post semantic checking, so the code underneath needs to be valid |
23:17:29 | FromDiscord | <Recruit_main707> Of not being able to inject `it`? |
23:18:02 | FromDiscord | <Elegantbeef> So if the code cannot be compiled before the trm it cannot get to the point to apply the trm |
23:18:47 | FromDiscord | <Elegantbeef> > ↵> Term rewriting macros are macros or templates that have not only a name but also a pattern that is searched for after the semantic checking phase of the compiler\: This means they provide an easy way to enhance the compilation pipeline with user defined optimizations\:↵> |
23:19:35 | FromDiscord | <Recruit_main707> and since the injection happens within the template it cannot reach it before being invalid (?) |
23:19:52 | FromDiscord | <Elegantbeef> Well the template is never chosen in the semantic check |
23:20:10 | FromDiscord | <Elegantbeef> So it choses the procedure and then checks the expression inside `[]` |
23:20:24 | FromDiscord | <Elegantbeef> That expression is `it > 20` which cannot be resolved since `it` isnt known |
23:20:50 | FromDiscord | <Elegantbeef> It then throws a compiler error there and you have to fix the code or use a different indexing method |
23:21:34 | FromDiscord | <Elegantbeef> Once you have a procedure that matches your template/macro that takes an untyped you need to use a different index method or a more specific procedure |
23:21:39 | FromDiscord | <Recruit_main707> so this happens:↵> [] as a function is considered more specific |
23:21:55 | FromDiscord | <Recruit_main707> right? |
23:22:01 | FromDiscord | <Elegantbeef> Yes |
23:22:34 | FromDiscord | <Elegantbeef> It doesnt know which `[]` you're using so it attempts to sem the `it > 20`, but then hits a wall of `it` being undefined |
23:23:22 | FromDiscord | <Elegantbeef> So in this case you could actually do `[proc(a: T): bool = a > 20]` |
23:23:26 | FromDiscord | <Elegantbeef> Not overly nice |
23:24:31 | FromDiscord | <Recruit_main707> alright, its just that trm are not able to be prioritised over previously defined functions, thanks for answering my doubts :) |
23:25:03 | FromDiscord | <Elegantbeef> Not that it's fucking clean |
23:25:09 | FromDiscord | <Elegantbeef> But that's not the point of this excersize |
23:25:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3xAz |
23:25:25 | FromDiscord | <Elegantbeef> Maybe i'll spell that word right eventually, where is rika to spell it for me |
23:27:12 | FromDiscord | <Elegantbeef> Arent you glad you asked rattley ? |
23:27:21 | FromDiscord | <Elegantbeef> We're now in the deepend of procedure resolution |
23:27:30 | FromDiscord | <RattleyCooper> Hehehe |
23:27:39 | FromDiscord | <RattleyCooper> I'm learning a lot so I'm happy |
23:28:11 | FromDiscord | <Elegantbeef> Do wonder if my solution for the object constructor actually helped them |
23:28:23 | FromDiscord | <Elegantbeef> Radio silence after my solution makes me sad |
23:28:46 | * | luis_ joined #nim |
23:29:30 | FromDiscord | <RattleyCooper> Oh it definitely did. I haven't gotten it done yet but I can see how to actually do it now.. |
23:29:49 | FromDiscord | <Elegantbeef> But you werent the one with a problem |
23:30:18 | FromDiscord | <RattleyCooper> Oh lol I forgot you're helping everyone and mine isn't an object constructor 👀 |
23:37:32 | * | luis_ quit (Ping timeout: 245 seconds) |
23:42:05 | * | auxym_ joined #nim |
23:45:46 | * | flynn quit (Read error: Connection reset by peer) |
23:46:52 | * | flynn joined #nim |
23:54:25 | * | luis_ joined #nim |