00:15:51 | * | oprypin quit (Quit: No Ping reply in 180 seconds.) |
00:20:30 | * | oprypin joined #nim |
00:28:16 | FromDiscord | <voidwalker> so I am trying to make a super basic torrent client. wrote an async proc where the peer messaging happens. I am passing a Peer type object to it with var, so I can write to its fields directly. Problem is, I am getting `'aPeer' is of type <var Peer> which cannot be captured as it would violate memory safety`. How would I get around this ? I don't think there will be any memory safety issues with this design. |
00:35:48 | FromDiscord | <Elegantbeef> You can either do the unsafe thing and do `let a = aPee.addr` and use `a` inside your closure or make `Peer` a ref object |
00:37:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g5b |
00:40:04 | FromDiscord | <Elegantbeef> in the case it's a ref object you drop the `var` |
00:40:43 | FromDiscord | <voidwalker> that's it ? what are the consequences of this ? |
00:40:57 | FromDiscord | <Elegantbeef> Consequences of what? |
00:41:09 | FromDiscord | <voidwalker> of using ref instead of normal object with var |
00:41:21 | FromDiscord | <Elegantbeef> It's heap allocated and a nilable type now |
00:41:25 | FromDiscord | <Elegantbeef> But it can safely be captured |
00:41:56 | FromDiscord | <Elegantbeef> To explain further `var T` cannot be captured as it's a pointer to any resource which can mean a value on the stack |
00:42:59 | FromDiscord | <voidwalker> btw, any such nim libs/programs out there, with high quality code, that I could learn from ? I am talking implementation of network protocols, tracking state and such |
00:44:12 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4g5c for an example |
00:50:41 | FromDiscord | <auxym> In reply to @voidwalker "btw, any such nim": https://github.com/treeform/netty maybe? |
00:53:26 | FromDiscord | <voidwalker> hm not exactly what I was thinking of (udp is too low level), but it's good |
01:37:58 | FromDiscord | <.tochka> not nil ref by default when |
01:38:23 | FromDiscord | <Elegantbeef> Sometime in 2.x |
01:40:28 | FromDiscord | <.tochka> jason the time traveler |
01:40:40 | FromDiscord | <Elegantbeef> What? |
01:40:41 | FromDiscord | <Elegantbeef> Nah there is a 'roadmap |
01:41:01 | FromDiscord | <MilesTheFox> Hello! |
01:41:29 | FromDiscord | <.tochka> hi |
01:42:42 | FromDiscord | <MilesTheFox> Huh, do you know how to encrypt TCP connections in Nim? |
01:43:16 | * | derpydoo quit (Ping timeout: 248 seconds) |
01:44:11 | FromDiscord | <.tochka> use ssl or something |
01:44:38 | FromDiscord | <MilesTheFox> I never tried using SSL in Nim |
01:45:42 | FromDiscord | <Elegantbeef> Nim ships with openssl and bindings for it that are used for `net` and `httpclient` |
01:46:16 | FromDiscord | <MilesTheFox> Ohh, okayy |
01:49:34 | FromDiscord | <Elegantbeef> There is also bearssl which is arguably better |
01:49:36 | FromDiscord | <Elegantbeef> Status uses it |
01:51:52 | * | wallabra joined #nim |
02:03:28 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
02:09:55 | FromDiscord | <aquova> Hello everyone. Is there a way to set some code behind a JS compiler flag? I have a program that I want to be able to both compile into a binary as well as compile and embed as javascript. Since the main function has some file loading code, it can't be used with the javascipt. I wasn't sure if there's anyway to set one function to be used if compiling as javascript, and a different one otherwise (aside from breaking it out into two files, |
02:11:07 | FromDiscord | <.tochka> when defined(js): should work? |
02:12:30 | FromDiscord | <aquova> that might be what I'm looking for |
02:14:32 | FromDiscord | <aquova> Is there a list of those `defined` items somewhere? |
02:16:23 | FromDiscord | <MilesTheFox> In reply to @Elegantbeef "There is also bearssl": How to use it? |
02:16:57 | FromDiscord | <ringabout> In reply to @aquova "Is there a list": I don't think there is, but it is worth having it documented somewhere. |
02:17:13 | FromDiscord | <Elegantbeef> No clue, other than import the bearssl bindings |
02:18:24 | FromDiscord | <.tochka> documentation of stuff is certainly lacking with nim 😔 |
02:19:00 | FromDiscord | <.tochka> eternal wip smh |
02:19:08 | FromDiscord | <MilesTheFox> In reply to @.tochka "documentation of stuff is": At least you don't have to suffering with porting your app to Windows |
02:19:17 | FromDiscord | <MilesTheFox> (edit) "suffering" => "suffer" |
02:20:21 | * | rockcavera joined #nim |
02:21:24 | FromDiscord | <.tochka> its rather windows friendly indeed |
02:22:27 | FromDiscord | <MilesTheFox> Windows programming is hard |
02:22:41 | FromDiscord | <MilesTheFox> Also, uh, how to properly crosscompile to Windows via MinGW? |
02:23:08 | FromDiscord | <MilesTheFox> ``-os:windows`` uses default GCC and because of that it can't find Windows headers |
02:23:14 | FromDiscord | <Elegantbeef> `-d:mingw` |
02:23:18 | FromDiscord | <Meowing Cat> In reply to @MilesTheFox "Windows programming is hard": MacOS is even worse |
02:23:20 | FromDiscord | <Meowing Cat> i think |
02:23:47 | FromDiscord | <Meowing Cat> In reply to @Elegantbeef "`-d:mingw`": beef i was looking for you |
02:23:58 | FromDiscord | <Meowing Cat> are you still a bot? |
02:24:23 | FromDiscord | <MilesTheFox> https://media.discordapp.net/attachments/371759389889003532/1042626225966960670/image.png |
02:24:40 | FromDiscord | <Elegantbeef> That's what it says on my name tag |
02:24:52 | FromDiscord | <MilesTheFox> In reply to @Meowing Cat "MacOS is even worse": Nope |
02:25:11 | FromDiscord | <MilesTheFox> NIX(-like) systems are much easier |
02:25:37 | FromDiscord | <Meowing Cat> In reply to @MilesTheFox "*NIX(-like) systems are much": iOS? |
02:25:43 | FromDiscord | <MilesTheFox> I still can't understand WinSocks2 docs XD |
02:25:53 | FromDiscord | <MilesTheFox> In reply to @Meowing Cat "iOS?": A bit hard |
02:26:23 | FromDiscord | <.tochka> i mean, winsocks2 are pretty much the same berkeley sockets linux has |
02:26:23 | FromDiscord | <MilesTheFox> On Nim I can use anything and it'll work on any OS |
02:26:38 | FromDiscord | <.tochka> (edit) "i mean, winsocks2 are pretty much the same berkeley sockets linux ... has" added "too" |
02:27:01 | FromDiscord | <.tochka> its just that this ancient api is rather whacky |
02:27:02 | FromDiscord | <MilesTheFox> In reply to @.tochka "i mean, winsocks2 are": Nope, NIX sockets are much easier than Win↵Socks2 |
02:27:10 | FromDiscord | <MilesTheFox> (edit) "Win↵Socks2" => "WinSocks2" |
02:27:44 | FromDiscord | <MilesTheFox> In reply to @.tochka "its just that this": I always have to use #pragma comment and it's annoying |
02:28:25 | FromDiscord | <.tochka> for what? |
02:28:35 | FromDiscord | <MilesTheFox> Every lib |
02:28:36 | FromDiscord | <.tochka> linking? |
02:28:43 | FromDiscord | <.tochka> you can pass it via cli |
02:28:44 | FromDiscord | <MilesTheFox> Y e a h |
02:28:52 | FromDiscord | <.tochka> same way other compilers work |
02:29:00 | FromDiscord | <.tochka> (edit) "same way other compilers ... work" added "and environments" |
02:29:10 | FromDiscord | <MilesTheFox> I tried and it didn't work |
02:30:21 | FromDiscord | <Elegantbeef> image.png↵(@MilesTheFox) https://media.discordapp.net/attachments/371759389889003532/1042627727951405187/image.png |
02:31:14 | FromDiscord | <MilesTheFox> Weird |
02:31:30 | FromDiscord | <.tochka> looks like misconfiguration or something |
02:31:44 | FromDiscord | <MilesTheFox> Wait... looks like it still uses default GCC |
02:32:34 | FromDiscord | <MilesTheFox> sent a code paste, see https://play.nim-lang.org/#ix=4g5r |
02:32:51 | FromDiscord | <Elegantbeef> How are you compiling? |
02:33:15 | FromDiscord | <MilesTheFox> In reply to @Elegantbeef "How are you compiling?": ``nim compile --os:windows --d:mingw --app:gui -d:danger b64t.nim`` |
02:33:35 | FromDiscord | <MilesTheFox> (edit) "--d:mingw" => "-d:mingw" |
02:33:45 | FromDiscord | <Elegantbeef> you can remove the `--os:windows` |
02:34:41 | FromDiscord | <MilesTheFox> I'm confused https://media.discordapp.net/attachments/371759389889003532/1042628815505072138/image.png |
02:35:13 | FromDiscord | <.tochka> top 10 reasons to have nim llvm: 1. cross compiling |
02:35:32 | FromDiscord | <MilesTheFox> XD |
02:35:41 | FromDiscord | <Elegantbeef> `nimble install zigcc` 😛 |
02:35:53 | FromDiscord | <huantian> while you're at it move to nixos |
02:36:06 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4g5s |
02:36:22 | FromDiscord | <MilesTheFox> In reply to @huantian "while you're at it": NixOS is a bit bloated |
02:36:35 | FromDiscord | <MilesTheFox> I use suckless init (sinit) |
02:36:41 | FromDiscord | <MilesTheFox> With Sway compositor |
02:36:46 | FromDiscord | <MilesTheFox> No DM |
02:36:49 | FromDiscord | <huantian> right |
02:36:52 | FromDiscord | <MilesTheFox> (edit) "DM" => "Desktop Manager" |
02:37:00 | FromDiscord | <huantian> i mean you can use sway on nixos |
02:37:07 | FromDiscord | <huantian> if that's what you mean? |
02:37:15 | FromDiscord | <MilesTheFox> But it's slow for 11 years old laptop |
02:37:23 | FromDiscord | <huantian> unless you're talking about the nix package manager being not the fastest |
02:37:37 | FromDiscord | <MilesTheFox> I heard Nix packakge manager uses 2GB RAM |
02:37:39 | FromDiscord | <huantian> but this is offtopic lmao |
02:37:48 | FromDiscord | <MilesTheFox> My laptop has only 2GB RAM |
02:38:04 | FromDiscord | <.tochka> In reply to @MilesTheFox "I heard Nix packakge": no way o.O |
02:38:08 | FromDiscord | <huantian> I mean anything can use 2gb of ram if you tell it to |
02:38:35 | FromDiscord | <MilesTheFox> In reply to @huantian "I mean anything can": ``cat /dev/zero > /dev/shm/a`` |
02:39:29 | FromDiscord | <Elegantbeef> Your PC sweats hearing that doesnt it 😛↵(@.tochka) |
02:39:40 | FromDiscord | <.tochka> lol |
02:40:02 | FromDiscord | <huantian> but anyway I got 32gb of ram for my new laptop for minecraft so im fine |
02:40:08 | FromDiscord | <.tochka> now i have machine even older |
02:40:15 | FromDiscord | <.tochka> before it was at least 4gb ram |
02:40:42 | FromDiscord | <huantian> lol |
02:52:35 | FromDiscord | <Rika> In reply to @huantian "but anyway I got": Bruh |
02:52:55 | FromDiscord | <Rika> TBF the reason I have 32 GB of RAM isn’t much better lol |
02:55:54 | FromDiscord | <MilesTheFox> Is it possible to use WebSockets with Nim? |
02:56:50 | FromDiscord | <Rika> https://github.com/treeform/ws |
02:57:57 | FromDiscord | <MilesTheFox> Also, is it possible to prevent 2 instances of app running at same time? |
02:58:50 | FromDiscord | <Rika> Sure but manually |
02:59:06 | FromDiscord | <Rika> No code in the standard library to easily implement it so you’re gonna need your own solution |
02:59:17 | FromDiscord | <MilesTheFox> Okayy |
03:00:50 | FromDiscord | <Elegantbeef> A solution is to make a dummy file and if it exists you just close the appliication |
03:01:40 | FromDiscord | <leorize> that's just pidfiles with extra steps |
03:01:51 | FromDiscord | <Rika> Then you have the problem of what if the working application crashes and doesn’t remove the file so yeah have fun |
03:01:58 | FromDiscord | <Elegantbeef> Comically Unity does that to prevent you from working on multiple projects |
03:02:05 | FromDiscord | <Elegantbeef> well the same project multiple times |
03:02:08 | FromDiscord | <Rika> PID file would prolly work best yes |
03:02:26 | FromDiscord | <leorize> you can copy Qt's solution |
03:02:33 | FromDiscord | <huantian> yeah and if I force kill unity I have to manually remove it! what a pain those 10 seconds of my life oculd've been used to do something meaningfuly but instead I'm left here to clean up after unity's issues |
03:02:36 | FromDiscord | <MilesTheFox> In reply to @Elegantbeef "A solution is to": But what if power outage happens? |
03:02:41 | FromDiscord | <leorize> iirc they just use a named pipe/fifo |
03:02:54 | FromDiscord | <huantian> In reply to @MilesTheFox "But what if power": tell your user to get a ups |
03:03:02 | FromDiscord | <MilesTheFox> Huh |
03:03:04 | FromDiscord | <Elegantbeef> It's all on the user |
03:04:13 | FromDiscord | <huantian> the developer is always right |
03:05:23 | FromDiscord | <MilesTheFox> Easy solution: just check if something is already listening on the port, if nothing is listening it will use it and continue working, if not it'll close |
03:05:47 | FromDiscord | <MilesTheFox> (edit) "not" => "something is listening on the port" |
03:06:24 | FromDiscord | <MilesTheFox> Anyways we have 65565 free ports |
03:06:50 | FromDiscord | <Rika> It’s not a lot of ports tbh |
03:06:50 | FromDiscord | <leorize> and then someone squat your port |
03:07:05 | FromDiscord | <Rika> As mentioned you should prolly use Unix sockets or named pipes or what else |
03:07:09 | FromDiscord | <leorize> do remember that all OS have facilities for picking a random port |
03:08:06 | FromDiscord | <MilesTheFox> In reply to @Rika "As mentioned you should": NIX sockets don't work on Spyndows |
03:08:30 | FromDiscord | <Rika> Named pipes |
03:09:03 | FromDiscord | <MilesTheFox> Okayy |
03:09:37 | FromDiscord | <leorize> also unix sockets is a thing on windows 10 for quite awhile |
03:10:57 | FromDiscord | <Rika> Woah really? |
03:11:03 | FromDiscord | <MilesTheFox> Huhh |
03:12:27 | FromDiscord | <leorize> https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ |
03:13:16 | FromDiscord | <Rika> Yeah |
03:13:26 | FromDiscord | <Rika> No data gram support |
03:13:27 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Nim is great because i don’t have to worry too much on how expensive the costs of running the code are. |
03:13:31 | FromDiscord | <Rika> Doesn’t matter though I think |
03:14:03 | * | arkurious quit (Quit: Leaving) |
04:18:15 | FromDiscord | <dizzyliam> Just double checking: If a macro generates code that includes macros, those macros will also be executed afterwards? |
04:20:04 | FromDiscord | <leorize> yes they will |
04:21:47 | * | droidrage joined #nim |
04:23:07 | FromDiscord | <morgan> In reply to @MilesTheFox "But what if power": so you could have the program not just create a file, but instead periodically write a timestamp to it, and if the timestamp is more than some amount of time out of date, assume no other instances are open |
04:24:14 | * | rockcavera quit (Remote host closed the connection) |
04:26:51 | FromDiscord | <dizzyliam> In reply to @leorize "yes they will": Interesting, my macro that generates jester routes is resulting in undeclared identifier errors for identifiers that jester's `router` macro should take out. Almost like scope checking is happening between the two macros |
04:26:53 | FromDiscord | <MilesTheFox> People that keep PC running 24/7: you'll never understand my power |
04:27:24 | FromDiscord | <.tochka> hm, how to mark loop for unrolling? |
04:29:14 | FromDiscord | <Elegantbeef> https://stackoverflow.com/a/74077789 |
04:29:58 | FromDiscord | <MilesTheFox> Huh, is it possible to embed executable inside Nim app? |
04:30:44 | FromDiscord | <dizzyliam> Could read it at compile time, then save it to a temporary file at runtime and execute |
04:31:10 | FromDiscord | <Elegantbeef> You can `staticRead` it but it''s just a binary file there |
04:33:25 | FromDiscord | <.tochka> In reply to @Elegantbeef "https://stackoverflow.com/a/74077789": hm, wonder, was it proposed to be implemented in std or language |
04:33:34 | FromDiscord | <MilesTheFox> How to do it? I don't wanna have more than 1 file |
04:33:50 | FromDiscord | <MilesTheFox> I'm already thinking about how to embed cacert.pem inside Nim app itself |
04:36:11 | FromDiscord | <.tochka> In reply to @MilesTheFox "How to do it?": looks promising https://captain-woof.medium.com/how-to-execute-an-elf-in-memory-living-off-the-land-c7e67dbc3100 |
04:36:23 | FromDiscord | <leorize> indeed, scope checking happens between macro. If you'd like to call a symbol declared in /your/ scope (and not the macro's caller scope), then you have to use `bindSym` to get the symbol↵(@dizzyliam) |
04:36:30 | FromDiscord | <.tochka> but would be highly non-portable any way |
04:37:10 | FromDiscord | <Elegantbeef> No clue, personally my way i find is the best↵(@.tochka) |
04:37:15 | FromDiscord | <Elegantbeef> Works on all iterators |
04:37:34 | FromDiscord | <.tochka> you would need to compile the elf first tho, and then embed it in other compiler invocation |
04:37:57 | FromDiscord | <leorize> here's your reminder that `{.unroll: n.}` was in the Nim spec |
04:38:31 | FromDiscord | <Elegantbeef> With for loop macros could throw it in `sugar` |
04:38:52 | FromDiscord | <MilesTheFox> In reply to @.tochka "you would need to": Already compiled ELF |
04:39:25 | FromDiscord | <leorize> you can copy appimage's approach |
04:39:48 | FromDiscord | <leorize> (or, just use appimage to make your life easier) |
04:39:56 | FromDiscord | <Meowing Cat> what is Nim's JS support? |
04:40:40 | FromDiscord | <huantian> what exactly do you wanna know about it? |
04:41:02 | FromDiscord | <Meowing Cat> seems like it has something like Next.js |
04:42:06 | FromDiscord | <huantian> next js is server side rendering right? |
04:42:20 | FromDiscord | <huantian> if you wanna do serverside rendering, you can do it in C compiled Nim |
04:42:36 | FromDiscord | <Meowing Cat> In reply to @huantian "next js is server": yes |
04:42:39 | FromDiscord | <Meowing Cat> In reply to @huantian "if you wanna do": ummmmmmm |
04:42:43 | FromDiscord | <leorize> next js is hybrid server side/client side iirc |
04:42:47 | FromDiscord | <Meowing Cat> so it has a similar feature? |
04:43:06 | FromDiscord | <Meowing Cat> In reply to @leorize "next js is hybrid": damn another bottttt |
04:43:18 | FromDiscord | <.tochka> this server is full of bots |
04:43:22 | FromDiscord | <.tochka> worse than twitter |
04:43:26 | FromDiscord | <leorize> you basically pre-generate the DOM as an HTML document then have your JS use it to do things like an SPA |
04:43:27 | FromDiscord | <Meowing Cat> 🙀 |
04:43:33 | FromDiscord | <dizzyliam> In reply to @leorize "indeed, scope checking happens": Thanks I'll have a look |
04:43:41 | FromDiscord | <Elegantbeef> Give me your 8$↵(@.tochka) |
04:45:04 | FromDiscord | <huantian> In reply to @leorize "next js is hybrid": so it's like a combo of jester/prologue + karax? |
04:45:45 | FromDiscord | <leorize ✔> nope, it's more advanced |
04:46:01 | FromDiscord | <huantian> so like a combo of those but built to work together |
04:47:03 | FromDiscord | <leorize> SPA generates the pages on client when load, the next.js approach basically take that code and run it on the server first to get a page that can be delivered verbatim to the user |
04:47:16 | FromDiscord | <dizzyliam> Karax can do server side rendering, although I've never tried it |
04:48:06 | FromDiscord | <.tochka> In reply to @.tochka "looks promising https://captain-woof.medium.com/how": looks possible in windows too https://github.com/aaaddress1/RunPE-In-Memory/tree/master/RunPE-In-Memory/RunPEinMemory |
04:48:22 | FromDiscord | <leorize> basically let you reuse client code as page generation code on server-side |
04:49:14 | FromDiscord | <leorize> karax can do SSR, but I don't know if it can rehydrate a page |
05:02:19 | FromDiscord | <dizzyliam> In reply to @leorize "indeed, scope checking happens": Sadly the documentation for `bindSym` isn't helping me. Basically I need a way to get around the scope checking that happens between my macro and the `router` macro, because the latter is designed to execute before any scope checking has happened. |
05:03:29 | FromDiscord | <Elegantbeef> you `bindSym"myCode"` then use that symbol in your code |
05:04:18 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/blob/2efefb944b954b9f05891dce5274e53d7798bcf2/lender.nim#L5↵https://github.com/beef331/nimtrest/blob/2efefb944b954b9f05891dce5274e53d7798bcf2/lender.nim#L51 |
05:08:11 | FromDiscord | <dizzyliam> Thanks for the examples :) |
05:15:55 | FromDiscord | <leorize> [@dizzyliam](https://matrix.to/#/%40_discord_531959880609955841%3At2bot.io) oh wait, you're running it to generate routes inside the router macro? |
05:16:05 | FromDiscord | <leorize> then no amount of `bindSym` will help you |
05:17:11 | FromDiscord | <leorize> `jester.router` is an untyped macro. In short, it will perform all the transformation /before/ your macro executes |
05:19:20 | FromDiscord | <dizzyliam> In reply to @leorize "`jester.router` is an untyped": Ah, so I can't generate code that uses it. Damm |
05:19:28 | FromDiscord | <dizzyliam> Thanks for the help |
05:20:33 | FromDiscord | <leorize> you can try to see if its possible to register routes manually without the fancy macro |
05:21:08 | FromDiscord | <leorize> fancy `router` macro |
05:21:23 | FromDiscord | <leorize> I don't think it's possible, the `router` macro is quite a hack on its own |
05:22:20 | FromDiscord | <dizzyliam> Yeah I was registering them manually before but needed some of that fancy `router` functionality |
05:28:14 | FromDiscord | <leorize> time to craft your own macro-friendly `router` \:p |
05:32:47 | FromDiscord | <alicia ッ> https://github.com/andreaferretti/patty↵is it still maintained? |
05:34:45 | FromDiscord | <dizzyliam> In reply to @leorize "time to craft your": regex magic time |
05:35:12 | FromDiscord | <dizzyliam> I was mostly looking at `router` for it's url matching ability |
05:35:14 | FromDiscord | <Elegantbeef> Ew |
05:35:15 | FromDiscord | <Elegantbeef> Regex |
05:35:51 | FromDiscord | <alicia ッ> @ElegantBeef is patty still maintained/supported |
05:35:58 | FromDiscord | <alicia ッ> im interested in pattern matching libraries for nim |
05:41:33 | FromDiscord | <alicia ッ> or should i use fusion |
05:50:19 | FromDiscord | <Elegantbeef> No clue i dont do PM |
05:50:44 | * | ltriant joined #nim |
05:51:53 | FromDiscord | <pietroppeter> I think this is a more update version of Pattern Matching (have not used it though) https://github.com/haxscramper/hmatching (the version in fusion is an early version of this), cc @haxscramper |
05:53:00 | FromDiscord | <Bung> use https://github.com/nim-lang/ast-pattern-matching if want official support |
05:53:44 | FromDiscord | <leorize> i'm pretty sure that one is for macro devs only |
05:56:41 | FromDiscord | <Bung> ah, so use patty or hmatching |
05:58:58 | FromDiscord | <Meowing Cat> too many bots |
05:59:00 | FromDiscord | <Meowing Cat> damnnnnnnnnnnnnnnnn |
05:59:15 | FromDiscord | <Elegantbeef> Beep boop beep |
06:00:54 | FromDiscord | <alicia ッ> sent a code paste, see https://play.nim-lang.org/#ix=4g66 |
06:36:49 | * | ehmry quit (Remote host closed the connection) |
06:38:31 | * | ehmry joined #nim |
06:53:36 | FromDiscord | <.tochka> sent a long message, see http://ix.io/4g6i |
06:53:57 | FromDiscord | <.tochka> sent a code paste, see https://play.nim-lang.org/#ix=4g6i |
06:54:01 | FromDiscord | <.tochka> could something like this work? |
06:57:13 | FromDiscord | <Meowing Cat> sent a code paste, see https://play.nim-lang.org/#ix=4g6l |
06:57:31 | FromDiscord | <Meowing Cat> Nim is weird |
06:59:04 | FromDiscord | <Elegantbeef> Sadly no tochka |
06:59:22 | FromDiscord | <.tochka> bummer |
07:05:22 | FromDiscord | <Meowing Cat> In reply to @.tochka "bummer": beef is a booooomer |
07:05:32 | FromDiscord | <.tochka> ik |
07:05:41 | FromDiscord | <Meowing Cat> also a bot |
07:05:58 | FromDiscord | <Meowing Cat> a beef can't even meow |
07:06:24 | FromDiscord | <.tochka> it can but not by its own will |
07:06:33 | FromDiscord | <.tochka> anything can meow if you force it |
07:06:35 | FromDiscord | <.tochka> (edit) "anything can meow if you force it ... " added "to" |
07:06:41 | FromDiscord | <.tochka> (edit) "anything" => "butanything" |
07:06:46 | FromDiscord | <.tochka> (edit) "butanything" => "but anything" |
07:07:17 | FromDiscord | <Elegantbeef> Bark |
07:11:15 | FromDiscord | <Meowing Cat> In reply to @.tochka "but anything can meow": fake meow |
07:11:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g6o |
07:11:36 | FromDiscord | <Meowing Cat> sent a code paste, see https://play.nim-lang.org/#ix=4g6p |
07:12:16 | FromDiscord | <Elegantbeef> Cause by doing `T.myArr` we delay the logic until instantation |
07:13:10 | FromDiscord | <.tochka> nice |
07:13:25 | FromDiscord | <Elegantbeef> Fuck that's an easy hack 😄 |
07:13:25 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g6q |
07:13:47 | FromDiscord | <Elegantbeef> This actually makes so many things easier |
07:27:56 | * | ltriant quit (Ping timeout: 256 seconds) |
07:35:30 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
07:35:36 | * | PMunch joined #nim |
07:41:40 | * | jjido joined #nim |
07:45:57 | * | kenran joined #nim |
07:55:28 | * | ltriant joined #nim |
07:57:02 | * | kenran quit (Remote host closed the connection) |
08:03:04 | * | ltriant quit (Ping timeout: 256 seconds) |
08:16:16 | * | ltriant joined #nim |
08:17:25 | FromDiscord | <SBG> hey fellas. |
08:17:33 | FromDiscord | <SBG> Does nim have anything like ncat |
08:17:43 | FromDiscord | <SBG> or should i just like make it run the ncat cmd from linux? |
08:19:26 | FromDiscord | <Elegantbeef> You can program what you want to do but it'll be more complex than just calling ncat |
08:21:12 | * | ltriant quit (Ping timeout: 256 seconds) |
08:22:52 | FromDiscord | <SBG> In reply to @Elegantbeef "You can program what": would it be faster to use sockets instead of ncat? as ncat depends on Linux (unless that gcc thingy is installed i forgor name)? |
08:23:36 | FromDiscord | <luteva> maybe: https://github.com/iocrate/netkit ? or have a look at what netkit uses for its tools....? |
08:23:45 | FromDiscord | <SBG> 👍🏻 |
08:24:22 | FromDiscord | <Elegantbeef> Depends what you're doing wit ncat |
08:24:23 | FromDiscord | <Elegantbeef> ncat does a lot |
08:24:29 | FromDiscord | <Elegantbeef> So you need to be specific what you want |
08:24:54 | FromDiscord | <SBG> ill show u essentially what im doing in python atm |
08:26:21 | FromDiscord | <SBG> sent a code paste, see https://play.nim-lang.org/#ix=4g6z |
08:26:33 | FromDiscord | <SBG> (edit) "https://play.nim-lang.org/#ix=4g6z" => "https://play.nim-lang.org/#ix=4g6A" |
08:27:16 | Zevv | wait what |
08:28:07 | Zevv | what does spinning up a qemu have to do with all of this |
08:28:25 | Zevv | basically, you just want to open a TCP socket, connect it to 127.0.0.1:1234 and send the string "sendkey 1" |
08:28:26 | FromDiscord | <Elegantbeef> Seems they're using ncat to see if a server is alive? |
08:28:39 | FromDiscord | <Elegantbeef> Yea there is no reason to use ncat for that 😄 |
08:28:47 | FromDiscord | <SBG> no thats not whats going on |
08:29:04 | FromDiscord | <SBG> cmd("") just wraps shell commands. |
08:29:33 | FromDiscord | <SBG> I'm sunning qemu and im giving it a monitor on blahblahblah which is sort of like a tty session |
08:30:12 | FromDiscord | <SBG> im launching whats like a ssh into the tty of the qemu (it's not a tty into the guest but the vm hardware itself) and then it sends the function "sendkey 1" |
08:30:22 | FromDiscord | <SBG> which sends the number 1 as user input into qemu |
08:31:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g6D |
08:31:07 | FromDiscord | <SBG> oh dang that simple dude? |
08:31:29 | FromDiscord | <SBG> and this doesn't need to be routed through shell right so there's not like a midlde man slowing stuff down? |
08:31:29 | FromDiscord | <Elegantbeef> Of course you're just sending a single string across tcp |
08:31:58 | FromDiscord | <Elegantbeef> Indeed and it's portable, it doesnt require ncat on the PC or even to be ran on linux |
08:32:03 | FromDiscord | <SBG> well yeah |
08:32:06 | Zevv | dial("127.0.0.1", 1234.Port).send("sendkey 1") |
08:32:17 | FromDiscord | <SBG> qemu sendkey makes chars be seperated by - |
08:32:20 | FromDiscord | <Elegantbeef> Ah dial is even niftier |
08:32:34 | FromDiscord | <SBG> sent a code paste, see https://play.nim-lang.org/#ix=4g6F |
08:32:38 | FromDiscord | <Elegantbeef> I dont do network stuff much so didnt know about dial |
08:33:05 | FromDiscord | <SBG> is there any difference between dial and Elegantbeef's solution? |
08:33:13 | FromDiscord | <Elegantbeef> dial manages the socket itself |
08:33:18 | FromDiscord | <Elegantbeef> So you need to make a new socket |
08:33:22 | FromDiscord | <Elegantbeef> Well internally it does it |
08:33:33 | FromDiscord | <Elegantbeef> My way allows a series of requests with the same socket |
08:33:48 | FromDiscord | <SBG> In reply to @SBG "so i have to": yeah it's doing multiple requests |
08:34:56 | FromDiscord | <luteva> but the dial version will work too, for multiple requests. it just opens new sockets. afaik. |
08:35:33 | FromDiscord | <Elegantbeef> Yea it's best to avoid doing that |
08:35:45 | FromDiscord | <SBG> In reply to @Elegantbeef "Yea it's best to": avoid doing? |
08:35:59 | FromDiscord | <luteva> so the main difference is the line:↵defer: mySocket.close()↵which is done implicitly in the dial version |
08:36:04 | FromDiscord | <Elegantbeef> Avoid making new sockets repetitively |
08:36:17 | FromDiscord | <SBG> ah right k |
08:36:20 | FromDiscord | <Elegantbeef> Wait dial returns a socket |
08:36:40 | FromDiscord | <Elegantbeef> So just use dial |
08:36:41 | FromDiscord | <Elegantbeef> I'm a fuckwit |
08:37:09 | Amun-Ra | ^ noted |
08:37:15 | FromDiscord | <Elegantbeef> Thought dial just send the data, guess i'm too tired |
08:38:17 | FromDiscord | <Elegantbeef> Amun if we noted how many times i called myself a fuckwit, we'd run out of paper |
08:38:39 | Amun-Ra | ;p |
08:41:44 | FromDiscord | <SBG> In reply to @Elegantbeef "Amun if we noted": well on the account your on, of the webhook id of 854845166641086475, you've said the phrase "I'm a fuckwit" 3 times. On your discord account you've said it twice. So unless your writing using a font size of 400 and paper the size of tictacs then sure. |
08:42:32 | FromDiscord | <Elegantbeef> That implies i've only done it here |
08:43:18 | FromDiscord | <jmgomez> Can you use the compiler API to get the type from a symbol in a file? Similar of what nimsuggest do but much more relaxed, just the inferred type name (return for a fn or the variable type itself) in a given file? |
08:43:50 | FromDiscord | <Elegantbeef> You should be able to it's `PSym.type` |
08:43:54 | FromDiscord | <Elegantbeef> well `.typ` |
08:47:09 | FromDiscord | <jmgomez> sweet, where would you start to look into it if you want to pass around the nim file, any particular fn? |
08:47:21 | FromDiscord | <Elegantbeef> Uhh |
08:47:35 | FromDiscord | <Elegantbeef> My response is "Just use a macro", cause i really dont know |
08:51:11 | * | ltriant joined #nim |
08:53:06 | FromDiscord | <jmgomez> but if nim file is incorrect which is usually the case it wouldnt work, would it? What I want is to build a small plugin editor, I have potentially millions of functions and type information to feed in already parsed but I need to know the type of what the user is typing |
08:53:14 | FromDiscord | <jmgomez> (edit) "but if ... nim" added "the" |
08:53:43 | FromDiscord | <Elegantbeef> Yea it wont work |
08:55:46 | * | ltriant quit (Ping timeout: 256 seconds) |
08:56:22 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
09:16:45 | * | ltriant joined #nim |
09:51:17 | * | lumidify joined #nim |
11:04:21 | FromDiscord | <albassort> whenever beef doesn't know he goes "make a macro" |
11:05:00 | FromDiscord | <Rika> Whenever seasoned Nim programmers don’t know they’d go “just make a macro it’s possible anyway” |
11:40:07 | * | genpaku quit (Remote host closed the connection) |
11:40:47 | * | genpaku joined #nim |
11:49:48 | FromDiscord | <&Makarov/1> Hi beautifull people 👋 |
11:49:57 | FromDiscord | <&Makarov/1> sent a code paste, see https://play.nim-lang.org/#ix=4g7z |
11:50:12 | FromDiscord | <&Makarov/1> i dont know this throws an error and says that it's a type mismatch |
11:50:30 | FromDiscord | <&Makarov/1> https://media.discordapp.net/attachments/371759389889003532/1042768689914708108/image.png |
11:50:53 | FromDiscord | <&Makarov/1> https://media.discordapp.net/attachments/371759389889003532/1042768784508854282/image.png |
11:51:03 | FromDiscord | <&Makarov/1> m trying to play a little with references 😂 |
11:52:04 | FromDiscord | <ChocolettePalette> p is actually a ref ref Person |
11:52:17 | FromDiscord | <ChocolettePalette> Because there's already 1 ref in declaration |
11:52:21 | FromDiscord | <scarf> In reply to @&Makarov/1 "m trying to play": does removing space between `alter` make changes? |
11:52:28 | FromDiscord | <ChocolettePalette> Isn't it? |
11:52:39 | FromDiscord | <scarf> (edit) "`alter`" => "`alter (n, hello)`" |
11:52:40 | FromDiscord | <Rika> In reply to @scarf "does removing space between": Yes |
11:53:26 | FromDiscord | <&Makarov/1> In reply to @ChocolettePalette "Because there's already 1": okaay 😂 |
11:53:49 | FromDiscord | <&Makarov/1> but the compiler says that it's just one ref 😂 |
11:54:21 | FromDiscord | <Rika> In reply to @&Makarov/1 "but the compiler says": It doesn’t |
11:54:29 | FromDiscord | <Rika> It’s just saying as it is |
11:56:07 | FromDiscord | <ChocolettePalette> Wtf why??? It is so CRINGE↵(@Rika) |
11:56:12 | FromDiscord | <&Makarov/1> sent a code paste, see https://play.nim-lang.org/#ix=4g7A |
11:56:34 | FromDiscord | <&Makarov/1> okay i removed "ref" from the `var n,m : Person` declaration |
11:56:57 | FromDiscord | <&Makarov/1> but still the same error ! |
11:57:11 | FromDiscord | <Rika> Remove the space between alter and (n, “hello”) |
11:57:29 | FromDiscord | <&Makarov/1> https://media.discordapp.net/attachments/371759389889003532/1042770450746458134/image.png |
11:57:42 | FromDiscord | <ChocolettePalette> > maybe misplaced space between alter and↵Ah if it's the design then OK |
11:57:45 | FromDiscord | <&Makarov/1> In reply to @Rika "Remove the space between": no change 🥲 |
11:57:57 | FromDiscord | <Rika> Show |
11:58:07 | FromDiscord | <Rika> Show the new error and the new code |
11:58:08 | FromDiscord | <&Makarov/1> https://media.discordapp.net/attachments/371759389889003532/1042770613829386250/image.png |
12:02:30 | FromDiscord | <&Makarov/1> sent a code paste, see https://play.nim-lang.org/#ix=4g7C |
12:02:31 | FromDiscord | <&Makarov/1> it's fixed here ! |
12:02:58 | FromDiscord | <&Makarov/1> thanks anyway 🙏 |
12:05:03 | FromDiscord | <Rika> Weird |
12:05:04 | FromDiscord | <&Makarov/1> in fact it's not working cause it doesnt affect the referenced value |
12:05:15 | FromDiscord | <Rika> Ah I see |
12:05:25 | FromDiscord | <&Makarov/1> is there any "address referencing" operator in nim |
12:05:29 | FromDiscord | <Rika> You removed the ref in the bar but not the one in the function signature |
12:05:31 | FromDiscord | <&Makarov/1> like "&" in C ? |
12:05:39 | FromDiscord | <&Makarov/1> In reply to @Rika "You removed the ref": yeah ! |
12:05:40 | FromDiscord | <Rika> Technically yes but not for ref |
12:05:48 | FromDiscord | <&Makarov/1> In reply to @Rika "Technically yes but not": ptr ? |
12:05:58 | FromDiscord | <Rika> Yes, “addr” function |
12:06:07 | FromDiscord | <&Makarov/1> hmm i didnt reach it yet |
12:06:40 | FromDiscord | <&Makarov/1> so what i'm trying to achieve is to get alter the person.name value fron the proc by passing a ref to it 🙁 |
12:07:05 | FromDiscord | <Rika> I’d help you but I’m on a phone so I don’t really want to program lol |
12:08:23 | FromDiscord | <&Makarov/1> yeah man take a break , thanks 🙏 |
12:08:33 | FromDiscord | <&Makarov/1> some how this works |
12:08:33 | FromDiscord | <&Makarov/1> sent a code paste, see https://play.nim-lang.org/#ix=4g7E |
12:12:11 | FromDiscord | <&Makarov/1> it explains a lot now 😂 https://media.discordapp.net/attachments/371759389889003532/1042774149233381407/image.png |
12:13:28 | FromDiscord | <Rika> Yeah ref ref object |
12:13:33 | FromDiscord | <Rika> Two pointers |
12:13:39 | FromDiscord | <&Makarov/1> nice |
12:13:46 | FromDiscord | <&Makarov/1> it's fun to play with this shit :joy |
12:13:50 | FromDiscord | <&Makarov/1> (edit) ":joy" => "😂" |
12:15:11 | FromDiscord | <&Makarov/1> hurray i got it 😂 , thanks guys ! |
12:15:12 | FromDiscord | <scarf> does `n` and `m` need allocation tho, for they are just references |
12:15:26 | FromDiscord | <&Makarov/1> they dont need ? |
12:15:36 | FromDiscord | <Rika> They do |
12:15:42 | FromDiscord | <Rika> In your scenario they need |
12:15:48 | FromDiscord | <Rika> Because you do new, then [] |
12:16:01 | FromDiscord | <Rika> If you only do [] you dereference a nil so |
12:16:59 | FromDiscord | <&Makarov/1> i guess they need @scarf https://media.discordapp.net/attachments/371759389889003532/1042775357792714853/image.png |
12:17:00 | FromDiscord | <scarf> sent a code paste, see https://play.nim-lang.org/#ix=4g7G |
12:17:15 | FromDiscord | <scarf> (edit) "https://play.nim-lang.org/#ix=4g7G" => "https://play.nim-lang.org/#ix=4g7H" |
12:17:43 | FromDiscord | <scarf> (edit) "https://play.nim-lang.org/#ix=4g7H" => "https://play.nim-lang.org/#ix=4g7J" |
12:17:58 | FromDiscord | <scarf> (edit) "https://play.nim-lang.org/#ix=4g7J" => "https://play.nim-lang.org/#ix=4g7L" |
12:18:14 | FromDiscord | <Rika> In reply to @scarf "what would be an": What does “const string” mean exactly |
12:18:23 | FromDiscord | <Rika> Because I’m not familiar with the semantics |
12:19:08 | FromDiscord | <&Makarov/1> immutable string ! |
12:19:36 | FromDiscord | <Rika> Yes but immutable in what ways |
12:19:48 | FromDiscord | <Rika> Because C++ is hell and I’m not sure of all the edge cases |
12:20:02 | FromDiscord | <scarf> In reply to @Rika "What does “const string”": my mistake, removed const because `alter` wouldn't work without it |
12:20:05 | FromDiscord | <Rika> Oh you edited it |
12:20:06 | FromDiscord | <Rika> Okay |
12:20:12 | FromDiscord | <Rika> Yeah I thought so too |
12:22:21 | FromDiscord | <&Makarov/1> In reply to @scarf "my mistake, removed const": you can keep the `const string & bar = &foo` |
12:22:36 | FromDiscord | <Rika> sent a long message, see http://ix.io/4g7Q |
12:25:16 | FromDiscord | <scarf> In reply to @Rika "var foo = "Hello"": are nim `addr` the same as C++ references? |
12:25:29 | FromDiscord | <MilesTheFox> Is it possible to make GUI app in Nim? |
12:25:40 | FromDiscord | <MilesTheFox> Like GTK app |
12:25:51 | PMunch | Yup |
12:26:01 | FromDiscord | <Rika> In reply to @scarf "are nim `addr` the": I don’t know , raw pointer |
12:26:09 | FromDiscord | <Rika> Same as C & |
12:26:27 | FromDiscord | <Rika> I think that C has that, I forgot |
12:26:33 | FromDiscord | <Rika> C in type |
12:26:44 | PMunch | C++ ref would be closer to a Nim ref wouldn't it? |
12:27:03 | FromDiscord | <Rika> I don’t know |
12:27:24 | PMunch | @MilesTheFox, there are plenty of ways to make GUI apps in Nim |
12:27:29 | PMunch | GTK included |
12:28:53 | PMunch | You can use it directly, or you might want to check out something like https://github.com/pmunch/gtkgenui |
12:29:25 | FromDiscord | <jmgomez> In reply to @PMunch "C++ ref would be": No, it would be closer to nim var |
12:29:47 | * | jmdaemon quit (Ping timeout: 256 seconds) |
12:30:03 | PMunch | Hmm, right |
12:30:07 | * | PMunch quit (Quit: Leaving) |
12:32:58 | FromDiscord | <&Makarov/1> In reply to @scarf "are nim `addr` the": i dont think soo |
12:33:29 | FromDiscord | <&Makarov/1> they are more like C pointer ! without afaik a referencing pointer |
12:34:08 | FromDiscord | <MilesTheFox> In reply to @PMunch "@MilesTheFox, there are plenty": Thank you! |
13:16:11 | FromDiscord | <b1rdf00d> sent a code paste, see https://play.nim-lang.org/#ix=4g82 |
13:16:33 | FromDiscord | <b1rdf00d> (edit) "https://play.nim-lang.org/#ix=4g82" => "https://play.nim-lang.org/#ix=4g83" |
13:28:17 | FromDiscord | <Rika> Parenthesise the ref Circle |
13:28:19 | FromDiscord | <Rika> That’s it |
13:28:28 | FromDiscord | <Rika> @b1rdf00d |
13:28:52 | FromDiscord | <.tochka> In reply to @b1rdf00d "I've got a ref": var circle = (ref Circle)(radius: 20.0) |
13:29:18 | FromDiscord | <Rika> That, yes |
13:30:27 | FromDiscord | <.tochka> you will get segfault in that example btw, as circle memory is assigned without being allocated |
13:31:07 | FromDiscord | <Rika> Yes, first example is broken |
13:31:42 | FromDiscord | <.tochka> wonder could this case be statically checked when obvious like that |
13:36:21 | FromDiscord | <.tochka> In reply to @&Makarov/1 "i dont think soo": they would be if marked as not nil, which they arent afaik. could probably be done in the future for addressing objects that are known to exist, such as automatics in functions and globals |
13:39:03 | FromDiscord | <b1rdf00d> Thanks! Rika and .tochka |
13:39:13 | FromDiscord | <b1rdf00d> (I'm discovering the segfault now 🙂 ) |
14:14:29 | FromDiscord | <.tochka> lol https://media.discordapp.net/attachments/371759389889003532/1042804927669481502/image.png |
14:29:28 | FromDiscord | <.tochka> cant replicate it on small scale... |
15:16:13 | FromDiscord | <MilesTheFox> Is there any Blowfish or Twofish library for Nim? |
15:22:15 | FromDiscord | <hmmm> broskis is there a sugary one liner way of testing if a string has only the characters 'a' or 'b' or 'c' in it |
15:24:27 | FromDiscord | <Yardanico> In reply to @hmmm "broskis is there a": yes |
15:24:29 | FromDiscord | <Yardanico> with sequtils |
15:24:42 | FromDiscord | <Yardanico> `mystr.allIt(it in {'a', 'b', 'c'})` |
15:24:51 | FromDiscord | <hmmm> ty yardy ❤️ |
15:27:06 | FromDiscord | <albassort> does if any exist in the stdlib |
15:38:07 | FromDiscord | <.tochka> yes |
15:38:20 | FromDiscord | <hmmm> nunununu all it doesn't work for me because "aaab" should pass the test |
15:38:28 | FromDiscord | <hmmm> allit requires a c to be present |
15:40:06 | FromDiscord | <albassort> In reply to @.tochka "yes": what is it called |
15:42:08 | * | kenran joined #nim |
15:42:10 | FromDiscord | <untoreh> sent a code paste, see https://play.nim-lang.org/#ix=4g8K |
15:42:39 | FromDiscord | <untoreh> it generates a new tag at `<scr` |
15:42:47 | FromDiscord | <Rika> In reply to @hmmm "allit requires a c": I don’t think so? |
15:42:48 | FromDiscord | <albassort> post code |
15:43:47 | FromDiscord | <Rika> !eval import sequtils; echo "aaab".allIt(it in {'a', 'b', 'c'}) |
15:43:52 | FromDiscord | <hmmm> In reply to @Rika "I don’t think so?": you are correct, I was dumb lol |
15:43:54 | NimBot | true |
15:44:12 | FromDiscord | <hmmm> HEY THE NIMBOT INSULTED ME |
15:44:13 | FromDiscord | <Rika> In reply to @hmmm "you are correct, I": ~~”was”?~~ |
15:44:14 | FromDiscord | <.tochka> In reply to @untoreh "`std/xmlparser` parses this incorrectly:": embedded text is not part o xml |
15:44:17 | FromDiscord | <hmmm> HEEEEEEEEY |
15:44:32 | FromDiscord | <hmmm> damn I'm getting torched left and right today 🧐 |
15:44:36 | FromDiscord | <.tochka> (edit) "o" => "of" |
15:45:13 | FromDiscord | <untoreh> In reply to @.tochka "embedded text is not": what about html? |
15:45:24 | FromDiscord | <Rika> In reply to @.tochka "embedded text is not": Note that HTML isn’t a set in XML |
15:45:39 | FromDiscord | <Rika> Which is why it fails |
15:45:40 | FromDiscord | <Rika> I assume |
15:45:53 | FromDiscord | <.tochka> In reply to @untoreh "what about html?": should work in xhtml and html |
15:45:59 | * | ixmpp quit (Ping timeout: 260 seconds) |
15:46:13 | FromDiscord | <untoreh> so its `std/htmlparser` bug |
15:46:25 | FromDiscord | <.tochka> hmmm |
15:47:10 | * | droidrage quit (Ping timeout: 256 seconds) |
15:47:13 | FromDiscord | <Rika> Didn’t you say you used the xml one |
15:47:33 | FromDiscord | <untoreh> I assumed it was xmlparser as an htmlparser dependencies |
15:47:43 | FromDiscord | <untoreh> (edit) "dependencies" => "dependency" |
15:48:21 | FromDiscord | <untoreh> they both spit out `XmlNode` trees |
15:53:54 | NimEventer | New thread by templatedperson: Procedure to remove modules from stdlib?, see https://forum.nim-lang.org/t/9627 |
15:58:00 | * | xet7 quit (Read error: Connection reset by peer) |
16:00:14 | FromDiscord | <DarkSky> helloo |
16:04:13 | FromDiscord | <Rika> hello |
16:13:10 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
16:13:47 | * | xet7 joined #nim |
16:14:03 | * | ehmry joined #nim |
16:14:24 | FromDiscord | <albassort> im looking for a proc to convert unicode to a string |
16:14:35 | FromDiscord | <albassort> i dont think its in unicode |
16:14:38 | FromDiscord | <albassort> do i have to do it... |
16:15:27 | FromDiscord | <albassort> yep |
16:15:28 | FromDiscord | <albassort> sad |
16:15:32 | FromDiscord | <Yardanico> In reply to @albassort "im looking for a": As in? |
16:15:39 | FromDiscord | <Yardanico> Nim strings are just bytes |
16:15:45 | FromDiscord | <albassort> yes |
16:15:50 | FromDiscord | <Yardanico> so what do you want to do |
16:16:27 | FromDiscord | <albassort> i give, say 0x30 and it gives me the char 0x30 |
16:17:08 | FromDiscord | <albassort> or i give it 0x257F and it gives me ╬ |
16:19:12 | FromDiscord | <Rika> do you know what charset that is |
16:19:37 | FromDiscord | <albassort> nope, I'll just invert a function i already have to convert chars to unicode |
16:21:43 | FromDiscord | <Rika> http://www.madore.org/~david/computers/unicode/cstab.html |
16:21:53 | FromDiscord | <Rika> `Tables of Common Character Sets↵Summary↵↵This page gives the tables of a few common character sets. The various cells contain the Unicode character that represents the character set's entry.` |
16:23:24 | FromDiscord | <albassort> be faster and simpler to just do some bitoperations |
16:23:28 | FromDiscord | <albassort> (edit) "bitoperations" => "bit operations" |
16:23:52 | FromDiscord | <albassort> is there a proc to get the minimum amount of bytes to contain this integer? |
16:30:46 | FromDiscord | <.tochka> amount of bytes for coded point? |
16:30:58 | FromDiscord | <.tochka> there graphemeLen in std/unicode |
16:31:27 | FromDiscord | <.tochka> at least if you're assuming utf8 by unicode |
16:31:47 | * | lampi quit (Remote host closed the connection) |
16:42:18 | FromDiscord | <albassort> no |
16:42:37 | FromDiscord | <albassort> for an integer you need to know how many bytes it takes up in order to convert it to utf8 |
16:44:28 | FromDiscord | <Rika> get the bit size of the stored integer, then subtract it by CLZ |
16:45:12 | FromDiscord | <Rika> theoretically `integ.sizeof8 - integ.countLeadingZeroBits == integ.bitsize` |
16:45:28 | FromDiscord | <albassort> i was writing a macro |
16:46:12 | FromDiscord | <Rika> countLeadingZeroBits is in bitops |
16:46:33 | FromDiscord | <Rika> note this is bitsize |
16:46:56 | FromDiscord | <Rika> you can always `(.../8).ceil` |
16:47:31 | FromDiscord | <Rika> or use div + mod + conditionals but thats smth im too lazy to write |
16:49:22 | FromDiscord | <albassort> In reply to @Rika "countLeadingZeroBits is in bitops": bytes dont start with 1 so its irrelevant |
16:49:31 | FromDiscord | <albassort> (edit) "bytes" => "integers" |
16:49:48 | FromDiscord | <albassort> i suppose you could round up |
16:49:57 | FromDiscord | <albassort> but thats just an extrapolation of what im doing |
16:51:00 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4g8Z |
16:51:51 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4g8Z" => "https://play.nim-lang.org/#ix=4g90" |
16:51:54 | FromDiscord | <albassort> disgusting |
16:54:10 | NimEventer | New thread by RodSteward: How to inject member identifiers in generics, see https://forum.nim-lang.org/t/9628 |
16:54:24 | FromDiscord | <albassort> doesn't compile dynamicly typed |
16:59:09 | FromDiscord | <albassort> alright gonna settle for just doing uint32 |
16:59:12 | FromDiscord | <albassort> (edit) "uint32" => "uint16" |
17:01:28 | FromDiscord | <Rika> In reply to @albassort "integers dont start with": What? |
17:02:00 | FromDiscord | <albassort> doesn't matter my idea isn't static |
17:03:23 | FromDiscord | <Rika> There is this |
17:03:25 | FromDiscord | <Rika> https://nim-lang.org/docs/math.html#nextPowerOfTwo%2Cint |
17:07:52 | * | derpydoo joined #nim |
17:10:24 | * | derpydoo quit (Client Quit) |
17:21:23 | * | kenran quit (Remote host closed the connection) |
17:23:24 | FromDiscord | <albassort> pretty scuffed here |
17:23:25 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4g97 |
17:24:24 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4g98 |
17:24:26 | FromDiscord | <Yardanico> nim has that in stdlib |
17:24:33 | FromDiscord | <Yardanico> or there's https://github.com/treeform/encode if you prefer |
17:24:41 | FromDiscord | <Yardanico> https://nim-lang.org/docs/widestrs.html is the stdlib module |
17:24:48 | FromDiscord | <albassort> useful |
17:25:16 | FromDiscord | <Yardanico> with widestrs it's just `$newWideCString(yourstringwithutf16bytes)` |
17:25:32 | FromDiscord | <albassort> no its an integer |
17:25:37 | FromDiscord | <albassort> oh wait |
17:25:51 | FromDiscord | <albassort> this takes unicode and spits out the utf8 |
17:26:07 | FromDiscord | <albassort> its specified uint16 because i dont want to code more bits |
17:26:08 | FromDiscord | <Yardanico> don't you have the whole string in seq/string as bytes? |
17:26:30 | FromDiscord | <albassort> https://media.discordapp.net/attachments/371759389889003532/1042853247465050143/image.png |
17:26:47 | FromDiscord | <albassort> outputs ゖ |
17:27:06 | FromDiscord | <Yardanico> but in a real program will you receive just a single codepoint or whole strings? |
17:27:30 | FromDiscord | <albassort> in a real program, i have a function which gets the unicode value, adds 60, then puts it through this |
17:29:06 | FromDiscord | <albassort> the function for that is |
17:29:16 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4g9c |
17:29:22 | FromDiscord | <albassort> if you're wondering why this is all strings |
17:29:29 | FromDiscord | <albassort> its because the strings are faster for some reason |
17:29:34 | FromDiscord | <albassort> i reprogrammed it in bits but it was slower |
17:29:37 | FromDiscord | <albassort> so i just reverted it |
17:29:46 | FromDiscord | <Yardanico> so again what do you want to do at the highest level? You have a UTF-8 string and you want to +60 all utf8 chars? |
17:29:58 | * | kenran joined #nim |
17:30:03 | FromDiscord | <albassort> here is how im using it |
17:30:20 | NimEventer | New thread by drkameleon: Using templates with generic or untyped parameters, see https://forum.nim-lang.org/t/9629 |
17:30:46 | FromDiscord | <albassort> シ -> unicode -> isKatakana -> シ-60 -> parseUnicode -> し |
17:31:42 | FromDiscord | <albassort> its kinda too late i already wrote my own shitty code |
17:33:47 | FromDiscord | <Yardanico> yeah I get that, I just want to understand what you're trying to do, because I feel like there's a much easier way |
17:34:13 | FromDiscord | <Yardanico> what does -60 mean here? utf8 value for that symbol is 12471 and -60 gives ほ |
17:35:49 | FromDiscord | <Yardanico> ahh 60 in hex |
17:36:23 | * | rockcavera joined #nim |
17:36:29 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4g9f |
17:36:34 | FromDiscord | <Yardanico> outputs 4 `し`s |
17:37:09 | FromDiscord | <albassort> ok so this is what i asked in the start |
17:37:49 | FromDiscord | <Yardanico> and what else do you need to do? |
17:38:37 | FromDiscord | <albassort> runes also destroy the need for my unicode thing |
17:38:38 | FromDiscord | <albassort> nice |
17:41:28 | FromDiscord | <jmgomez> @ShalokShalom did you see that they jetbrains pushed a new version of the Nim plugin? I think your comment made effect! ↵They support rendering on debug types now, I think they are the first on support that. Of course, no nimsuggest/autocomplete yet but seems to be alive again |
17:41:48 | FromDiscord | <Yardanico> wow really? |
17:41:53 | FromDiscord | <Yardanico> i thought it was abandoned for good :D |
17:42:10 | FromDiscord | <Yardanico> wow https://media.discordapp.net/attachments/371759389889003532/1042857191641727066/image.png |
17:42:22 | FromDiscord | <jmgomez> Yeah, https://twitter.com/PiotrekTomiak/status/1593237584159076352↵We should give it some love and RT it |
17:42:25 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/1042857254526910494/image.png |
17:42:29 | FromDiscord | <Yardanico> i should try it again now then |
17:42:50 | * | kenran quit (Remote host closed the connection) |
17:43:05 | FromDiscord | <Yardanico> In reply to @jmgomez "Yeah, https://twitter.com/PiotrekTomiak/status/1593": pls make a forum thread |
17:43:07 | FromDiscord | <Yardanico> a new one :) |
17:43:50 | FromDiscord | <Yardanico> going to download idea rn |
17:44:53 | FromDiscord | <Yardanico> or actually CLion, guess that'd fit more |
17:47:33 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4g9h |
17:47:47 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4g9i |
17:48:26 | FromDiscord | <Arathanis> are you trying to map original over the others? |
17:48:37 | FromDiscord | <hmmm> yea something like that |
17:48:40 | FromDiscord | <hmmm> but failed 😦 |
17:48:43 | FromDiscord | <Arathanis> taking the size of original |
17:48:53 | FromDiscord | <Arathanis> and replacing missing elements with the value in original? |
17:48:57 | FromDiscord | <ShalokShalom> In reply to @jmgomez "<@208199869301522432> did you see": Wonderful |
17:49:41 | FromDiscord | <hmmm> I mean if a seq is too short it should leave the zeros of original seq and if it's too long it should ignore the longer part |
17:50:00 | FromDiscord | <Arathanis> yes i understand |
17:50:24 | NimEventer | New thread by jmgomez: Jetbrains updated its Nim Plugin!, see https://forum.nim-lang.org/t/9630 |
17:51:32 | FromDiscord | <Arathanis> you should use `sequtils.zip` and compare the resulting length to the length of "original" then if its too short start padding the missing elements with the correct indexes from "original" |
17:51:46 | FromDiscord | <Arathanis> or easier, just compare lengths |
17:51:53 | FromDiscord | <Arathanis> if the case seq is too short, pad |
17:51:59 | FromDiscord | <Arathanis> if its too long or equal, just slice |
17:52:21 | FromDiscord | <Arathanis> (edit) "you" => "~~you" | ""original"" => ""original"~~" |
17:52:50 | FromDiscord | <hmmm> hmm I can do that, I was hoping for some simple for loop trickery to avoid a bunch of code 🙂 |
17:53:22 | FromDiscord | <Yardanico> In reply to @hmmm "hmm I can do": if `original` is always with 0s, it's just 2 lines of code |
17:53:29 | FromDiscord | <Yardanico> `setLen` |
17:53:32 | FromDiscord | <hmmm> ye original is always with 0 |
17:54:02 | FromDiscord | <Yardanico> ? |
17:54:03 | FromDiscord | <hmmm> setlen slashes the longer seq right? but what about the padding |
17:54:05 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4g9j |
17:54:15 | FromDiscord | <Yardanico> In reply to @hmmm "setlen slashes the longer": it expands if it's too short, removes if it's too long |
17:54:18 | FromDiscord | <Yardanico> kinda obvious from the name |
17:54:27 | FromDiscord | <hmmm> woa |
17:54:35 | FromDiscord | <hmmm> this is so comfy |
17:54:35 | FromDiscord | <Arathanis> and since default int value is 0, the expand should fill with 0s! |
17:54:38 | FromDiscord | <Arathanis> good call @Yardanico |
17:54:51 | FromDiscord | <Arathanis> if you want to pad with non-zero you will have to add more logic |
17:54:54 | FromDiscord | <Arathanis> just keep that in mind |
17:55:00 | FromDiscord | <Yardanico> yeah, setLen is useful for lower level stuff especially because it doesn't change the capacity |
17:55:11 | FromDiscord | <Yardanico> so you can reuse the same buffer if you have some code that adds to the seq, and then you need to "reset" it |
17:55:15 | FromDiscord | <Yardanico> so you won't allocate every loop iteration |
17:56:10 | FromDiscord | <Yardanico> In reply to @jmgomez "Yeah, https://twitter.com/PiotrekTomiak/status/1593": i checked, they do seem to have some debugging support and some defaults |
17:56:22 | FromDiscord | <Yardanico> e.g. they already provide some built-in expression so the editor can read nim strings, but only with refc |
17:56:30 | FromDiscord | <Yardanico> arc/orc have strings/seq with a different internal layout so they can't be read |
17:56:44 | FromDiscord | <Yardanico> maybe I should try doing lldb expressions for that myself |
17:56:55 | FromDiscord | <Yardanico> ah right, you just can't really do that for tables |
17:57:02 | FromDiscord | <Yardanico> they don't store the original values for keys, only hashes :P |
17:58:01 | * | derpydoo joined #nim |
17:58:45 | FromDiscord | <jmgomez> Ohh I see, I tried with rider on NUE but I assumed it didnt work with dlls or something with my setup. But then it's ORC? Although I saw the statcktrace listed, downloading clion now.. |
17:59:16 | * | junaid__ joined #nim |
17:59:35 | FromDiscord | <Yardanico> In reply to @jmgomez "Ohh I see, I": what didn't work? |
17:59:41 | FromDiscord | <Yardanico> if you mean strings, then it's because devel defaults to orc |
17:59:49 | FromDiscord | <Yardanico> and the extension seems to only understand strings/seqs for refc |
18:00:07 | FromDiscord | <Yardanico> they have different internal representation in arc/orc so it doesn't work |
18:00:31 | FromDiscord | <ShalokShalom> In reply to @jmgomez "Ohh I see, I": I am also about to use it on Rider. |
18:00:32 | FromDiscord | <jmgomez> On the other hand debugging alongside intellisense, are the most important tools that a dev would want.. I have zero idea of lldb but we should push it. For the hashes, the compiler does know if you are debugging so it can emit the proper symbols/values.. |
18:00:43 | FromDiscord | <ShalokShalom> Do you use it for the Unreal support? |
18:00:45 | FromDiscord | <Yardanico> well lldb can be easily used in vscode and all that |
18:00:47 | FromDiscord | <jmgomez> Yeah, I use ORC on NUE too.. |
18:00:51 | * | junaid__ quit (Quit: leaving) |
18:01:08 | FromDiscord | <Yardanico> There's really nothing new in how this extension does debugging really, it just provides a way for it to work out of the box :) |
18:01:09 | FromDiscord | <ShalokShalom> I wonder if I can use both F# and Nim for one Unreal project. |
18:01:15 | FromDiscord | <ShalokShalom> That would be really cool. |
18:01:17 | FromDiscord | <Yardanico> and then it uses the same usual stuff for getting actual Nim values |
18:01:26 | FromDiscord | <Yardanico> nim-gdb does the same but it's not really maintained, we could rewrite it to use LLDB |
18:01:43 | FromDiscord | <Yardanico> also nim-gdb uses nim runtime type info kinda a lot, and that just doesn't exist with arc/orc |
18:01:50 | FromDiscord | <jmgomez> In reply to @Yardanico "nim-gdb does the same": I would help if someone else leads the project.. |
18:02:05 | FromDiscord | <jmgomez> And also to improve the intellisense with another approach different than nim suggest |
18:02:20 | FromDiscord | <jmgomez> In reply to @ShalokShalom "I wonder if I": how would you use F#? |
18:02:27 | FromDiscord | <ShalokShalom> UnrealCLR |
18:02:30 | FromDiscord | <jmgomez> UnrealCLR, with all my respect, it's a toy |
18:02:44 | FromDiscord | <ShalokShalom> Its currently not yet compatible with Unreal 5 |
18:02:46 | FromDiscord | <Yardanico> In reply to @jmgomez "And also to improve": the main problem with non-nimsuggest is macros |
18:02:49 | FromDiscord | <Yardanico> and templates too |
18:02:57 | FromDiscord | <ShalokShalom> I will see 👀 |
18:02:58 | FromDiscord | <jmgomez> Proper unreal bindings is not just interop with cpp |
18:03:16 | FromDiscord | <Yardanico> it will work for basic Nim code just fine, but when you get into macros, compileTime functions, templates, it'll stop working |
18:03:24 | FromDiscord | <jmgomez> In reply to @Yardanico "the main problem with": Yeah, but NimSuggest is still there for that |
18:03:55 | FromDiscord | <Yardanico> I guess I'll look at LLDB soon again, see how simple it is to at least get expressions for strings/seqs, should be really simple |
18:04:09 | FromDiscord | <ShalokShalom> Do you suggest to drop Nim suggest completely? |
18:04:14 | FromDiscord | <jmgomez> In reply to @Yardanico "I guess I'll look": Okay, keep updated pls if you do so |
18:04:14 | FromDiscord | <ShalokShalom> Or just for this case |
18:04:37 | FromDiscord | <jmgomez> In reply to @ShalokShalom "Do you suggest to": No.. |
18:04:42 | FromDiscord | <Elegantbeef> I still need to toy with the compiler to emit `debug` procedures that the nim pretty printer can call |
18:05:01 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4g9l |
18:05:15 | FromDiscord | <jmgomez> NimSuggest is great.. Im saying that you can use another approach (much faster) for regular nim code |
18:05:16 | FromDiscord | <Elegantbeef> You just did |
18:05:19 | FromDiscord | <Yardanico> In reply to @Jessa "how would i make": your code just works as is |
18:05:22 | FromDiscord | <Yardanico> nim has UFCS |
18:05:26 | FromDiscord | <Yardanico> a.b() is same as b(a) |
18:05:39 | FromDiscord | <Jessa> wait what |
18:05:41 | FromDiscord | <Jessa> really |
18:05:41 | FromDiscord | <Yardanico> lol |
18:05:42 | FromDiscord | <Elegantbeef> But regular nim code has templates and macros↵(@jmgomez) |
18:05:43 | FromDiscord | <Yardanico> yes |
18:05:46 | FromDiscord | <Jessa> omg |
18:05:52 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#procedures-method-call-syntax |
18:06:06 | FromDiscord | <Jessa> holy fuck |
18:06:09 | FromDiscord | <Jessa> i love nim |
18:06:17 | FromDiscord | <jmgomez> In reply to @Elegantbeef "But regular nim code": right, regular nim code except templates and macros then |
18:06:29 | FromDiscord | <jmgomez> for templates and macros NimSuggest is fine |
18:07:45 | FromDiscord | <Yardanico> @jmgomez this is how codelldb extension with nim looks ootb in vscode |
18:07:47 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/1042863636651188365/image.png |
18:07:52 | FromDiscord | <Jessa> that's actually amazing, i love how it automatically kind of knows to make the string_function an extension of string↵↵i'm so used to python where it's basically impossible to do that |
18:08:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g9n |
18:08:22 | FromDiscord | <Elegantbeef> Not using a compiler to give code suggestions is a dead end if you ask me |
18:08:39 | FromDiscord | <Yardanico> at least for compiled languages I'd kind of agree, there's just too much going on |
18:08:52 | FromDiscord | <Yardanico> all the types and stuff, you'd have reimplement large parts of the compiler yourself otherwise |
18:09:06 | FromDiscord | <Elegantbeef> Or you dont and the tooling is mostly useless |
18:09:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g9o |
18:09:50 | FromDiscord | <Elegantbeef> How does it know whether x is mutable |
18:09:55 | FromDiscord | <jmgomez> In reply to @Yardanico "": yeah, same in regular VS and my current Rider setup.. |
18:10:18 | FromDiscord | <Yardanico> well that's how it'd look like, the jetbrains extension didn't really add much to it |
18:10:20 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4g9p |
18:10:24 | FromDiscord | <Yardanico> they just added some defaults for strings and the like |
18:10:29 | FromDiscord | <jmgomez> I mean ideally it would work better, but it doesnt.. |
18:10:40 | FromDiscord | <Elegantbeef> The real thing for debugging is emitting debugging procedures |
18:10:54 | FromDiscord | <Elegantbeef> If someone adds that functionality into the compiler we're golden |
18:10:59 | FromDiscord | <Elegantbeef> No more complex pretty printer |
18:11:21 | FromDiscord | <Elegantbeef> You just call the nim debug procedure and you've got complex types showing up when debugging |
18:11:34 | FromDiscord | <Yardanico> debuggers can call native code from the binaries themselves? |
18:11:49 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/devel/tools/nim-gdb.py#L135-L171 |
18:12:17 | FromDiscord | <Yardanico> oh yeah at least for $ |
18:12:21 | FromDiscord | <Elegantbeef> Nim's already allows you to call the `$` proc, but Nim doesnt emit one for everytype nor mark it `extern` |
18:12:31 | FromDiscord | <jmgomez> I think it's important enough to be considered |
18:12:36 | FromDiscord | <Yardanico> and if it's not extern you can't call it from gdb? |
18:12:38 | FromDiscord | <Elegantbeef> This is a much better way of handling pretty printer imo |
18:12:47 | FromDiscord | <Elegantbeef> Well extern code doesnt get DCE'd out |
18:12:53 | FromDiscord | <jmgomez> (edit) "considered" => "considered↵https://discord.com/channels/371759389889003530/371759389889003532/1042864423070617671" |
18:12:56 | FromDiscord | <Yardanico> ah you mean exportc ? |
18:13:13 | FromDiscord | <Elegantbeef> Same difference 😜 |
18:13:29 | FromDiscord | <Elegantbeef> I know it's not |
18:13:30 | FromDiscord | <Elegantbeef> but meh |
18:13:35 | FromDiscord | <Yardanico> can't one just create a small lib/prelude file that just has a single exportc proc by calling $ for most stdlib types? |
18:13:47 | FromDiscord | <Yardanico> i know then it's not 0 effort, but a single import is still good enough |
18:13:54 | FromDiscord | <Elegantbeef> One could but the issue is that still can be DCE'd |
18:13:59 | FromDiscord | <Yardanico> not if it's exportc ? |
18:14:09 | FromDiscord | <Elegantbeef> missed the exportc part |
18:14:22 | FromDiscord | <Yardanico> yeah ugly, but I think it'd work |
18:14:53 | FromDiscord | <.tochka> hm, could unmanaged pointer be casted to var array |
18:15:03 | FromDiscord | <.tochka> you cant assign to items of non-var array right? |
18:15:13 | FromDiscord | <Yardanico> if you want to have nice array syntax, use UncheckedArray[T] |
18:15:24 | FromDiscord | <Elegantbeef> `cast[ptr UncheckedArray[T]](myPtr)` |
18:15:40 | FromDiscord | <.tochka> yes, but you lose length guarantee |
18:15:51 | FromDiscord | <Elegantbeef> you can cast it to an array aswell |
18:15:55 | FromDiscord | <Elegantbeef> Or use toOpenArray after |
18:16:02 | FromDiscord | <Elegantbeef> I'd suggest the latter more |
18:16:50 | FromDiscord | <.tochka> non static length 😔 |
18:16:54 | FromDiscord | <Elegantbeef> But yea yardanico that's a way of doing it, but really the compiler should emit `gdb_debug` procedures for every type |
18:17:21 | FromDiscord | <Yardanico> In reply to @.tochka "non static length 😔": > you can cast it to an array as well |
18:17:24 | FromDiscord | <Elegantbeef> Instead of using RTTI and attempting to figure out the data |
18:17:30 | FromDiscord | <.tochka> In reply to @Yardanico "> you can cast": but not a var one |
18:17:43 | FromDiscord | <Yardanico> why not? |
18:17:45 | FromDiscord | <Elegantbeef> `ptr array[l, t]` is a var |
18:17:53 | FromDiscord | <Elegantbeef> It's a L-value == var |
18:18:10 | FromDiscord | <.tochka> oh this way |
18:18:20 | FromDiscord | <Elegantbeef> You can likely also do `var array[l, t]` |
18:18:34 | FromDiscord | <Elegantbeef> Though i might misremember that |
18:21:00 | FromDiscord | <Elegantbeef> Thinking about it yard your idea falls apart with generics |
18:21:07 | * | junaid_ joined #nim |
18:21:33 | FromDiscord | <Elegantbeef> Only the compiler or someone that manually emits a debug proc can do it |
18:21:59 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4g9u |
18:22:06 | FromDiscord | <Yardanico> did this never work? |
18:24:33 | FromDiscord | <Elegantbeef> Is `$` not seen as a infix operator here? |
18:24:59 | FromDiscord | <Elegantbeef> Yea it is |
18:25:09 | FromDiscord | <Elegantbeef> `a op b` is always an infix operator |
18:28:59 | FromDiscord | <ShalokShalom> @jmgomez I installed Rider and the Nim plugin.↵↵Do you create a new dotnet solution, when you want a pure Nim project? |
18:29:27 | FromDiscord | <ShalokShalom> The new solution dialog, seems not to offer any Nim solution |
18:29:40 | FromDiscord | <ShalokShalom> I would just like an empty file 😄 |
18:30:05 | FromDiscord | <Yardanico> just open any empty folder :P |
18:31:00 | FromDiscord | <ShalokShalom> Ah really? |
18:31:01 | FromDiscord | <ShalokShalom> Nice |
18:32:47 | FromDiscord | <ShalokShalom> Its really obvious, that the developers of Rider use the software themselves |
18:33:37 | FromDiscord | <Arouzing> So I know this is a simple thing. But like love how parentheses aren't required when applying procs to objects. |
18:33:41 | FromDiscord | <ShalokShalom> Lets you wonder, in which world we could be, when every product would be made by developers for developers and they simultaneously gain enough money for it |
18:34:13 | FromDiscord | <ShalokShalom> In reply to @Arouzing "So I know this": Particularly imperative and oo languages are noisy. |
18:34:28 | FromDiscord | <ShalokShalom> Functional languages are more often similar in style to Nim. |
18:34:50 | FromDiscord | <ShalokShalom> Its what brought me to Nim in the first place, so I definitely understand you. |
18:35:40 | FromDiscord | <Arouzing> It was a little thing that when I learned it made me smile. |
18:35:52 | FromDiscord | <haxscramper> By the way @ShalokShalom I wanted to ask -- are you working on some software in nim? I looked at discord history and you've been around for quite some time actually (2020) so you probably have several things you worked on during that time |
18:36:51 | FromDiscord | <ShalokShalom> I did not visit the community for several years |
18:37:55 | FromDiscord | <ShalokShalom> And I worked mostly on myself in that time 😅 |
18:39:18 | FromDiscord | <ShalokShalom> Meaning I read a lot of literature, communicated with people online, watched videos, lots of theoretical background stuff.↵↵I know that practical development make huge of a difference, and I appreciate the inspiration 😅 |
18:40:21 | FromDiscord | <ShalokShalom> And I never wanted to storm ahead and start developing with the first language that I come across.↵↵I am a blank sheet of paper, and haven't made my mind up about which language and framework I wanna specialize about up until very recently |
18:40:39 | FromDiscord | <ShalokShalom> I wanted to study the environment, before I actually settle down. 🙂 |
18:43:02 | * | junaid_ quit (Remote host closed the connection) |
18:43:15 | * | jjido joined #nim |
18:49:27 | * | xet7 quit (Ping timeout: 256 seconds) |
18:49:46 | FromDiscord | <jmgomez> @Yardanico just tested it with both, orc and refc and it's pretty bad. Still good news that they pretend to improve it, ping me out if you ever start looking it lldb. It has been on my roadmap since the very beginning: https://github.com/jmgomez/NimForUE/blob/4f8ff5b64bdce33ef9faac766a3e5931e90087c0/Readme.md?plain=1#L140 |
18:53:24 | FromDiscord | <ShalokShalom> In reply to @jmgomez "<@177365113899057152> just tested it": If you were right, and my comment caused this, then they had just a few days time |
18:53:27 | * | Guest47 joined #nim |
18:53:35 | FromDiscord | <ShalokShalom> Maybe they improve more now and commit to it |
18:53:54 | FromDiscord | <ShalokShalom> ✌🏻 |
18:54:00 | * | Guest47 quit (Client Quit) |
18:57:14 | * | jmdaemon joined #nim |
18:58:09 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How would i turn parsed toml into json object? |
18:58:44 | FromDiscord | <Phil> Like you have a nim object and want a JSON string? |
19:00:06 | FromDiscord | <Phil> If you want to use std/json, just use the `%` proc, if you're fine with using jsony (another lib for the same purpose but faster and imo better), use `toJson()` after importing jsony |
19:00:48 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4g9D |
19:00:58 | FromDiscord | <jmgomez> you can use toJSon with the std one too |
19:01:04 | FromDiscord | <jmgomez> (edit) "toJSon" => "toJson" |
19:01:19 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4g9E |
19:01:20 | FromDiscord | <Elegantbeef> `(kind, path) in lsdirseq` |
19:01:41 | FromDiscord | <Elegantbeef> `kind, path in lsdirseq` calls `pairs` which yields `(int, tuple)` |
19:02:13 | FromDiscord | <Elegantbeef> you need `\\` on any `\` that are supposed to be in the string↵(@Jessa) |
19:02:22 | FromDiscord | <Jessa> yes |
19:02:23 | FromDiscord | <Jessa> i do |
19:02:24 | FromDiscord | <Elegantbeef> At the very end i see `\]` |
19:02:35 | FromDiscord | <user2m> In reply to @Elegantbeef "`kind, path in lsdirseq`": perfect! |
19:02:43 | FromDiscord | <Jessa> wait |
19:03:01 | FromDiscord | <Jessa> so, i need 4`\`'s for every escaped `\`? |
19:03:04 | FromDiscord | <Elegantbeef> !eval echo ']' |
19:03:09 | NimBot | ] |
19:03:12 | FromDiscord | <Jessa> (edit) "so, i need 4`\`'s for every escaped `\`? ... " added "in nim regex" |
19:03:13 | FromDiscord | <Elegantbeef> Shit |
19:03:14 | FromDiscord | <Elegantbeef> Anyway |
19:03:35 | FromDiscord | <Elegantbeef> No |
19:03:42 | FromDiscord | <Elegantbeef> You need to escape `\` in the literal |
19:04:13 | FromDiscord | <Elegantbeef> You also might be able to do `fmt"""yourregexhere"""` |
19:04:26 | FromDiscord | <Elegantbeef> or \`fmt"yourregexhere"\~ |
19:04:41 | FromDiscord | <Elegantbeef> raw string literals do not do escaping |
19:04:45 | FromDiscord | <Elegantbeef> both of the above are raw string literals |
19:04:52 | FromDiscord | <ZaZi> Hello |
19:04:58 | FromDiscord | <Jessa> ii see |
19:05:20 | FromDiscord | <Phil> It's the `\` near whitelist that are murdering you... well it compiles if you double up the backslashes on those |
19:05:29 | FromDiscord | <Elegantbeef> Though i'm still dubious of regex |
19:05:41 | FromDiscord | <Phil> I have no idea what that regex is supposed to look like either |
19:05:51 | FromDiscord | <Phil> Also, cheers ZaZi |
19:05:56 | FromDiscord | <Elegantbeef> It's not supposed to look like regex |
19:06:08 | FromDiscord | <Elegantbeef> What's the format of what you're attempting to capture? |
19:06:29 | FromDiscord | <Elegantbeef> I dislike regex so i'm probably going to be an idiot about this |
19:07:22 | FromDiscord | <Phil> I personally don't mind them, but the last time I had to use them was ages ago and learning the individual steps to actually make one in a given language, what needs additional escaping where etc. is always a bit of a re-learn |
19:07:29 | FromDiscord | <Jessa> sent a long message, see http://ix.io/4g9H |
19:07:48 | FromDiscord | <Elegantbeef> I mean i want to know what you're attempting to capture |
19:07:58 | FromDiscord | <Elegantbeef> The pattern doesnt help me much since i dont use regex 😄 |
19:08:14 | FromDiscord | <Jessa> how do you mean, what i'm trying to capture? |
19:08:21 | FromDiscord | <Elegantbeef> I avoid it like the plague as it's a horrid API that is unreadable and unmaintainable |
19:08:32 | FromDiscord | <Elegantbeef> What are you attempting to do with the regex |
19:08:37 | FromDiscord | <Jessa> In reply to @Jessa "simiplified regex i'm trying": ^ |
19:08:41 | FromDiscord | <Elegantbeef> Match, search, .... parse |
19:08:51 | FromDiscord | <Phil> Jessa wants the string `"[potato]"` to match I believe, but not `"\\[potato]"` |
19:08:56 | FromDiscord | <Phil> (edit) "`"\\[potato]"`" => "`"\[potato]"`" |
19:09:10 | FromDiscord | <Jessa> yes- |
19:09:13 | FromDiscord | <Phil> R being a placeholder for whatever |
19:09:23 | FromDiscord | <ZaZi> Im new to Nim and have a few question before I might learn can Nim compile for riscv? |
19:09:36 | FromDiscord | <Phil> is R just anything in the whitelist? |
19:09:41 | FromDiscord | <Phil> Or is it literally anything? |
19:10:18 | FromDiscord | <Jessa> whitelist will be compiled of whatever i decide to put in there |
19:10:25 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g9I |
19:11:00 | FromDiscord | <Elegantbeef> then you can do `if myData in myWhiteList` |
19:11:19 | FromDiscord | <Elegantbeef> No clue if it's technically supported but it's likely capable↵(@ZaZi) |
19:11:24 | FromDiscord | <Phil> I think it's not `$+`, it's one of "list of entries in a seq[string]" |
19:11:26 | FromDiscord | <Jessa> honestly, the regex works fine, that's not the problem↵it's just not compiiling |
19:11:42 | FromDiscord | <Elegantbeef> I mean i gave the solution for the regex |
19:11:54 | FromDiscord | <Elegantbeef> `\]` is an invalid character |
19:12:00 | FromDiscord | <Elegantbeef> you need to escape any `\` with `\\` |
19:12:07 | FromDiscord | <Elegantbeef> or use raw string lits |
19:12:28 | FromDiscord | <Elegantbeef> This latter part is me disliking regex cause it's awful 😛 |
19:12:31 | FromDiscord | <Jessa> yes, and i'm wondering if to check for `\` in regex, ii need `\\` or `\\\\` |
19:12:31 | FromDiscord | <Elegantbeef> I said i was being an idiot! |
19:12:31 | FromDiscord | <Phil> All the unnecessary `()` brackets are kinda throwing me off unless there's extra logic involved |
19:12:49 | FromDiscord | <Elegantbeef> you need `\\` |
19:12:53 | FromDiscord | <Elegantbeef> I dont get why you'd need 4 |
19:13:08 | FromDiscord | <Elegantbeef> `\` is the start of a character literal `\\` is a character `'\'` |
19:14:47 | FromDiscord | <Elegantbeef> Like i said this is easier though |
19:14:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g9L |
19:15:37 | FromDiscord | <Jessa> In reply to @Isofruit "All the unnecessary `()`": let me writie out the regex explenation |
19:16:23 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4g9N |
19:16:51 | FromDiscord | <qb> (edit) "https://play.nim-lang.org/#ix=4g9N" => "https://play.nim-lang.org/#ix=4g9O" |
19:17:07 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4g9P |
19:18:14 | FromDiscord | <Jessa> (edit) "https://play.nim-lang.org/#ix=4g9P" => "https://play.nim-lang.org/#ix=4g9Q" |
19:18:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4g9R |
19:18:38 | FromDiscord | <Jessa> (edit) "https://play.nim-lang.org/#ix=4g9Q" => "https://play.nim-lang.org/#ix=4g9S" |
19:18:50 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4g9T |
19:23:49 | FromDiscord | <DarkSky> How can i get current date in `yyy-MM-dd`? |
19:23:57 | FromDiscord | <DarkSky> i went through the whole docs and can |
19:24:02 | FromDiscord | <DarkSky> (edit) "can" => "can't find it" |
19:24:10 | FromDiscord | <DarkSky> (sorry im new) |
19:27:22 | FromDiscord | <Elegantbeef> !eval import std/times; echo now().format("yyyy-MM-dd") |
19:27:31 | NimBot | Compile failed: 2022-11-17 |
19:27:43 | FromDiscord | <Elegantbeef> Close enough |
19:28:14 | FromDiscord | <DarkSky> oooooooooooooooooooooooooooooh lol that makes sense |
19:28:22 | FromDiscord | <DarkSky> my bad, i started learning today |
19:28:26 | FromDiscord | <DarkSky> trying to get used to the syntax |
19:30:54 | FromDiscord | <DarkSky> sent a code paste, see https://play.nim-lang.org/#ix=4g9V |
19:31:16 | FromDiscord | <DarkSky> (edit) "https://play.nim-lang.org/#ix=4g9V" => "https://play.nim-lang.org/#ix=4g9W" |
19:31:54 | FromDiscord | <ZaZi> does nim have pointers? |
19:32:03 | FromDiscord | <.tochka> yes |
19:32:38 | FromDiscord | <.tochka> In reply to @ZaZi "does nim have pointers?": https://nim-lang.org/docs/manual.html#types-reference-and-pointer-types |
19:32:41 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Anyone know how i would convert parsed toml into json? |
19:34:07 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Nvm im stupid |
19:34:35 | FromDiscord | <DarkSky> sent a code paste, see https://play.nim-lang.org/#ix=4g9X |
19:35:02 | * | xet7 joined #nim |
19:35:03 | * | arkurious joined #nim |
19:35:55 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4g9Z |
20:21:53 | FromDiscord | <voxal> sent a code paste, see https://play.nim-lang.org/#ix=4ga9 |
20:26:26 | FromDiscord | <voxal> sent a code paste, see https://play.nim-lang.org/#ix=4gab |
20:35:54 | FromDiscord | <albassort> is there anyway to get all the variables on a object |
20:38:45 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4gae this is a bit ugly, but it's likely more efficient↵(@qb) |
20:38:55 | FromDiscord | <Elegantbeef> Basically we check if the end/start match |
20:39:06 | FromDiscord | <Elegantbeef> For what reason?↵(@albassort) |
20:39:26 | FromDiscord | <albassort> serialization stuff\ |
20:39:27 | FromDiscord | <Elegantbeef> compile with `--mm:refc`↵(@voxal) |
20:39:29 | FromDiscord | <albassort> (edit) "stuff\" => "stuff" |
20:39:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gaf |
20:40:04 | FromDiscord | <Elegantbeef> Otherwise i suggest using disruptek's assume |
20:40:17 | FromDiscord | <Elegantbeef> it's typeit works well for object variants |
20:40:22 | FromDiscord | <Elegantbeef> You could also just use frosty in that case |
20:41:21 | FromDiscord | <Elegantbeef> whoops `myobj.fieldpairs` |
20:41:26 | FromDiscord | <Elegantbeef> or `for field in myObj.fields` |
20:41:26 | FromDiscord | <albassort> i realized my idea is stupid |
20:41:28 | FromDiscord | <albassort> nevermind |
20:41:35 | FromDiscord | <albassort> hmm actually |
20:41:43 | FromDiscord | <albassort> nah actually its stupid |
20:41:46 | FromDiscord | <albassort> unless |
20:42:56 | FromDiscord | <Jessa> i'm curious↵would there be a way to get all functions / procs within the nim file? |
20:43:16 | FromDiscord | <Elegantbeef> There is not |
20:43:23 | FromDiscord | <voxal> In reply to @Elegantbeef "compile with `--mm:refc` (<@290952090560364545>)": thanks, what does this flag mean exactly? |
20:43:26 | FromDiscord | <Elegantbeef> There are some hacky ways but there is not really a way to do it |
20:43:33 | FromDiscord | <Jessa> i see |
20:43:38 | FromDiscord | <Elegantbeef> it uses the gc instead of orc which is the default o ndevel |
20:43:46 | FromDiscord | <voxal> ah i see |
20:43:58 | FromDiscord | <Elegantbeef> jester seems to not be written in an orc friendly way |
20:44:10 | FromDiscord | <Elegantbeef> httpx i think is orc friendly |
20:44:21 | FromDiscord | <albassort> i can think of a few very hacky ways |
20:44:29 | FromDiscord | <albassort> but like |
20:44:30 | FromDiscord | <voxal> ill look into it thanks |
20:44:34 | FromDiscord | <albassort> nothing you 'd want to practically do |
20:45:22 | FromDiscord | <Elegantbeef> I might have meant prologue |
20:46:26 | FromDiscord | <Elegantbeef> albassort if you mean the list all procs in a file you basically parse the file using `parseStmt` then iterate it |
20:46:30 | FromDiscord | <Elegantbeef> It's very much not a good idea |
20:46:38 | FromDiscord | <albassort> yea |
20:47:04 | FromDiscord | <albassort> im going to make a bidirectional table by using stale memory |
20:47:04 | FromDiscord | <Elegantbeef> There very much needs to be a macro for `allExportedSymbols` |
20:48:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/FiI |
20:48:55 | FromDiscord | <albassort> I just realized why bidrectional hastables are hard |
20:49:27 | FromDiscord | <albassort> my idea was to allocate a block of memory and then alternate key value pairs |
20:49:36 | FromDiscord | <albassort> say int to int |
20:49:43 | FromDiscord | <albassort> 3929320123921 |
20:49:55 | FromDiscord | <albassort> (edit) "3929320123921" => "390|209|320|123|921" |
20:50:04 | FromDiscord | <albassort> but thats kinda blegh |
21:04:35 | FromDiscord | <albassort> its going to be bi-tri-directonal |
21:05:08 | FromDiscord | <Generic> I have not looked into other implementations, but I guess it is a big know your usecase thing |
21:05:28 | FromDiscord | <Generic> like dependind on whether you access more often via one side |
21:05:29 | FromDiscord | <albassort> I'm looking for implementations |
21:05:36 | FromDiscord | <Generic> or whether the key is lightweight or not |
21:07:15 | FromDiscord | <albassort> obvious the worst case scenario, the one im heading for, is O(n) |
21:07:30 | FromDiscord | <albassort> scalling up a block of memory |
21:07:59 | FromDiscord | <albassort> i dont know if a O(1) solution is possible for a directional map |
21:26:48 | FromDiscord | <Phil> I felt tempted to use mold since apparently it speeds up compilation.↵Then I realized I deploy my only larger project in an alpine container and compile with musl-gcc, which isn't compatible with mold it appears.↵Now I'm just saddened |
21:27:50 | FromDiscord | <Phil> (edit) "I felt tempted to use mold ... sincecompilation" added "linker" | "compilation.↵Then" => "compilation in the lto phase quite significantly.↵Then" |
21:28:25 | FromDiscord | <Yardanico> In reply to @Isofruit "I felt tempted to": use zig cc with mold? |
21:28:36 | FromDiscord | <Yardanico> and also mold will only speed up linking, not compilation |
21:28:52 | FromDiscord | <Yardanico> LTO wouldn't be managed by mold anyway |
21:29:03 | FromDiscord | <Phil> Doesn't linking count as part of the compilation phase ? |
21:29:21 | FromDiscord | <Yardanico> you can say that, true, but again, mold is only useful for projects that are big |
21:29:27 | FromDiscord | <Yardanico> like hundreds of MBs of object files |
21:29:29 | FromDiscord | <.tochka> In reply to @albassort "i dont know if": for lookup? |
21:29:46 | FromDiscord | <Phil> Alrighty, then at least I didn't get my terminology entirely wrong |
21:31:06 | FromDiscord | <albassort> In reply to @.tochka "for lookup?": well, yea... taking from memory address the lookup specifies will usually take O(n) of the size of the pointer or block of data |
21:31:09 | FromDiscord | <.tochka> you usually dont have consatnt O(1) in any sort of map, as bucket clashes are a thing |
21:31:24 | FromDiscord | <albassort> yes |
21:31:35 | FromDiscord | <albassort> for a one directional map |
21:31:49 | FromDiscord | <albassort> but i cant find an algorithm for a bidirectional map |
21:31:56 | FromDiscord | <albassort> so that makes me think it'll be O(1) |
21:32:31 | FromDiscord | <.tochka> my stupid idea for optimized lookup bidirectional, but it would be memory hungry and a mess to keep the states on mutations https://media.discordapp.net/attachments/371759389889003532/1042915161725472828/image.png |
21:32:59 | FromDiscord | <albassort> the only benefit to bidirectional is memory |
21:33:20 | FromDiscord | <albassort> if you need state you might as well just use two tables |
21:33:44 | FromDiscord | <.tochka> thats pretty much just two tables ye, just with specialized items |
21:37:09 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4gas |
21:37:11 | FromDiscord | <qb> Shouldn't that raise an error? |
21:37:25 | FromDiscord | <albassort> nah |
21:37:40 | FromDiscord | <albassort> overflow is fine |
21:37:45 | FromDiscord | <Elegantbeef> Unsigned integers are not checked for overflow |
21:37:50 | FromDiscord | <Elegantbeef> And underflow |
21:37:53 | FromDiscord | <albassort> ^ |
21:37:55 | FromDiscord | <qb> Oh |
21:38:47 | FromDiscord | <albassort> https://media.discordapp.net/attachments/371759389889003532/1042916739966574742/image.png |
21:40:01 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4gat |
21:40:26 | FromDiscord | <qb> Or could I prevent overflowing / underflowing in some way |
21:40:39 | FromDiscord | <albassort> i would make my own + |
21:41:16 | FromDiscord | <.tochka> ye you can define new integer type also |
21:41:59 | FromDiscord | <vindaar> Yeah, I'd define a `CheckedUint8 = distinct uint8` with custom math operations if you really need that. Makes sure you can never forget to do the check |
21:42:18 | FromDiscord | <qb> Alrighty thanks |
21:43:21 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4gax |
21:43:30 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4gax" => "https://play.nim-lang.org/#ix=4gay" |
21:43:46 | FromDiscord | <albassort> or something |
21:43:48 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4gay" => "https://play.nim-lang.org/#ix=4gaz" |
21:43:54 | FromDiscord | <.tochka> lol |
21:44:10 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4gaz" => "https://play.nim-lang.org/#ix=4gaA" |
21:45:06 | FromDiscord | <.tochka> sent a code paste, see https://play.nim-lang.org/#ix=4gaB |
21:48:48 | FromDiscord | <.tochka> sent a code paste, see https://play.nim-lang.org/#ix=4gaE |
21:48:48 | FromDiscord | <.tochka> :D |
21:49:25 | FromDiscord | <.tochka> would not work for uint8 and uint16 doe, gcc and clang dont define it for those |
21:49:28 | FromDiscord | <albassort> beef please stop this person |
21:50:02 | FromDiscord | <albassort> no way that compile s |
21:50:06 | FromDiscord | <Elegantbeef> Nah i got them here |
21:50:16 | FromDiscord | <.tochka> (edit) "https://play.nim-lang.org/#ix=4gaE" => "https://play.nim-lang.org/#ix=4gaF" |
21:50:16 | FromDiscord | <Elegantbeef> It doesnt compile |
21:50:19 | FromDiscord | <Elegantbeef> They forgot to convert `a` and `b` to the C counterparts |
21:50:20 | FromDiscord | <.tochka> In reply to @albassort "no way that compile": i havent checked tbh |
21:50:32 | FromDiscord | <albassort> :KEK: |
21:50:54 | FromDiscord | <Elegantbeef> Sorry for unleashing tochka upon this realm |
21:53:36 | FromDiscord | <Horizon [She/Her]> In reply to @.tochka "my stupid idea for": Why not two sequences/arrays that keep the same index? |
21:54:17 | FromDiscord | <Horizon [She/Her]> `a["key"]` uses the sequence that stores the keys, it gets the index and uses it on the sequence storing the values |
21:54:35 | FromDiscord | <Horizon [She/Her]> `a["value"]` this does the same, but reversed |
21:54:44 | FromDiscord | <Horizon [She/Her]> In reply to @.tochka "my stupid idea for": ^^ |
21:55:01 | FromDiscord | <.tochka> In reply to @Event Horizon "Why not two sequences/arrays": index is supposed to be corresponding to key you're looking for |
21:55:08 | FromDiscord | <Horizon [She/Her]> Yeah |
21:55:08 | FromDiscord | <.tochka> otherwise you have to do linear search |
21:55:25 | FromDiscord | <Horizon [She/Her]> What's the difference between a value and key map? |
21:55:42 | FromDiscord | <Horizon [She/Her]> I mean map and sequence sorry |
21:55:48 | FromDiscord | <.tochka> one stores values, other keys. technically they both key and values at the same time |
21:55:58 | FromDiscord | <.tochka> (edit) "values" => "value" | "valueat the same time ... " added "for each other" |
21:58:54 | FromDiscord | <albassort> In reply to @Event Horizon "I mean map and": they uses hasehs and buckets to be really cool and efficient |
21:59:00 | FromDiscord | <albassort> (edit) "hasehs" => "hashes" |
21:59:04 | FromDiscord | <.tochka> In reply to @Event Horizon "I mean map and": map has hash to item correspondence, where it doesnt matter when and how you got this hash you can search the map and get the value, even if it mutates. in sequence you have to know that given index has appropriate value, and indexes could change on mutation of sequence |
21:59:50 | FromDiscord | <albassort> making a sequence for this lol |
22:00:00 | FromDiscord | <albassort> fuck it |
22:00:28 | FromDiscord | <.tochka> good choice most of the time tbh |
22:00:49 | FromDiscord | <albassort> what do you think this is, lisp |
22:00:50 | Amun-Ra | can I somehow return an object matching concept without inheritance, as in: https://play.nim-lang.org/#ix=4gaL |
22:00:51 | FromDiscord | <albassort> >:O |
22:01:13 | FromDiscord | <.tochka> linear search over sequence is actually not bad for small data sets, and in fact a lot more efficient, even if its O(n) vs O(1) |
22:01:43 | FromDiscord | <Elegantbeef> Amun concepts are compile time only |
22:01:46 | FromDiscord | <.tochka> tho complexity formulas are misleading smh |
22:02:11 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4gaO |
22:02:12 | FromDiscord | <.tochka> In reply to @albassort "what do you think": i didnt say linked list ;p |
22:02:14 | FromDiscord | <Elegantbeef> Works but it doesnt do what you want |
22:02:26 | FromDiscord | <albassort> In reply to @Elegantbeef "Amun concepts are compile": it doesn't need to |
22:02:57 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4gaP |
22:02:58 | FromDiscord | <albassort> >:) |
22:03:01 | FromDiscord | <Elegantbeef> Wrong reply? |
22:03:22 | FromDiscord | <albassort> write compile time macro and do some disgusting shit |
22:03:22 | FromDiscord | <.tochka> correct reply |
22:03:30 | FromDiscord | <Elegantbeef> Count point https://github.com/beef331/traitor https://github.com/beef331/nimtrest/blob/master/goface.nim https://github.com/yglukhov/iface |
22:03:40 | FromDiscord | <Elegantbeef> It's really not that disgusting |
22:03:52 | FromDiscord | <Elegantbeef> You need to have a pointer indirection though amun cause the values can be different sizes |
22:04:13 | Amun-Ra | hmm |
22:04:39 | FromDiscord | <albassort> should i make my ime gpu accelerated |
22:04:52 | FromDiscord | <.tochka> ime? |
22:04:55 | FromDiscord | <Elegantbeef> Stack inheritance does exist, but it's not really usable for polymorphism without so many hacks |
22:05:18 | FromDiscord | <albassort> In reply to @.tochka "ime?": im doing some native language stuff and im kinda worried about speed because it needs to be as fast as you type so |
22:05:27 | FromDiscord | <.tochka> get rid of nim, write everything to stack in asm, no pointers needed |
22:05:40 | FromDiscord | <albassort> wouldn't everything be a pointer in asm |
22:05:53 | FromDiscord | <albassort> just the distinction of pointer not exist |
22:06:15 | FromDiscord | <Elegantbeef> Everything is untyped 64bit |
22:06:20 | FromDiscord | <.tochka> omre like everything is a value with potential to be used for addressing |
22:06:28 | FromDiscord | <.tochka> (edit) "omre" => "more" |
22:06:30 | FromDiscord | <albassort> i guess? |
22:06:48 | FromDiscord | <albassort> in my brain when you use a byte for addressing then it becomes a pointer |
22:07:06 | FromDiscord | <Elegantbeef> I guess 64bit is kinda wrong given that there are simd registers |
22:07:07 | FromDiscord | <albassort> even if its type is bits |
22:07:22 | FromDiscord | <albassort> In reply to @Elegantbeef "I guess 64bit is": yea it doesn't need to be 64bit all the time |
22:07:23 | FromDiscord | <Elegantbeef> Asm is typless |
22:07:26 | FromDiscord | <Elegantbeef> typeless\ |
22:07:29 | FromDiscord | <Elegantbeef> There are no integers |
22:08:01 | FromDiscord | <albassort> its not literally a byte, theres nothing stopping you from just using it some other wya |
22:08:06 | FromDiscord | <albassort> (edit) "wya" => "way" |
22:08:11 | FromDiscord | <.tochka> theres probably some cpus with typed registers |
22:08:30 | FromDiscord | <Elegantbeef> Let's run JS on them |
22:08:37 | FromDiscord | <Elegantbeef> Just to really piss the designers off |
22:08:37 | FromDiscord | <albassort> no way |
22:08:39 | FromDiscord | <.tochka> i guess you can count fpus as that? |
22:08:39 | FromDiscord | <albassort> no possible way |
22:08:48 | FromDiscord | <albassort> JAVA cpu |
22:08:54 | FromDiscord | <albassort> fuckin OOP cpu |
22:09:08 | FromDiscord | <Elegantbeef> Anyway amun what are you actually wanting? |
22:09:18 | FromDiscord | <Elegantbeef> Like i know some type of runtime polymorphism |
22:14:15 | Amun-Ra | Elegantbeef: I'm working on video driver interface, I think I'll end with sth like https://play.nim-lang.org/#ix=4gaQ |
22:15:26 | FromDiscord | <Elegantbeef> is the `# do stuff` the same? |
22:15:34 | FromDiscord | <Elegantbeef> And does each `Driver` have different fields? |
22:16:36 | Amun-Ra | yes |
22:16:53 | FromDiscord | <Elegantbeef> To both questions? |
22:18:40 | Amun-Ra | do stuff is the same, fields aren't |
22:18:57 | Amun-Ra | Elegantbeef: that's excerpt from the code https://play.nim-lang.org/#ix=4gaR |
22:20:30 | Amun-Ra | all the drivers are known at ct so I'm fine with that |
22:20:50 | Amun-Ra | all the driver init proc may fail at rt tho |
22:24:02 | Amun-Ra | that sample lacks return at the end of "do stuff" in try clause |
22:24:55 | FromDiscord | <Elegantbeef> I really have too much fun writing hacks using macros https://play.nim-lang.org/#ix=4gaT is the whole hack on using methods with stack inheritance thanks to Nim being a prick about it, but doesnt help you |
22:25:33 | Amun-Ra | hmm |
22:25:59 | FromDiscord | <Elegantbeef> You need some pointer indirection and type information to use concepts at runtime |
22:26:09 | Amun-Ra | driver object are not of the same size but I have to carefully read your example |
22:26:28 | Amun-Ra | objects* |
22:26:53 | FromDiscord | <Elegantbeef> You'd need to allocate the largest object always if that was the case |
22:27:01 | FromDiscord | <Elegantbeef> So you could still use that but's not really advisable |
22:27:12 | Amun-Ra | thanks |
22:27:48 | FromDiscord | <Elegantbeef> Why are you avoiding inheritance? |
22:29:28 | Amun-Ra | I had inheritance before; I didn't like having proc foo(drv: Driver) = cast[Driver1](drv).foo for every interface callback |
22:29:44 | FromDiscord | <Elegantbeef> Why are you casting? |
22:29:59 | FromDiscord | <Elegantbeef> `Driver1(drv).foo` or just use methods then do `drv.foo` |
22:30:39 | Amun-Ra | well… perhaps because I haven't implemented callback as object fields… ;> |
22:33:18 | Amun-Ra | Elegantbeef: I ended up with https://play.nim-lang.org/#ix=4gaW |
22:33:52 | Amun-Ra | she'll be right |
22:35:40 | FromDiscord | <Elegantbeef> So that whole "allocate the largest" is done here https://play.nim-lang.org/#ix=4gaY |
22:35:56 | FromDiscord | <Elegantbeef> You might say i'm just writing lowlevel code for fun |
22:36:31 | Amun-Ra | that's a nice approach |
22:36:34 | FromDiscord | <Elegantbeef> All stack based inheritance there, for no real reason aside from why not |
22:36:53 | Amun-Ra | I like that |
22:36:55 | Amun-Ra | tbh |
22:38:02 | Amun-Ra | I think I may use a variation of that; thank you |
22:42:37 | FromDiscord | <Elegantbeef> One minor issue is that if you want to unpack it outside of a method you have to cast like so https://play.nim-lang.org/#ix=4gaZ |
22:42:38 | FromDiscord | <Elegantbeef> If you only want stack allocations this is pretty much the best you can do, cause of Nim's anger at type mismatch at runtime |
22:42:50 | FromDiscord | <Elegantbeef> Well dont yell at me if it breaks! |
22:43:07 | FromDiscord | <Elegantbeef> I'm only a slightly sophisticated monkey at a keyboard |
23:07:27 | FromDiscord | <albassort> can i make a macro which initializes variables in the proc |
23:08:06 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4gb3 |
23:08:58 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4gb3" => "https://play.nim-lang.org/#ix=4gb5" |
23:09:08 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4gb5" => "https://play.nim-lang.org/#ix=4gb6" |
23:12:41 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4gb7 |
23:15:33 | FromDiscord | <Elegantbeef> Again i will say if you can write it macros can make it |
23:15:34 | FromDiscord | <Elegantbeef> So yes you can |
23:15:47 | * | derpydoo quit (Ping timeout: 256 seconds) |
23:16:23 | FromDiscord | <albassort> well yes |
23:16:28 | FromDiscord | <albassort> but i haven't seen other people do it |
23:16:35 | FromDiscord | <albassort> and im inexperienced with them |
23:17:04 | FromDiscord | <xixixi> hi.. is there a simple way to do atomic file read/writes? it's for a simple text configuration file, but i don't want to deal with file locking myself |
23:19:22 | FromDiscord | <Elegantbeef> Well i have plent of macros that operate on procs |
23:19:27 | FromDiscord | <Elegantbeef> https://github.com/beef331/constructor/blob/master/src/constructor/constructor.nim↵https://github.com/beef331/nettyrpc/blob/master/src/nettyrpc.nim |
23:20:35 | FromDiscord | <albassort> In reply to @Elegantbeef "Well i have plent": ones that specifically inject variables tho :\ |
23:20:48 | FromDiscord | <albassort> time to get reading |
23:20:54 | FromDiscord | <Elegantbeef> It's all the same shit |
23:21:17 | FromDiscord | <albassort> you're all the same shit |
23:21:32 | * | vicecea quit (Remote host closed the connection) |
23:25:04 | FromDiscord | <Elegantbeef> Yep |
23:39:30 | * | TakinOver quit (Ping timeout: 240 seconds) |
23:40:37 | FromDiscord | <! Nilts> Is there any good way in nim json to be like `createJson(kind: JInt, value: 0)` without having a diffrent name for each value |
23:43:20 | FromDiscord | <Elegantbeef> An array? |
23:43:25 | FromDiscord | <juan_carlos> In reply to @not logged in "Is there any good": `newJint` ? |
23:45:22 | FromDiscord | <! Nilts> In reply to @juan_carlos "`newJint` ?": but that will only work with int, not all the other JsonNodeKinds |
23:46:15 | FromDiscord | <juan_carlos> How to chain `and` 's in a macro for a `seq[NimNode]` ?, like https://play.nim-lang.org/#ix=4gb8 🤔 |
23:46:45 | FromDiscord | <! Nilts> In reply to @Elegantbeef "An array?": ? |
23:52:08 | FromDiscord | <juan_carlos> In reply to @not logged in "but that will only": Do a `case node.kind` and call the `newJint` etc |
23:54:21 | FromDiscord | <vindaar> feel free to adjust https://github.com/SciNim/Unchained/blob/master/src/unchained/utils.nim#L19-L29 to your use case↵(@juan_carlos) |
23:55:43 | FromDiscord | <! Nilts> In reply to @juan_carlos "Do a `case node.kind`": but that is a pain. whatever, ill do it |