<< 24-04-2022 >>

00:01:40FromDiscord<-|-> Hrm, how much stack space does a nim program typically use?
00:03:02PMunchAs much as it requires
00:03:20FromDiscord<-|-> sent a code paste, see https://play.nim-lang.org/#ix=3W3O
00:03:28FromDiscord<-|-> With `-d:release`, it just hangs after the first `echo` call
00:05:20PMunchHmm, that's weird
00:05:29PMunchHow bigs the stack for this target?
00:07:41FromDiscord<Elegantbeef> Are you using arc?↵(@-|-)
00:08:29FromDiscord<-|-> In reply to @Elegantbeef "Are you using arc?": Yes
00:08:30FromDiscord<-|-> sent a code paste, see https://play.nim-lang.org/#ix=3W3P
00:09:02FromDiscord<-|-> i086 is a new CPU target I added
00:23:58FromDiscord<huantian> Is there a way I can get nim vscode to use a different nim binary for a single workspace?
00:24:15FromDiscord<huantian> specifically when working with devel
00:24:22*pch_ is now known as disso_peach
00:25:07FromDiscord<System64 ~ Flandre Scarlet> How can I compile to 32-bits please?
00:25:11PMunchHmm, @Elegantbeef, I wonder if I could go about this the other way round
00:25:45FromDiscord<Elegantbeef> That last time i read something that cryptic i was reading egyptian artificats
00:25:58PMunchTake the routable procedure, then generate procedures that get less and less specific
00:27:38PMunchSo start with getPost(User, Post), and then create procs getPost(Request, Post) which just calls getPost(get(User, Request), Post), and getPost(User, get(Post, Request))
00:28:14PMunchAnd so on
00:28:50PMunchThen the routing logic would just be `routes: get "/whatever": getPost(request)`
00:29:07PMunchAnd since it has at some point generated that procedure it should just work
00:29:14FromDiscord<Elegantbeef> No clue if it works for you 😄
00:29:33FromDiscord<Elegantbeef> insert a comman
00:29:34FromDiscord<Elegantbeef> comma
00:29:37FromDiscord<Elegantbeef> Jesus i cannot type right now
00:29:49PMunchA comma? Where?
00:30:05FromDiscord<Elegantbeef> 'No clue, ...'
00:30:07PMunch@System64_~_Flandre_Scarlet, --cpu shoul help you out here
00:30:24PMunchOf course if you compile on a 32 bit system it will compile to 32 bit automatically
00:30:33PMunchAh right :P
00:30:37FromDiscord<Elegantbeef> you'll need to fetch the compiler for crosscompiling
00:31:01FromDiscord<Elegantbeef> Hmm Clang/Zigcc allow 64bit -\> 32bit without any special tooling dont they?
00:31:11FromDiscord<Elegantbeef> Never built for 32bit before cause afterall it's 2022 😄
00:31:41FromDiscord<-|-> Well, I solved my problem now. I added another target, i086big, that is specifically able to handle the large memory model. Not the best solution, but there's no other way.
00:31:48FromDiscord<-|-> In reply to @Elegantbeef "Hmm Clang/Zigcc allow 64bit": It does. I've used it.
00:32:03FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, --cpu shoul help": ah alright, thanks
00:33:18FromDiscord<Elegantbeef> Hmm `--cc:clang --cpu:i386` does not work you've lied to me!
00:33:50FromDiscord<-|-> You still need the C library and support files for 32-bit platforms
00:34:04FromDiscord<-|-> `zig cc` comes with those. Regular clang usually doesn't.
00:34:12FromDiscord<Elegantbeef> I mean it's hello world, the issue is the size of pointer isnt the same as size of nimint
00:35:32FromDiscord<-|-> oh, you'll also need to pass the target triple to clang
00:36:01FromDiscord<-|-> `--passC:"-target i386-<os>-gnu" -passL:"-target i386-<os>-gnu"`
00:36:34FromDiscord<Elegantbeef> Ah there you go
00:37:42FromDiscord<Elegantbeef> Yea ran into the lack of 32bit header files
00:39:09PMunchOh well, time for bed
00:39:14*PMunch quit (Quit: leaving)
00:39:23FromDiscord<Elegantbeef> Buh bye have a nice sobering sleep 😛
00:40:05FromDiscord<Elegantbeef> Ah nice fetched 32bit clang and it just worked 😄
00:40:56FromDiscord<Elegantbeef> suppose 32bit gcc also works easily
00:46:21disso_peachhey, I have a library implemented in nim that I've offered for use to a friend who would end up using it from rust, is there much documentation on calling nim code over CFFI in rust
00:47:26FromDiscord<JSONBash> has anyone dealt with monetary floats and arbitrary decimals in Nim? Looking for ideas on how I should handle them
00:47:36FromDiscord<Elegantbeef> There isnt any documentation that i know of but you can checkout genny for making the system library, and i'd suggest using `--mm:orc`
00:48:18FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#foreign-function-interface-dynlib-pragma-for-export https://nim-lang.org/docs/manual.html#foreign-function-interface-exportc-pragma are the best things to read
00:51:50FromDiscord<huantian> Just noticed asyncdispatch has this stuck at the end of it's docs https://media.discordapp.net/attachments/371759389889003532/967588645710209054/unknown.png
00:52:04FromDiscord<huantian> because it includes asyncmacro which has this as it's module docstring
00:56:17FromDiscord<huantian> Is this intentional??
01:11:14*vicfred joined #nim
01:33:09FromDiscord<SirOlaf> Can I force arc to not produce a destructor? Am dealing with a particularly nasty bug
01:42:56FromDiscord<SirOlaf> Guess cursor annotation is good enough for now. So, I may have memory corruption or something going on, gonna see if I can make this reproducible somehow, as it is currently part of a pretty big codebase
02:24:55FromDiscord<SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3W4a
02:26:10FromDiscord<huantian> I mean you can `GC_ref()` it but then it won't get collected
02:26:17FromDiscord<huantian> so you'll get a memory leak
02:26:32FromDiscord<Elegantbeef> Do you have the scope that causes the issue?
02:27:08FromDiscord<SirOlaf> Well I can give some context at best. I got this dll that detours a function that does something like that
02:27:23FromDiscord<SirOlaf> So I don't know if the destructor screws with the stack or something
02:27:42FromDiscord<Elegantbeef> Are these both Nim libraries?
02:27:50FromDiscord<SirOlaf> ?
02:28:04FromDiscord<Elegantbeef> The dll and the caller are they both Nim?
02:28:10FromDiscord<SirOlaf> I got a foreign process that gets injected with my dll made using Nim
02:28:15FromDiscord<SirOlaf> And it hooks a few functions in that process
02:29:48FromDiscord<Elegantbeef> And there's no chance a pointer to this string outlives the string?
02:30:02FromDiscord<SirOlaf> Absolutely no chance as that code I sent is all I need to crash it
02:30:26FromDiscord<Elegantbeef> Can i see the scope where the crash happens?
02:30:34FromDiscord<SirOlaf> What does this mean
02:30:59FromDiscord<Elegantbeef> Just show the procedure then 😄
02:31:12FromDiscord<SirOlaf> Crash happens later from what I can tell because the process, not dll, tries to use an invalid pointer
02:31:29FromDiscord<SirOlaf> So the situation I got is that the destructor may somehow screw up the stack
02:32:18FromDiscord<Elegantbeef> doubtful but who knows
02:32:28FromDiscord<SirOlaf> Well yeah it makes no sense
02:32:37FromDiscord<SirOlaf> But I'm running out of ideas
02:32:41FromDiscord<SirOlaf> It works when I mark x as a cursor
02:32:47FromDiscord<Elegantbeef> Well i still do want to see the procedure you're doing it with
02:33:19FromDiscord<SirOlaf> In reply to @SirOlaf "It works when I": But that probably has some consequences
02:33:44FromDiscord<Elegantbeef> What does `x` even do then, you said it causes it even if you just add to it and dont pass it
02:33:55FromDiscord<SirOlaf> In reply to @Elegantbeef "Well i still do": There is not much to see, it's just a stdcall proc hooked using minhook
02:34:18FromDiscord<SirOlaf> In reply to @Elegantbeef "What does `x` even": In my real example it does more, but I reduced the crash to this tiny snippet
02:34:35FromDiscord<SirOlaf> So the destructor must be at fault somehow
02:34:54FromDiscord<Elegantbeef> well like huan said `GCRef` it
02:35:00FromDiscord<Elegantbeef> if it still crashes you're wrongo
02:35:21FromDiscord<SirOlaf> Does that work with arc
02:35:34FromDiscord<Elegantbeef> Yes
02:35:44FromDiscord<SirOlaf> Still gives me the issue of a memory leak then
02:35:55FromDiscord<Elegantbeef> It's a fucking test
02:35:58FromDiscord<SirOlaf> Yeah true
02:36:56FromDiscord<SirOlaf> Well that's funny, it for some reason wants a ref T
02:37:05FromDiscord<SirOlaf> Does not want to use the string version
02:37:42FromDiscord<Elegantbeef> Do you use `--threads:on`?
02:37:48FromDiscord<SirOlaf> Oh yeah, forgot to mention that
02:37:49FromDiscord<SirOlaf> Yes
02:38:41FromDiscord<SirOlaf> I know it uses sharedalloc or something
02:38:45FromDiscord<SirOlaf> Does that do anything wild
02:38:56FromDiscord<SirOlaf> (edit) "sharedalloc" => "allocshared"
02:39:14FromDiscord<Elegantbeef> It allocates on the shared heap, so nothing really for Arc
02:39:28FromDiscord<Elegantbeef> Ok so i'm going to say it's more likely you have a thread issue somewhere
02:39:28FromDiscord<SirOlaf> So why does gc_ref not work for it
02:39:35FromDiscord<Elegantbeef> Odd that you can use gcref with threads
02:39:37FromDiscord<Elegantbeef> I dont fucking know
02:39:40FromDiscord<SirOlaf> Documentation mentions nothing about thread support
02:40:40FromDiscord<Elegantbeef> Oh wait it just seems you cant use gcref on strings
02:40:41FromDiscord<Elegantbeef> Guess cause of the COW
02:41:02FromDiscord<Elegantbeef> Or sequences
02:41:09FromDiscord<huantian> dang cows always ruining plans
02:41:16FromDiscord<SirOlaf> Ok, any other options
02:41:36FromDiscord<SirOlaf> This is extraordinarily hard to debug, have been trying to figure this out for days
02:41:38FromDiscord<Elegantbeef> Give me the program so i can actually see what's happening
02:42:02FromDiscord<SirOlaf> That's a bit problematic. I could write a new dll and try to make it fail but it would have to hook something
02:42:16FromDiscord<Elegantbeef> I mean the code
02:42:25FromDiscord<SirOlaf> But what do you want to see there
02:42:39FromDiscord<SirOlaf> I swear to god this detour literally does nothing else
02:42:40FromDiscord<Elegantbeef> I want to see the code so i can see if you're doing anything unsafe
02:42:46FromDiscord<SirOlaf> Oh I'm doing tons of unsafe stuff
02:42:49FromDiscord<Elegantbeef> I dont give a fiddly fuck
02:43:00FromDiscord<Elegantbeef> I want to see the code to validate the logic and ensure you arent missing a minor detail
02:43:29FromDiscord<Elegantbeef> By unsafe i mean "Oh it's working" and not "Oh it's done properly"
02:44:02FromDiscord<SirOlaf> I do basically nothing
02:44:04FromDiscord<SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3W4f
02:44:13FromDiscord<Elegantbeef> Debugging code without the code is about as useful as a brain surgeon walking a blind person through brain surgury
02:44:24FromDiscord<SirOlaf> Well yeah but the point is that I'm doing nothing
02:44:35FromDiscord<Elegantbeef> You have more code than 1 function
02:44:35FromDiscord<SirOlaf> I just call the original and then make it crash using the string
02:44:47FromDiscord<SirOlaf> Of course I do, in fact, I got a few thousand lines
02:44:53FromDiscord<SirOlaf> A massive chunk of which is unsafe
02:45:07FromDiscord<Elegantbeef> Gib code!
02:45:47FromDiscord<SirOlaf> I'll just make a new one
02:45:53FromDiscord<SirOlaf> Then it's easier to look through
02:46:38FromDiscord<SirOlaf> Still gonna be like a hundred lines though
02:46:54FromDiscord<SirOlaf> Because of setup and pattern scanning
02:53:22NimEventerNew thread by JPLRouge: Link with a kernel32.lib proc and function, see https://forum.nim-lang.org/t/9124
02:54:26FromDiscord<SirOlaf> Good news, my sample still causes the issue
02:54:47FromDiscord<SirOlaf> https://media.discordapp.net/attachments/371759389889003532/967619582955249704/sample.nim
02:55:01FromDiscord<SirOlaf> You can ignore the scanning stuff
02:55:23FromDiscord<SirOlaf> https://media.discordapp.net/attachments/371759389889003532/967619737548914688/sample.nim
02:55:45FromDiscord<SirOlaf> serializerBinaryLoadDetour is the thing that causes a crash somehow
02:56:39FromDiscord<SirOlaf> As for why I scan in this weird way, I have no idea. Fast enough though
02:57:00FromDiscord<SirOlaf> So, anything jump out at you
02:57:50FromDiscord<Elegantbeef> the fact you heap allocate for your `originalptr` is a bit off
02:58:27FromDiscord<SirOlaf> Probably true. So, it does seem that threads have something to do with this crash
02:58:32FromDiscord<SirOlaf> Minimal sample allowed me to switch them off
02:59:02FromDiscord<Elegantbeef> remove that assignment to the heap allocated pointer and just make it nil
02:59:20FromDiscord<Elegantbeef> Unless it's supposed to be a `ptr int64` that's a silly operation
03:00:27FromDiscord<SirOlaf> Yeah so I don't know why I did that
03:00:29FromDiscord<SirOlaf> Not related to crash though
03:00:57FromDiscord<SirOlaf> Crash only happens with threads on
03:02:41FromDiscord<SirOlaf> Does allocShared have some crazy behavior for arc
03:02:47FromDiscord<Elegantbeef> try `--tlsEmulation:off` with threads on
03:03:01FromDiscord<Elegantbeef> It's probably just an alias for `alloc`
03:03:59FromDiscord<Elegantbeef> Afaik `allocShared` isnt needed for `orc/arc` since shared heap
03:04:12FromDiscord<SirOlaf> Same issue with tlsemulation off
03:05:01FromDiscord<Elegantbeef> same thing with `-d:useMalloc`?
03:05:09FromDiscord<SirOlaf> With or without tls
03:05:56FromDiscord<SirOlaf> Huh
03:06:15FromDiscord<Elegantbeef> huH
03:06:20FromDiscord<SirOlaf> Yeah so that seems to work
03:06:46FromDiscord<Elegantbeef> Well perhaps you need to use C's alloc to make your game hacks
03:07:11FromDiscord<SirOlaf> It's weird that it only happens with threads on though
03:07:27FromDiscord<SirOlaf> Maybe allocshared does to something weird for arc
03:07:31FromDiscord<Elegantbeef> Well threads do creat heap locks
03:07:45FromDiscord<Elegantbeef> Does it work fine with refc?
03:07:54FromDiscord<SirOlaf> Need to init gc for that right
03:08:05FromDiscord<Elegantbeef> Only if you dont care to leak
03:08:23FromDiscord<Elegantbeef> This is testing it doesnt matter if you leak
03:08:40FromDiscord<Elegantbeef> Atleast i dont think it matters
03:08:43FromDiscord<Elegantbeef> I could be wrong
03:08:45FromDiscord<SirOlaf> refc crashes during scan
03:08:52FromDiscord<SirOlaf> Probably should do at least something to set it up
03:08:55FromDiscord<Elegantbeef> Ok we'll say i'm wrong
03:11:16FromDiscord<SirOlaf> Yeah refc works
03:11:26FromDiscord<SirOlaf> When you get setupforeignthreadgc and a call to nimmain
03:11:30FromDiscord<SirOlaf> (edit) "get" => "got"
03:11:37FromDiscord<Elegantbeef> With default allocator and threads?
03:11:44FromDiscord<SirOlaf> Correct
03:15:07FromDiscord<SirOlaf> Well, guess useMalloc works for now
03:15:08FromDiscord<Elegantbeef> Well then i guess there's a bug with the threaded allocation logic in video game injection, sad that the Nim allocator cannot be used for making aimbots for CSGO, how will i get good now
03:15:11FromDiscord<SirOlaf> But it is odd that this fails
03:15:32FromDiscord<SirOlaf> In reply to @Elegantbeef "Well then i guess": This is mostly for data extraction
03:15:40FromDiscord<SirOlaf> Serialization format and funny stuff like that
03:16:09FromDiscord<Elegantbeef> I'm going to jokingly pretend it's a case of anticheat and live my life like that 😄
03:16:57FromDiscord<SirOlaf> Anyways, you got a clue where I could find the alloc implementations
03:17:19FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/tree/cfdac6666f5772479724e082fb08c2db694d8d40/lib/system/mm
03:17:32FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/cfdac6666f5772479724e082fb08c2db694d8d40/lib/system/arc.nim
03:18:03FromDiscord<SirOlaf> That doesn't quite have that
03:18:36FromDiscord<SirOlaf> alloc.nim seems to have it
03:18:41FromDiscord<SirOlaf> Guess I should have expected that
03:19:09FromDiscord<Elegantbeef> You're going to be disappointed due to how simple they are
03:19:30FromDiscord<SirOlaf> Amazing
03:21:42FromDiscord<SirOlaf> Well thanks for the help. Probably gonna come back for this bug at some point, but works for now
05:14:17*slowButPresent quit (Quit: leaving)
05:27:11FromDiscord<TryAngle> @SirOlaf u doing it on linux or windows?
05:30:21FromDiscord<TryAngle> I'm curious because I can't find a good resource that I understand well on how to read process memory on linux 💀
06:19:45FromDiscord<Rika> In reply to @TryAngle "I'm curious because I": Proc pseudo file system?
06:20:02FromDiscord<Rika> If you can’t use that you’re in for a ride I believe
06:35:41*kenran joined #nim
06:41:45*kenran quit (Quit: WeeChat info:version)
07:06:31FromDiscord<TryAngle> In reply to @Rika "Proc pseudo file system?": it's blocking the process as far as I understand
07:06:37FromDiscord<TryAngle> if I read from that
07:06:56FromDiscord<TryAngle> (edit) "In reply to @Rika "Proc pseudo file system?": it's blocking the process as far as I understand ... " added "(I read that somewhere?)"
07:07:32FromDiscord<TryAngle> but I need to read multiple values at different offsets AT LEAST once per second
07:18:23*jmdaemon quit (Ping timeout: 260 seconds)
07:18:43FromDiscord<Solitude> In reply to @TryAngle "it's blocking the process": i had simple csgo cheat accessing proc/mem and it worked just fine
07:21:28FromDiscord<qb> In reply to @TryAngle "I'm curious because I": https://github.com/qb-0/PyMeow/blob/master/src/linux/memory.nim
07:29:09FromDiscord<qb> Or without nimpy: https://github.com/qb-0/hLibLinux/blob/main/memory.nim
07:29:55FromDiscord<Rika> In reply to @qb "Or without nimpy: https://github.com/qb-0/hLibLinux": This one
07:36:55*duuude joined #nim
07:38:02FromDiscord<TryAngle> sent a code paste, see https://paste.rs/GkT
07:38:03FromDiscord<TryAngle> this was what I've been looking for I think
07:38:07FromDiscord<TryAngle> thank u @qb
07:38:12FromDiscord<TryAngle> 🥺 🥺 🥺 🥺 🥺 🥺 🥺 🥺 🥺 🥺 🥺
07:38:38duuudecan I make nim output C with ifndefs and everything so everyone only needs build-essentials and compiles it? some sort of gentoo-friendly C code
07:38:50FromDiscord<TryAngle> In reply to @Solitude "i had simple csgo": good to know, guess what I read on stackoverflow was not up to date then or just not knowledgable
07:39:50FromDiscord<qb> In reply to @TryAngle "good to know, guess": Related to this btw: https://github.com/qb-0/CSGoEsp-Linux
07:40:09FromDiscord<qb> But pointers / offsets are prob not up 2 date
07:40:36FromDiscord<TryAngle> oh no dw I'm not writing csgo cheats xd↵just want to read some offsets in league of legends
07:41:00FromDiscord<TryAngle> hope it works well because it's emulated in wine
07:41:11FromDiscord<TryAngle> (edit) "oh no dw I'm not writing csgo cheats xd↵just want to read some offsets in league of legends ... " added "(only legal things)"
07:41:48FromDiscord<qb> yea it works. process_vm_readv/write_v can be used on windows processes. And the windows offsets / pointers will work
07:41:51FromDiscord<TryAngle> but I read about a similar case about WOW and the offsets were the same even with wine?
07:42:00FromDiscord<TryAngle> so no issue I hope
07:42:32FromDiscord<Solitude> In reply to @TryAngle "oh no dw I'm": they are not accessible with client api?
07:42:52FromDiscord<TryAngle> In reply to @Solitude "they are not accessible": the client api is not for ingame
07:43:11FromDiscord<Solitude> the ingame api
07:43:17FromDiscord<Solitude> better?
07:44:26FromDiscord<TryAngle> In reply to @Solitude "the ingame api*": what do you mean?
07:44:34FromDiscord<TryAngle> do you mean the lcu or do you mean the riot api?
07:44:50FromDiscord<Solitude> https://developer.riotgames.com/docs/lol#game-client-api
07:44:59FromDiscord<Rika> In reply to @duuude "can I make nim": Not that I know of, no
07:45:25FromDiscord<Rika> Calling resident Gentoo user sheerluck xd
07:45:45FromDiscord<TryAngle> In reply to @Solitude "https://developer.riotgames.com/docs/lol#game-clien": lol
07:45:49FromDiscord<TryAngle> https://www.mingweisamuel.com/lcu-schema/tool/↵it's not documented here
07:46:08FromDiscord<Solitude> why are you looking for documentation at some third party shithole?
07:46:21FromDiscord<TryAngle> In reply to @Solitude "why are you looking": because it's the only usable documentation lol
07:46:34FromDiscord<Solitude> user issue
07:47:54FromDiscord<TryAngle> In reply to @Solitude "user issue": can u get jgl camps etc with this?
07:48:12FromDiscord<Solitude> i asked you that
07:48:38FromDiscord<Solitude> i dont know, im just offering alternative resource before reading straight from memory
07:48:48FromDiscord<TryAngle> ah Isee
07:48:51FromDiscord<TryAngle> I don't know either
07:49:04FromDiscord<TryAngle> I'm just a tiny cs undergrad with 0 knowledge 😭
07:51:12FromDiscord<TryAngle> @qb wow your pyMeow lib
07:51:24FromDiscord<TryAngle> didn't know it's so "trivial" to make python libs with nim o_O
07:51:49FromDiscord<Yardanico> it is, thanks to nimpy
07:51:57FromDiscord<Yardanico> https://github.com/yglukhov/nimpy
07:51:58FromDiscord<Solitude> In reply to @TryAngle "can u get jgl": you can query list of ingame events, the dragon and herald are there for sure, maybe jungle monsters too
07:52:22FromDiscord<TryAngle> In reply to @Yardanico "it is, thanks to": lol
07:52:27FromDiscord<TryAngle> "One Language to rule them all"
07:52:30FromDiscord<TryAngle> makes more sense now
08:01:48FromDiscord<qb> In reply to @TryAngle "<@590220785029873674> wow your pyMeow": 🙏
08:03:12FromDiscord<TryAngle> In reply to @Yardanico "https://github.com/yglukhov/nimpy": I haven't tried it but hwat does it look like from the pytohn side?
08:03:31FromDiscord<TryAngle> when u click to function defintion from your editor for example
08:03:55FromDiscord<TryAngle> do u see the nim code? or is the result of the compilation literally python code?
08:05:05FromDiscord<Yardanico> In reply to @TryAngle "I haven't tried it": like a normal native extension
08:05:16FromDiscord<Yardanico> In reply to @TryAngle "do u see the": python has support for native extensions via the CPython C API
08:05:19FromDiscord<Yardanico> nimpy just uses that
08:05:32FromDiscord<Yardanico> it's the same as writing native modules for python in C/C++, except that it's easier and the code looks better
08:11:02FromDiscord<qb> Guess just pycharm has editor support for python extensions
08:11:09FromDiscord<qb> if that was the question
08:11:28FromDiscord<qb> I didn't figured it out for vscode atleast
08:14:04*Gustavo6046 quit (Quit: Goodbye! Leave messages at my XMPP @ [email protected] or my Discord Gustavo6046#9009 or possibly my Mastodon [email protected] – I don't check my email often since it's full of crap, but in any case, [email protected])
08:24:35*kayabaNerve quit (Remote host closed the connection)
08:24:43*kayabaNerve joined #nim
08:31:42FromDiscord<Knedlik> Hey guys, I need some help with syntax stuff - the SDL debug output redirect function requires a function and a pointer as a parameter, but I’m not sure, how to pass a function
08:31:57FromDiscord<Elegantbeef> You just use the name
08:32:04FromDiscord<Knedlik> Hmmm
08:32:05FromDiscord<Elegantbeef> so `sdl2logStuff(myProc, nil)`
08:32:20FromDiscord<Knedlik> I’ll try, thanks
08:43:34*kayabaNerve quit (Remote host closed the connection)
08:43:55*kayabaNerve joined #nim
10:06:33*Guest3791 joined #nim
10:12:25*Zectbumo quit (Remote host closed the connection)
10:20:30*Guest3791 quit (Quit: Client closed)
10:48:54FromDiscord<TryAngle> Any good libraries to work with bit sets with enums?
10:50:04FromDiscord<Solitude> what do you need
10:52:22FromDiscord<TryAngle> I'm stoopid↵Nim is that language that already has sets 🥺
10:52:59FromDiscord<Knedlik> Uhhh guys why does the compiler complaing about me passing in a string as the first param of write()?
10:53:07FromDiscord<Knedlik> (edit) "complaing" => "complain"
10:53:26FromDiscord<TryAngle> In reply to @Solitude "what do you need": set[<Enum Ident>]↵I forgot nim has sets already lol
10:53:36FromDiscord<Knedlik> Seems to only happen if I import os in some form
10:53:50FromDiscord<Solitude> In reply to @Knedlik "Uhhh guys why does": sorry, no telepathy today
10:54:04FromDiscord<TryAngle> In reply to @Knedlik "Uhhh guys why does": What write function
10:54:14FromDiscord<Knedlik> The file write function, under io
10:54:33FromDiscord<Solitude> which one
10:54:39FromDiscord<Solitude> what is the code
10:54:40FromDiscord<Solitude> what is the error
10:54:42FromDiscord<Solitude> please
10:54:43FromDiscord<Solitude> my guy
10:54:53FromDiscord<Knedlik> Let me just get it in here
10:55:48FromDiscord<TryAngle> @Knedlik please add the error and code with errors like this in future, otherwise we would need to guess
10:55:50FromDiscord<Knedlik> `write(fmt”{getAppDir()}/debug.log” & “\n”, log)`
10:55:59FromDiscord<Solitude> file comes first
10:56:10FromDiscord<Knedlik> Yeah, that’s the file
10:56:19FromDiscord<Knedlik> The first param
10:56:19FromDiscord<Solitude> that path to the file
10:56:21FromDiscord<Solitude> not file
10:56:45FromDiscord<Knedlik> I can’t find anything on how to convert string path to the file object
10:56:48FromDiscord<Solitude> https://nim-lang.org/docs/io.html#writeFile%2Cstring%2Cstring
10:57:02FromDiscord<Knedlik> Oh yeah I’m dumb af
10:57:21FromDiscord<Knedlik> Ignore me while I go cry in my corner
11:00:26*PMunch joined #nim
11:06:50*gsalazar quit (Ping timeout: 246 seconds)
11:16:52FromDiscord<SirElephant> there are two nim addons in vsc. Which one should i use?
11:17:27FromDiscord<Solitude> saem one
11:17:30FromDiscord<Knedlik> I find the less popular one by nimsaem better
11:17:48FromDiscord<SirElephant> In reply to @Solitude "saem one": nimsaem?
11:17:52FromDiscord<Solitude> yes
11:17:55FromDiscord<SirElephant> oke
11:18:27FromDiscord<Knedlik> Can’t say anything bad about it, it had no false positives or negatives when it comes to errors yet (for me)
11:19:28FromDiscord<SirElephant> is there a std lib for random nums?
11:19:57FromDiscord<Solitude> https://nim-lang.org/docs/lib.html
11:20:30FromDiscord<SirElephant> is it in algorithm?
11:20:35FromDiscord<Solitude> its in random
11:20:43FromDiscord<SirElephant> found it
11:20:47FromDiscord<Solitude> amazing
11:39:09FromDiscord<untoreh> sent a code paste, see https://play.nim-lang.org/#ix=3W5I
11:44:55FromDiscord<Andreas> is there any layout benefit in space or time for either using one uint64 or two uint32 in a tuple or object ?
11:50:05PMunch@Andreas, it depends
11:51:17PMunchIn general C tries to align data in memory so that access is fast
11:51:56PMunchSometimes this means that it adds padding to your struct
11:53:02FromDiscord<Andreas> In reply to @PMunch "In general C tries": ok, i'll try. I could pack two i16 into one u32, but i guess readabillity stays better if i use two ints
11:53:12PMunchYou can add the {.packed.} pragma to an object definition in Nim to tell the C compiler that it should cram the bits and bytes as tightly together as possible
11:53:45PMunchBut this might come at a cost in execution speed since the CPU might have to do some extra bit-shifting and masking logic to extract the number you requested
11:54:00PMunchSo it really comes down to what is most important, memory or CPU
11:54:54FromDiscord<Andreas> In reply to @PMunch "So it really comes": i guess using one u32 does not gain any memory-advantage ?
11:55:06FromDiscord<Knedlik> Hey guys, any idea how to build for linux and mac from windows? It’s throwing all kinds of errors if I add os:linux and os:macos
11:55:42FromDiscord<Knedlik> To be specific…
11:56:02FromDiscord<Knedlik> Linux build can’t find sys/mman.h, and mac screams no implementation for dyncalls
11:57:06PMunch@Andreas, a packed struct vs. a manually shifted and masked integer of the same size likely won't have a big difference
11:58:11PMunchThe CPU might have some extra tricks up it sleeve though, so it could be faster to use a packed struct. But if you have domain-specific knowledge (e.g. you can set the uint32 to 1 if you want to set one value to 0 and another to 1, and not have to do the whole masking rigamarole) then that would be faster
11:58:38PMunchAs with anything, benchmarking is the only real way to know which will perform better for your specific usecase on your specific hardware
11:59:06PMunch@Knedlik, you need the compatibility libraries and compilers
11:59:24FromDiscord<Andreas> In reply to @PMunch "As with anything, benchmarking": right, regarding benchmarking, what lib does one use here - i tried benchy, but there are others
12:01:21PMunchIt depends on what you're testing
12:01:57PMunchBenchy is nice to test for execution time, but I don't think it has any memory checking for example
12:09:47FromDiscord<Yardanico> In reply to @Knedlik "Hey guys, any idea": the easiest way is probably by using zig cc's cross compiler, but if you're building something like a game you need other libraries like glfw as well
12:25:03*PMunch quit (Quit: leaving)
12:41:47FromDiscord<TryAngle> In reply to @Knedlik "Can’t say anything bad": For me it doesn't work randomly until I reopen that file lol
12:42:58*duuude quit (Remote host closed the connection)
12:43:23*duuude joined #nim
13:06:45*slowButPresent joined #nim
14:01:49*krux02 joined #nim
14:31:03FromDiscord<Phil> I wonder how jsony manages to serialize also fields of objects that aren't exported and thus not public
14:45:25FromDiscord<Solitude> fieldPairs returns all fields
14:51:17FromDiscord<Solitude> In reply to @Isofruit "I wonder how jsony": yeah, just checked, it cant
14:55:25FromDiscord<TryAngle> sent a code paste, see https://paste.rs/N1r
14:56:03FromDiscord<Solitude> case nk: NodeKind
14:56:08FromDiscord<TryAngle> X
14:56:09FromDiscord<TryAngle> D
14:56:16FromDiscord<TryAngle> thanks @Solitude
14:56:34FromDiscord<TryAngle> the more nim I write
14:56:37FromDiscord<TryAngle> the less nim I understand
14:56:44FromDiscord<TryAngle> 😔
15:03:44FromDiscord<TryAngle> @Solitude in the same example, can I somehow construct a new Node with only one generic?
15:07:23FromDiscord<Phil> In reply to @Solitude "yeah, just checked, it": I'll need to double check my serialization again, could've sworn I saw fields serialized that were private
15:10:30*vicfred quit (Quit: Leaving)
15:17:52FromDiscord<Knedlik> Hey guys, is there not a multi-type sequence, or am I totally blind?
15:18:00FromDiscord<Solitude> In reply to @Isofruit "I'll need to double": You have hooks in same module?
15:18:12FromDiscord<Solitude> In reply to @Knedlik "Hey guys, is there": There isnt
15:18:24FromDiscord<Knedlik> hmmm okay, thx
15:18:56FromDiscord<Solitude> In reply to @TryAngle "<@104136074569211904> in the same": what
15:26:53FromDiscord<Phil> In reply to @Solitude "You have hooks in": I don't think so, but given how many layers of generics I use I can't make any guarantees for what gets executed where
15:30:19*jmdaemon joined #nim
15:30:32FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3W78
15:31:04FromDiscord<Knedlik> Hmmm, how tf do I get the value a ptr is pointing to? Is it like that by default, or do I need to deaddress it?
15:31:20FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=3W78" => "https://play.nim-lang.org/#ix=3W7a"
15:31:35FromDiscord<Solitude> In reply to @Knedlik "Hmmm, how tf do": ptr[]
15:31:46FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=3W7a" => "https://play.nim-lang.org/#ix=3W7b"
15:32:53FromDiscord<Knedlik> so if I understood that right, a pointer `adr` would be translated into the variable using `adr[]`?
15:33:38FromDiscord<Solitude> you get value stored at adr by dereferencing it with []
15:33:54FromDiscord<Knedlik> okay, thanks
15:34:21*neurocyte8614492 joined #nim
15:35:31FromDiscord<Ayy Lmao> Does anyone know any solid resourced for learning how to draw geometric primitives with triangles? I'm really struggling to find anything. imgui_draw.cpp seems to be the closest thing but it is difficult reading through thousands of lines of heavily inlined c++ code.
15:35:37FromDiscord<Ayy Lmao> (edit) "resourced" => "resources"
15:35:58FromDiscord<Ayy Lmao> (edit) "Does anyone know any solid resources for learning how to draw ... geometric" added "2d"
15:51:26FromDiscord<Knedlik> In reply to @Ayy Lmao "Does anyone know any": Are you okay using a graphics lib?
15:51:47FromDiscord<Knedlik> Like a full-fledged one?
15:52:26*emery quit (Ping timeout: 246 seconds)
15:52:58*ehmry joined #nim
15:54:54FromDiscord<ynfle> !eval echo float(5) #Is this a bug?
15:54:56NimBot5.0
15:55:27FromDiscord<Rika> what is the bug?
15:55:49FromDiscord<ynfle> Lol, it was a mistake
15:55:54FromDiscord<ynfle> !eval echo float($5) #Is this a bug?
15:55:57NimBotCompile failed: /usercode/in.nim(1, 11) Error: type mismatch: got 'string' for '"5"' but expected 'float'
15:56:19FromDiscord<huantian> Float doesn’t parse strings
15:56:20FromDiscord<Rika> no
15:56:39FromDiscord<ynfle> !eval echo float(($5)[0]) #Is this a bug?
15:56:41NimBot53.0
15:56:45FromDiscord<Rika> no
15:56:58FromDiscord<ynfle> I realized the mistake
15:57:03FromDiscord<Rika> !eval echo ord(($5)[0])
15:57:05FromDiscord<ynfle> That's confusing though
15:57:05NimBot53
15:57:14FromDiscord<Rika> its not really
15:57:19FromDiscord<ynfle> Why?
15:57:23FromDiscord<ynfle> char -> float?
15:57:31*ehmry quit (Ping timeout: 256 seconds)
15:57:40*emery joined #nim
15:57:50FromDiscord<Rika> i guess its not very sensible but i dont think its confusing
16:01:39FromDiscord<Ayy Lmao> In reply to @Knedlik "Are you okay using": I'm trying to write my own essentially.
16:04:01FromDiscord<Knedlik> gl, I sadly don't know how to help you there
16:06:21FromDiscord<aph> In reply to @ynfle "char -> float?": char = int (but prints the utf8/whatever encoding's text) i think
16:08:58FromDiscord<Rika> yes but its technically not sensible to implicitly convert char to int
16:13:25FromDiscord<TryAngle> how can I remove the last character of a string?
16:13:42FromDiscord<Yardanico> `setLen` would be the fastest way I guess
16:13:51FromDiscord<Yardanico> `mystr.setLen(mystr.len - 1)`
16:14:42FromDiscord<TryAngle> lol
16:14:44FromDiscord<TryAngle> thanks
16:18:03FromDiscord<TryAngle> In reply to @Yardanico "`mystr.setLen(mystr.len - 1)`": I get a really sussy error
16:18:11FromDiscord<Yardanico> care you show it at least?
16:18:19FromDiscord<Yardanico> (edit) "care" => "can"
16:18:21FromDiscord<TryAngle> yes was just looking up again
16:18:21FromDiscord<TryAngle> `Unhandled exception: value out of range: -2 notin 0 .. 9223372036854775807 [RangeDefect]`
16:18:35FromDiscord<TryAngle> `result.setLen(result.len() - 2)`
16:18:44FromDiscord<Yardanico> but what if your string is empty
16:18:49FromDiscord<Yardanico> then setLen won't work
16:19:05FromDiscord<Yardanico> it's throwing an exception because you're trying to set string's length to negative
16:19:18FromDiscord<TryAngle> oh!
16:19:25FromDiscord<TryAngle> I forgot about the first case
16:19:44FromDiscord<TryAngle> I'm trying to visualize a tree with nice pipes
16:21:56FromDiscord<Knedlik> umm guys can I somehow put Type1 and Type2 in the same seq if they both inherit Type0?
16:24:18FromDiscord<huantian> Yea
16:24:29FromDiscord<huantian> Just make the sequence of Type0
16:24:41*neurocyte8614492 quit (Ping timeout: 272 seconds)
16:25:52FromDiscord<Knedlik> Maybe I encountered a false positive from the VSC debug...
16:26:30FromDiscord<Knedlik> When compiling, any syntax error would stop it, right?
16:27:11FromDiscord<Rika> any compile time error sure
16:27:20FromDiscord<Knedlik> That's weird
16:27:39FromDiscord<Knedlik> VSC is giving me errors o'plenty, but compiler for once doesn't complain
16:27:54FromDiscord<Yardanico> well, there can be a lot of reasons for that
16:28:13FromDiscord<Yardanico> for example you're compiling with e.g. --threads:on but you didn't put that into your .nim.cfg or .nims so nimsuggest doesn't know that you're using it
16:28:27FromDiscord<Yardanico> or maybe nimsuggest is just being buggy, try to restart the editor :)
16:28:45FromDiscord<Knedlik> my compile is clean `nim c src/main.nim`
16:28:58FromDiscord<Yardanico> restart the editor
16:29:16FromDiscord<Generic> In reply to @Yardanico "or maybe nimsuggest is": unless you enable it, nim check is used for errors not nimsuggest
16:29:22FromDiscord<Knedlik> Still the same after a restart
16:29:32FromDiscord<Generic> what is the error?
16:30:09FromDiscord<Knedlik> sent a code paste, see https://play.nim-lang.org/#ix=3W7Q
16:30:33FromDiscord<Knedlik> Graphic is ref object of Object, seq is of type Object
16:30:53FromDiscord<Knedlik> Object is just `Object = object`
16:30:53FromDiscord<Yardanico> can you maybe share that part of code?
16:31:08FromDiscord<Yardanico> the type defs and the code around the error
16:31:12FromDiscord<Knedlik> sent a code paste, see https://play.nim-lang.org/#ix=3W7R
16:31:30FromDiscord<Knedlik> sent a code paste, see https://play.nim-lang.org/#ix=3W7S
16:31:40*duuude quit (Ping timeout: 250 seconds)
16:31:45FromDiscord<Knedlik> sent a code paste, see https://play.nim-lang.org/#ix=3W7T
16:31:53FromDiscord<Yardanico> well, this is actually incorrect
16:32:06FromDiscord<Yardanico> for you to inherit from Object you need to have it inherit from RootObj or RootRef :)
16:32:32*PMunch joined #nim
16:32:32FromDiscord<Knedlik> Why not just let me go and have fun wtf
16:32:45FromDiscord<Yardanico> if you want "fun" then go write basic :)
16:33:23FromDiscord<Knedlik> I want to know why an inheritable object has to inherit
16:33:25*duuude joined #nim
16:33:55FromDiscord<Yardanico> to make it inheritable you need to make it inherit from the base hierarchy
16:34:12FromDiscord<Yardanico> for RTTI
16:34:13FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#types-tuples-and-object-types
16:34:19FromDiscord<Yardanico> "Objects provide many features that tuples do not. Objects provide inheritance and the ability to hide fields from other modules. Objects with inheritance enabled have information about their type at runtime so that the of operator can be used to determine the object's type. The of operator is similar to the instanceof operator in Java."
16:34:39FromDiscord<Knedlik> I wonder if Java does that automatically or if it doesn't even need that, but I guess it's different when Java is OOP af
16:35:00FromDiscord<Yardanico> in Java everything is about OOP and almost everything is boxed
16:35:03FromDiscord<Yardanico> nim doesn't force you into one way
16:35:12FromDiscord<Knedlik> Yeah
16:35:18FromDiscord<Knedlik> And I kind of like that
16:37:06FromDiscord<Knedlik> I started on Java, and tbh, I feel like I like Nim more with it's simplicity-ish
16:39:00FromDiscord<Phil> I mean, you can write very java-y code without falling into java's pitfalls, those pitfalls being additional state everywhere in Java
16:39:50FromDiscord<Phil> (edit) "I mean, you can write very java-y code without falling into java's pitfalls, those pitfalls being additional state everywhere in Java ... " added "(class variables)"
16:40:11FromDiscord<Phil> The more I write java the less I'm a fan of class variables outside of POJOs
16:40:49FromDiscord<Phil> In that sense nim gives you a lot of the greatest stuff the language has to offer... now if the intellisense didn't absolutely suck that would be grand
16:41:14FromDiscord<Yardanico> it doesn't "absolutely suck" for me, but that seems to be a very personal thing for nim, for some it's unusable, for some it's fine :)
16:41:26FromDiscord<Phil> I wish I were more competent to be able to contribute a solution
16:42:45FromDiscord<Phil> In reply to @Yardanico "it doesn't "absolutely suck"": Like, the compiler errors are 90% of the time really useful, that gets props from me, the annoying part is just when you ask for an autocomplete on vscodium and it loads longer than 5 seconds
16:43:04FromDiscord<Yardanico> well, that's what I mean, it's fine for me in most cases
16:43:17FromDiscord<Yardanico> and fixing it wouldn't be so easy, since nimsuggest builds upon the compiler itself
16:43:38FromDiscord<Yardanico> so you either fix nimsuggest which is in the compiler, or have to create a new solution from scratch and somehow teach it to understand all of nim (macros, templates, compile time code evaluation, etc)
16:44:31FromDiscord<Yardanico> it is possible to fix some nimsuggest bugs, you just have to report them at last
16:44:32FromDiscord<Yardanico> (edit) "last" => "least"
16:44:40FromDiscord<Phil> Yeh, thus my desire to become more competent one day after my project got its first release
16:45:08FromDiscord<Rika> me, using buffer autocomplete:
16:46:01FromDiscord<Yardanico> i have auto-autocomplete in vscode
16:46:21FromDiscord<Yardanico> the one that triggers as you type without pressing Tab or anything
16:46:59FromDiscord<Rika> how does that work
16:47:12FromDiscord<Rika> how do you accept the correction
16:47:14FromDiscord<Rika> space?
16:47:15FromDiscord<Phil> One sec:↵> Nimsuggest is a server that takes queries that are related to myproject↵Does that mean there's a server that I can start up with systemd?
16:47:37FromDiscord<Rika> no
16:47:40FromDiscord<Rika> its not a server in that sense
16:48:03FromDiscord<Rika> you start it with arguments about the project youre opening so its per-project instances
16:48:19FromDiscord<Rika> so i guess you technically can but i dont think you shoukd
16:48:20FromDiscord<Rika> (edit) "shoukd" => "should"
16:48:35FromDiscord<Yardanico> In reply to @Rika "space?": tab
16:49:19FromDiscord<Phil> Ah, hmmmm
16:49:41FromDiscord<Rika> In reply to @Yardanico "tab": oh so you mean auto popup instead of the one that pops up on tab
16:49:44FromDiscord<Rika> same here
16:49:45FromDiscord<Yardanico> yes
16:53:37FromDiscord<Phil> I really don't understand where the different nimsuggest speeds come from. ↵Does nimsuggest maybe slow down a lot when there's a lot of generics around?↵Does it not like medium-sized projects and larger?↵I'm pretty sure it's not all that hardware related because my hardware is fairly fast
16:54:08FromDiscord<Solitude> In reply to @Isofruit "I really don't understand": its jsut shit
16:54:15FromDiscord<Rika> its just the implementation being hacked up
16:54:23FromDiscord<Rika> yeah pm what solitude says
16:54:49*duuude quit (Ping timeout: 248 seconds)
16:54:55FromDiscord<Phil> But isn't nimsuggest also fairly complicated given what it does?
16:55:05FromDiscord<Rika> thats pretty much why its shit
16:55:19PMunchWell nimsuggest has to pretty much implement the entire compiler (to understand macros and such)
16:55:41PMunchSo what it does is that it loads the compiler as libraries, then it essentially compiles your project and extracts information
16:56:09FromDiscord<Yardanico> exactly
16:56:11FromDiscord<Phil> Wait, so every time I want an auto-complete it does a file-compile in the background?
16:56:16PMunchOnce IC is implemented I assume nimsuggest could trivially be made much faster
16:56:18FromDiscord<Yardanico> In reply to @Isofruit "Wait, so every time": not full file-compile
16:56:24PMunch@Phil, not quite, but the process is similar
16:56:35PMunchWait, @Phil is Isofruit?
16:56:40FromDiscord<Phil> Yeh
16:56:42FromDiscord<Yardanico> In reply to @PMunch "Once IC is implemented": yeah, with IC the plan is to make it emit the files that contain all the symbols for nim files
16:56:57FromDiscord<Yardanico> so you can use IC'd files for autocompletion
16:57:01PMunchHuh, never knew
16:57:07FromDiscord<Yardanico> in fact there's already a tool in the nim repo
16:57:18FromDiscord<Phil> Made more sense since my github goes under the same name, makes the association easier
16:57:22FromDiscord<Yardanico> IC nagivator
16:57:22FromDiscord<Yardanico> https://github.com/nim-lang/Nim/pull/17714
16:57:29FromDiscord<Yardanico> defusages
16:57:30PMunchBut yeah, if you have a lot of generics, concepts, or macros then the compiler starts to slow down and you get poor nimsuggest performance
16:57:31FromDiscord<Rika> cool
16:57:49FromDiscord<Phil> And apparently a non-zero amount of folks in here have cloned my nimstoryfont repo that are a bit beyond me because I don't see the use but shrugs
16:58:11FromDiscord<Phil> So for contacting etc. I thought it'd make more sense
16:58:22FromDiscord<Phil> (edit) "So for contacting ... etc." added "regarding questions"
16:59:13FromDiscord<Phil> In reply to @PMunch "But yeah, if you": In that case my generics are most likely the culprit. With half a dozen dedicated generic-modules that are used figuratively everywhere else that would explain the slowdown
16:59:43FromDiscord<2F42BBA1> sent a long message, see http://ix.io/3W83
16:59:53FromDiscord<Rika> you can just.. do that
16:59:53FromDiscord<Yardanico> what
16:59:56FromDiscord<Rika> write it
16:59:58FromDiscord<Rika> compile
17:00:00FromDiscord<Rika> see it works
17:00:09FromDiscord<Phil> Does it explode with an error if you just write it that way?
17:00:16FromDiscord<Yardanico> In reply to @2F42BBA1 "I have `readLine(stdin)` ": https://nim-lang.org/docs/manual.html#procedures-method-call-syntax that's exactly one of the main nim "killer" features if you ask me
17:00:24FromDiscord<Yardanico> ability to write OOP-like code without having to actually write OOP
17:00:39FromDiscord<Solitude> this is first tutorial...
17:01:14FromDiscord<Phil> The tutorials are pretty solid stuff btw. Even now I regularly consult the second one
17:01:25FromDiscord<2F42BBA1> In reply to @Yardanico "https://nim-lang.org/docs/manual.html#procedures-me": i just want write in this way yeah
17:01:26FromDiscord<Yardanico> In reply to @Solitude "this is first tutorial...": in the modern day people just go with the flow :(
17:01:29FromDiscord<Yardanico> In reply to @2F42BBA1 "i just want write": just write it?
17:01:30FromDiscord<Yardanico> it already works
17:01:56FromDiscord<Yardanico> in nim there's literally no difference between `stdin.readLine()` and `readLine(stdin)`
17:02:00FromDiscord<Phil> In reply to @2F42BBA1 "i just want write": Given that you're asking the question, why would you believe it doesn't work?
17:02:37FromDiscord<2F42BBA1> In reply to @Isofruit "Given that you're asking": It does work, but I was curious how do I write in this style of `obj.methodName(args)`
17:02:42FromDiscord<Rika> you just do
17:02:45FromDiscord<2F42BBA1> And now I understand how do I do that
17:02:48FromDiscord<Rika> okay
17:02:56FromDiscord<Yardanico> In reply to @2F42BBA1 "And now I understand": please, please just give tut1 a read
17:03:07FromDiscord<Solitude> In reply to @Yardanico "please, please just give": its actually in second part, i lied
17:03:11FromDiscord<Yardanico> second part too
17:03:27FromDiscord<Phil> In reply to @2F42BBA1 "It does work, but": I don't mean that in any way hostile, I'm assuming you already tested it out, just wanted to figure out what lead you to assuming otherwise ^^↵Anyway, I recommend to do as Yardanico suggested and read through the tutorial
17:03:37FromDiscord<Phil> They're all 3 fairly short
17:03:43FromDiscord<Phil> (edit) "They're all 3 fairly short ... " added "and a great resource to bookmark in general"
17:04:14FromDiscord<Phil> They may not cover 100% of the available features, but the majority of what you'll need to get going and even a bit more than that seeing as pragmas and macros are also covered
17:04:18FromDiscord<Phil> (edit) "They may not cover 100% of the available features, but the majority of what you'll need to get going and even a bit more than that seeing as pragmas and macros are also covered ... " added "in part 3"
17:04:34FromDiscord<Phil> (edit) "what" => "major tools that"
17:05:20*duuude joined #nim
17:06:16FromDiscord<Yardanico> In reply to @2F42BBA1 "And now I understand": for even more fun, you can also write it as `readLine stdin`
17:06:32FromDiscord<Phil> In reply to @Yardanico "so you can use": That... kinda makes me really excited for auto completion.↵I mean, it's pretty doable to write code already, but with non-slow autocomplete that would be wonderful!
17:06:45FromDiscord<Yardanico> or the classic `r_E_a_D_L_i_N_e s_T_d_I_n`
17:06:49FromDiscord<Phil> Yard straight delving into the black magic syntax arts
17:06:54FromDiscord<Yardanico> just don't show this to your kids
17:07:01FromDiscord<Yardanico> `let val = r_E_a_D_L_i_N_e s_T_d_I_n`
17:07:28FromDiscord<Phil> I'm still squinting hard at "whitespace as bracket" syntax
17:07:50FromDiscord<Rika> `2+3 52 5/6`
17:07:59FromDiscord<Yardanico> it's called command invocation syntax :)
17:07:59FromDiscord<Phil> Rika, please
17:08:02FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax
17:08:03FromDiscord<Phil> I'm barely back from sports
17:08:06FromDiscord<Phil> Don't give me trauma
17:08:29FromDiscord<Phil> In reply to @Yardanico "it's called command invocation": Cool, now I have a name for the thing I'm always squinting at
17:08:30FromDiscord<Phil> (edit) "at" => "at!"
17:08:46FromDiscord<Yardanico> In reply to @Rika "`2+3 * 5*2 ": this works the way it's written, strong spaces aren't really enabled for most stuff anymore
17:09:13FromDiscord<Rika> In reply to @Yardanico "this works the way": it doesnt?
17:09:23FromDiscord<Yardanico> ? https://media.discordapp.net/attachments/371759389889003532/967834648577183804/unknown.png
17:09:25FromDiscord<Rika> `2+3 ...` is not `(2 + 3) (...)`
17:09:34FromDiscord<Yardanico> In reply to @Rika "`2+3 * ...` is": it gives 27
17:09:39*emery quit (Ping timeout: 272 seconds)
17:09:50FromDiscord<Yardanico> which is literally 2 + 3 5 2 5/6
17:09:50*ehmry joined #nim
17:09:57FromDiscord<Rika> look at what i wrote
17:09:59FromDiscord<Rika> its not equivalent
17:10:01FromDiscord<Solitude> yardanico
17:10:04FromDiscord<Solitude> you are a dumbass
17:10:13FromDiscord<Yardanico> In reply to @Solitude "you are a dumbass": i copied the exact thing
17:10:15FromDiscord<Rika> !eval echo ((2+3) (5 2)) (5/6)
17:10:16FromDiscord<Solitude> yes
17:10:16NimBotCompile failed: /usercode/in.nim(1, 13) Error: invalid token: (\29)
17:10:19FromDiscord<Solitude> reading comprehension
17:10:21FromDiscord<Solitude> holy shit
17:10:23FromDiscord<Rika> ok thanks bot
17:10:29FromDiscord<Yardanico> !eval echo 2+3 52 5/6
17:10:30NimBotCompile failed: /usercode/in.nim(1, 10) Error: invalid token: (\29)
17:10:33FromDiscord<Rika> thats not
17:10:34FromDiscord<Rika> omfg
17:10:38FromDiscord<Solitude> he is talking about strong whitespace
17:10:51FromDiscord<spoon> are you talking about order of operation?
17:10:51FromDiscord<Rika> phil mentioned strong spaces
17:11:01FromDiscord<Phil> fascinating, that one doesn't fail in inim
17:11:04FromDiscord<Yardanico> give me a nim snippet please
17:11:07FromDiscord<Yardanico> with code blocks
17:11:11FromDiscord<Yardanico> so i can rest at peace
17:11:14FromDiscord<Solitude> strong whitespace is removed from language
17:11:15FromDiscord<Phil> Yard, just open inim
17:11:18FromDiscord<Yardanico> In reply to @Solitude "strong whitespace is removed": i know
17:11:18FromDiscord<Rika> In reply to @Rika "!eval echo ((2+3) *": this is what it would be equivalent to no?
17:11:27FromDiscord<Solitude> yes
17:11:33FromDiscord<Rika> In reply to @Rika "`2+3 * 5*2 ": from this
17:11:39FromDiscord<spoon> 2+(305/6)
17:11:40FromDiscord<Yardanico> if strong space was still a thing
17:11:43FromDiscord<Rika> exactly
17:11:45FromDiscord<Rika> thats my point
17:11:45FromDiscord<Rika> what
17:12:00FromDiscord<Yardanico> you
17:12:01FromDiscord<Yardanico> didnt
17:12:03FromDiscord<Yardanico> mention
17:12:03FromDiscord<Yardanico> it
17:12:04FromDiscord<Yardanico> explicitly
17:12:05FromDiscord<Phil> I don't think so, wouldn't ((2+3)(52)(5/6)) = 550/6 = 250/6 = 41 2/3?
17:12:16FromDiscord<Rika> In reply to @Isofruit "I'm still squinting hard": PHIL SAID IT RIGHT BEFORE I WROTE IT
17:12:16FromDiscord<Solitude> read the context dummy, he wrote that right after it was mentioned
17:12:31FromDiscord<Phil> (edit) "((2+3)(52)(5/6))" => "((2+3)\(5\2)\(5/6))" | "550/6" => "5\50/6"
17:12:39FromDiscord<Yardanico> In reply to @Solitude "read the context dummy,": i thought he was talking about command invocation syntax 🤷
17:12:44FromDiscord<Solitude> its over yardanico
17:12:44FromDiscord<Yardanico> its also "whitespace as brackets"
17:12:48FromDiscord<Solitude> hand over your mod badge
17:12:51FromDiscord<Phil> I'm so confused now
17:12:52FromDiscord<Yardanico> `readLine stdin` vs `readLine(stdin)`
17:13:18FromDiscord<Rika> well okay then we were both confused
17:13:26FromDiscord<Phil> Anyway, I had originally assumed Rika's example would evaluate to the bracket syntax above.↵It has turned out that's not the case, I have learned now, nice
17:13:42FromDiscord<Rika> In reply to @Isofruit "Anyway, I had originally": it wouldnt in nim, no longer
17:13:51FromDiscord<Phil> Thankfully
17:14:14FromDiscord<Phil> ~~One more reason to squint at that sort of syntax any time I see it and promote brackets~~
17:14:27*ehmry quit (Ping timeout: 276 seconds)
17:14:32*emery joined #nim
17:14:37FromDiscord<Phil> Maybe I just suffer a very strong case of bracket-stockholm-syndrome
17:15:03FromDiscord<Rika> you suffer a case of stockholm syndrome from java
17:15:14*Gustavo6046 joined #nim
17:15:21FromDiscord<Phil> Now wait a second, I was a fan of brackets way before java
17:15:28FromDiscord<Phil> Except for curly braves around function
17:15:30FromDiscord<Phil> That can fuck off
17:15:38FromDiscord<Phil> (edit) "braves" => "braces"
17:15:39FromDiscord<Rika> {func()}? wdym
17:16:08FromDiscord<Phil> `private void blabla(){ <Method body>}`
17:16:14FromDiscord<Phil> Those curly braces
17:16:19FromDiscord<Yardanico> you can also emulate those in nim :)
17:16:23FromDiscord<Rika> why would you like brackets in general EXCEPT for that
17:16:25FromDiscord<Rika> thats weird
17:16:42FromDiscord<Rika> In reply to @Yardanico "you can also emulate": with the added bonus of required semicolons hahaha
17:16:53FromDiscord<Yardanico> @Phil have you seen https://github.com/nim-lang/Nim/wiki/Lesser-known-Nim-features ?
17:16:57FromDiscord<Yardanico> it generally has a lot of cool stuff :)
17:17:08FromDiscord<Yardanico> braces example from here:
17:17:14FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3W8a
17:17:19FromDiscord<Yardanico> welcome to Janim
17:17:32FromDiscord<Yardanico> also, an old fact, but nim used to have a braces syntax skin
17:18:29FromDiscord<Phil> In reply to @Rika "why would you like": I want brackets to visually tell me exactly what things are part of a proc call or not.↵I don't need them to tell me what line is part of a method body and what isn't.↵In fact, I prefer it not being there and the compiler relying on indentation, because indentations are imo easier to visually identify to properly "group" lines of code that belong into the same codeblock together.
17:19:01FromDiscord<Phil> In reply to @Yardanico "<@180601887916163073> have you seen": I have not, I'll give it a read
17:19:09*emery quit (Ping timeout: 272 seconds)
17:19:10*ehmry joined #nim
17:21:41FromDiscord<spoon> wow
17:21:53FromDiscord<Phil> Okay, the indexing arrays with enums is pretty dope
17:21:55FromDiscord<spoon> sent a code paste, see https://play.nim-lang.org/#ix=3W8c
17:22:04FromDiscord<Yardanico> In reply to @Isofruit "Okay, the indexing arrays": yes, and it's much much faster than the "obvious" approach with a table
17:22:08FromDiscord<Yardanico> tens of times faster
17:22:21FromDiscord<Yardanico> like `Table[EnumType, value]` vs `array[EnumType, value]`
17:22:36FromDiscord<Phil> Shame I don't tend to have array types, it's seqs all the way down everywhere, but generally really cool
17:23:40*ehmry quit (Ping timeout: 250 seconds)
17:23:51*ehmry joined #nim
17:25:58FromDiscord<huantian> In reply to @Yardanico "like `Table[EnumType, value]` vs": And you can emulate missing keys with Option probably
17:26:05FromDiscord<Phil> Ohhhh default params based on passed in non-default params
17:26:17FromDiscord<Phil> That's pretty neat
17:28:31*emery joined #nim
17:28:32PMunchHmm, this array initializer with values is new to me
17:28:39*ehmry quit (Ping timeout: 272 seconds)
17:28:49FromDiscord<Yardanico> no, i mean value as in value type :)
17:29:10PMunchAnd also somewhat cursed: https://play.nim-lang.org/#ix=3W8g :P
17:29:58FromDiscord<Yardanico> oh yeah this is actually documented in the manual
17:30:08FromDiscord<Yardanico> maybe i should add it to that wiki as well
17:30:20FromDiscord<Yardanico> it's in array section of the manual in "An array constructor can have explicit indexes for readability"
17:30:23PMunchIt's in that Wiki, that's where I found it :P
17:30:35PMunchUnder this section: https://github.com/nim-lang/Nim/wiki/Lesser-known-Nim-features#using-enums-as-array-indexes
17:30:43PMunchBut it doesn't mention that it work for normal indices as well
17:30:44FromDiscord<Yardanico> ah yeah
17:30:53*xet7 quit (Remote host closed the connection)
17:30:59FromDiscord<Solitude> In reply to @PMunch "And also somewhat cursed:": epic https://play.nim-lang.org/#ix=3W8h
17:31:09FromDiscord<Yardanico> zamn
17:31:16FromDiscord<Solitude> truly a zamn moment
17:31:16PMunchWe should write a simple program where we try to use the most cursed Nim code style possible
17:31:16FromDiscord<Yardanico> yeah arrays can start at arbitrary indexes
17:31:19FromDiscord<Yardanico> a lot of languages can't
17:31:43FromDiscord<Solitude> In reply to @PMunch "We should write a": this is a go to styleguide https://github.com/nim-lang/Nim/issues/19686
17:31:46PMunch@Solitude, oh that is interesting..
17:32:04*xet7 joined #nim
17:32:09FromDiscord<Yardanico> In reply to @Solitude "this is a go": shh this is a feature (TM)
17:32:45PMunch@Solitude, oh goodness gracious..
17:33:32FromDiscord<Phil> In reply to @PMunch "<@104136074569211904>, oh goodness gracious..": There are not balls of fire great enough for this
17:33:39FromDiscord<Phil> (edit) "not" => "no"
17:33:47FromDiscord<Yardanico> is it time for example_case yet @Solitude
17:34:08PMunchHmm, I can't get it to work for me
17:34:10FromDiscord<Yardanico> i don't remember if Phil seen it already
17:34:24FromDiscord<Yardanico> In reply to @Isofruit "There are no balls": https://raw.githubusercontent.com/Yardanico/nuglifier/master/example_output/example_case.nim
17:34:43FromDiscord<Phil> In reply to @Yardanico "https://raw.githubusercontent.com/Yardanico/nuglifi": Ah yes, death in code
17:34:49FromDiscord<Yardanico> it compiles and runs just fine btw
17:34:58FromDiscord<Yardanico> its my math evaluator
17:35:01FromDiscord<Phil> I veto this
17:35:15PMunchAh, the first example doesn't work for me on latest devel, all the others does though
17:35:18FromDiscord<Phil> I'll even veto the veto just so I can veto this again
17:35:32FromDiscord<Yardanico> how can you not enjoy the `pROC aD_DF_unC(e: Ev_ALU_aT_Or, namE: sT_RI_ng, fUN: Ma_tHF_UnC_Ti_ON, ar_gC_OunT = -1) =`
17:35:34FromDiscord<Phil> Seek help before you write this
17:35:45FromDiscord<Yardanico> In reply to @Isofruit "Seek help before you": luckily i haven't done this by hand :)
17:35:52FromDiscord<Yardanico> https://github.com/Yardanico/nuglifier
17:35:58FromDiscord<enthus1ast> i just saw aids scroll by↵(@Yardanico)
17:36:08FromDiscord<Yardanico> need to update it to finally fix the indentation bugs maybe
17:36:30FromDiscord<Phil> In reply to @enthus1ast "i just saw aids": I'm pretty sure in terms of horrible things I've seen this year this is competing in the same league as Covid
17:36:31PMunchUsing source code filters are a bit of cheating though
17:36:50FromDiscord<Yardanico> In reply to @PMunch "Using source code filters": those are only for zero width space and tabs indentation here :)
17:37:09PMunchAah, that's what the first one did there
17:37:13FromDiscord<Yardanico> nuglifier uses compiler as a library too btw, its lexer more specifically
17:37:19PMunchzero width space indentation is truly cursed :P
17:37:24FromDiscord<Yardanico> yeah
17:37:32FromDiscord<Yardanico> and in nim different blocks can have different indentation levels
17:37:37FromDiscord<Yardanico> it just has to match for one indentation block
17:37:54FromDiscord<Phil> In reply to @Yardanico "https://github.com/Yardanico/nuglifier": Yard, why would you do this
17:38:08FromDiscord<Phil> Why would you bring such a cursed abomination into this world?
17:38:11FromDiscord<Yardanico> we toyed around in discord
17:38:13FromDiscord<Yardanico> and then i made this
17:38:14FromDiscord<Phil> Do you just want to see the world burn around you?
17:38:16FromDiscord<Yardanico> lemme find the original paste
17:38:31FromDiscord<Phil> Is there not enough suffering in this world yet?
17:38:33FromDiscord<Yardanico> https://play.nim-lang.org/#ix=2qcg
17:38:38FromDiscord<Yardanico> this is what i was inspired with
17:38:51FromDiscord<Yardanico> this is a result of crowdsources effort of a few people
17:38:56FromDiscord<Phil> I will admit this looks like a helicopter in a side-scroller shooter
17:39:03FromDiscord<Yardanico> LOL
17:39:31FromDiscord<Phil> You even got the solid walls on top and the bottom
17:39:35PMunchI like that since that's a play link I can just hit run and see the madness actually running :P
17:40:03FromDiscord<Phil> This piece of source code is sad, justifiably so https://media.discordapp.net/attachments/371759389889003532/967842369275826226/unknown.png
17:40:08FromDiscord<Yardanico> just don't show this to newbies
17:40:09*vicfred joined #nim
17:40:15FromDiscord<Yardanico> or they'll complain that nim is harder to read than rust
17:40:57FromDiscord<Phil> > hell o wo_Rld!↵This is, indeed, hell
17:41:09FromDiscord<Rika> wait wtf
17:41:12FromDiscord<Rika> japanese
17:41:13FromDiscord<Rika> really
17:41:18FromDiscord<Yardanico> yes @Rika it's yours i think
17:41:22FromDiscord<Yardanico> from like a year ago or something
17:41:41FromDiscord<Yardanico> i mean the japanese part is yours
17:41:43FromDiscord<Phil> I always knew that Rika also created monsters as a hobby
17:41:56FromDiscord<Rika> it is?
17:41:59FromDiscord<Yardanico> maybe
17:42:02FromDiscord<Rika> i dont remember speaking japanese
17:42:03FromDiscord<Yardanico> i don't remember for sure, it was a long time ago
17:43:07FromDiscord<Yardanico> why do something productive when you can instead show how to abuse nim's syntax rules :)
17:45:39FromDiscord<Phil> I mean, it's creative, and creative is fun
17:45:55FromDiscord<Phil> I could rewatch Dylan's beaties "The Art of Programming" talk over and over
17:46:09FromDiscord<Phil> (edit) "beaties" => "beatties"
17:46:32FromDiscord<Phil> It's just really fun, diving into a lot of weirdness and fascinating and useless stuff
17:46:39FromDiscord<Phil> Like this
17:47:11FromDiscord<Phil> Apparently there's a bad-code-consortium, trying to bets-worst examples of code ever written
17:47:35FromDiscord<Phil> Which includes Code shaped like a mandelbrot set
17:47:56FromDiscord<huantian> In reply to @Yardanico "https://github.com/Yardanico/nuglifier": Why is it so much harder to do the opposite of this
17:47:57FromDiscord<Phil> (edit) "bets-worst" => "conserve the best-worst"
17:48:35FromDiscord<Yardanico> because beautiful is subjective
17:48:49FromDiscord<Phil> https://www.youtube.com/watch?v=6avJHaC3C2U↵For anyone wanting to entertain themselves if they haven't watched it already
17:49:27FromDiscord<Rika> In reply to @Yardanico "because beautiful is subjective": not really, its because "beautiful" is a smaller set than "ugly"
17:50:00FromDiscord<Phil> ~~Beautiful is writing your constants in screaming case~~
17:50:11FromDiscord<Yardanico> In reply to @Rika "not really, its because": that too
17:52:15FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=3W8k
17:52:41FromDiscord<Yardanico> nooo but if is slow because some random youtuber said so!!!
17:57:56PMunchHuh, apparently HDMI has a i2c port..
17:57:57PMunchhttps://mitxela.com/projects/ddc-oled
17:58:05PMunchThat could be useful, for, stuff
18:04:37FromDiscord<golova> In reply to @huantian "I mean this is": Is that a valid code?
18:04:43FromDiscord<Yardanico> of course?
18:05:03FromDiscord<Yardanico> nim has if expressions
18:05:11FromDiscord<golova> I mean i saw smth like that but with block: and const
18:05:23FromDiscord<Yardanico> yes, that will work too since there are block expressions as well
18:06:48*oprypin quit (Quit: No Ping reply in 180 seconds.)
18:06:59FromDiscord<huantian> Omitting the block is more consise tho
18:07:21FromDiscord<Yardanico> huh?
18:07:26FromDiscord<Yardanico> @huantian he's talking about the block expression itself
18:07:41FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3W8q
18:08:05*oprypin joined #nim
18:08:14FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=3W8s
18:08:40FromDiscord<golova> Actually both cases
18:08:49FromDiscord<golova> Not sure if last one would work tho
18:08:50FromDiscord<Yardanico> well, there's nothing unique here, that's normal nim syntax
18:08:55FromDiscord<Yardanico> In reply to @golova "Not sure if last": of course
18:08:58FromDiscord<Yardanico> all branches always return a value so why not
18:09:24FromDiscord<golova> Now i realize that my code is ugly asf
18:10:02FromDiscord<Yardanico> last expression in a proc can also be used for the result
18:10:15FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3W8u
18:10:24FromDiscord<Yardanico> this gets interesting once you add case statements or ifs
18:10:42FromDiscord<Yardanico> for example https://github.com/pietroppeter/nimib/blob/main/src/nimib/highlight.nim#L52
18:10:43FromDiscord<Solitude> In reply to @golova "Now i realize that": now you can make it prettier and feel good about yourself
18:10:49FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3W8v
18:11:05FromDiscord<Yardanico> since the second line of the proc it's all a big case statement expression
18:11:11FromDiscord<Yardanico> with another case statement expression inside of it
18:11:21FromDiscord<Yardanico> but since all branches always return a value, nim takes its value as the result of the proc
18:11:55FromDiscord<Solitude> ^ powerfull stuff
18:11:59FromDiscord<Yardanico> full
18:12:05FromDiscord<Yardanico> zamning
18:12:18FromDiscord<Rika> return a value or raise an exception
18:12:29FromDiscord<Yardanico> yeah
18:13:26FromDiscord<Solitude> or make a dummy proc, mark it with noreturn and do a little trolling
18:13:36FromDiscord<Yardanico> and watch your computer go up in flames
18:13:48FromDiscord<d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=3W8x
18:14:05FromDiscord<Yardanico> you're not sending a line
18:14:08PMunch@golova, for more stuff regarding ifs/blocks and implicit return: https://peterme.net/tips-and-tricks-with-implicit-return-in-nim.html
18:14:10FromDiscord<Yardanico> recvLine expects a line with line terminators
18:14:17FromDiscord<d4rckh> oh
18:14:28FromDiscord<d4rckh> like terminator as in `\n`?
18:14:34FromDiscord<Yardanico> \r\n
18:14:51PMunchOr \n if you're on Linux
18:15:06PMunchWell, if you're on any other system than Windows
18:15:13FromDiscord<d4rckh> wow it works! thank you
18:15:41FromDiscord<Yardanico> that's the usual protocol stuff - client or server need to know where the transmission "ends"
18:15:46FromDiscord<d4rckh> also, whenever i have both of my client and server connected, and i quit the server, the client just prints blank lines forever, what causes that?
18:15:53FromDiscord<Yardanico> of course it's possible to just receive all data with unbuffered sockets, but it's unreliable
18:18:15FromDiscord<d4rckh> interesting
18:24:27*duuude quit (Ping timeout: 240 seconds)
18:30:30FromDiscord<d4rckh> I am trying to have some sort of cli to interact with the clients, like send them messages and things, but i noticed that i cant have 2 while loops running at the same thing 😅, one to receive the messages from the cli and another one to listen to messages from the clients. what would be the best way of handling this?
18:31:11PMunchHmm, I'm creating a system for deriving types. Say I have a base type A and a procedure that takes A and returns B and one which takes B and returns C. I want to be able to say that I have A and want C and have the system figure out what to call in order to get there. I guess some kind of linked structure with a table lookup would be a good way to go about it?
18:31:19FromDiscord<huantian> In reply to @d4rckh "I am trying to": ✨ async ✨
18:31:20FromDiscord<huantian> Probably
18:31:43PMunchAsync is definitely one way of doing it
18:31:56PMunchRunning two threads would also work (although a bit overkill)
18:32:23PMunchOr you could just poll to see if a message is incoming, otherwise check if the user is typing anything and then loop all of that
18:33:52FromDiscord<Rika> In reply to @PMunch "Hmm, I'm creating a": yeah something that can resolve graphs like that
18:34:09FromDiscord<Rika> because in the end what you're describing is kinda a graph
18:34:15PMunchYeah it is
18:34:24FromDiscord<d4rckh> async would like, run them concurrently right? not parallel like threads would do
18:34:27PMunchThe structure would definitely have to be graph-like
18:34:34PMunch@d4rckh, correct
18:34:45FromDiscord<Rika> you dont need parallel here
18:34:46PMunchBasically async does the third thing I wrote
18:34:58FromDiscord<d4rckh> right, i dont need parallelism here
18:35:43PMunchYou give it a couple of file descriptors (your input socket and your terminal input socket) and then it will tell the operating system to notify it when either of them are ready. Then when they are the action associated with that thing is executed
18:35:54PMunchOf course all of that is wrapped away in layers of abstraction
18:36:01*duuude joined #nim
18:36:07PMunchSo your code looks similar to threaded code in a way
18:37:02PMunchThe easiest would be to have two async procedures, both with their own while true loop, and then do an async read from the socket and the terminal input
18:37:18PMunchThen in your main program you asyncCheck start them both and then runForever()
18:37:21PMunchOr something like that
18:37:41FromDiscord<d4rckh> yup, thats what im doing
18:37:49FromDiscord<dom96> In reply to @d4rckh "I am trying to": @d4rckh this should help you: https://github.com/dom96/nim-in-action-code/tree/master/Chapter3/ChatApp
18:38:23FromDiscord<dom96> you cannot asynchronously await for data to be read on stdin, the example I linked shows how to get around that
18:39:21FromDiscord<d4rckh> oh yeah, indeed, the communication stopped
18:40:57PMunchWait, so you're spawning a new thread to run the user input?
18:41:20PMunchIs this a Windows thing? I'm positive you can async read standard input on Linux
18:42:02FromDiscord<dom96> yes, this is required for Windows
18:42:09FromDiscord<dom96> indeed, on Linux it's doable
18:42:30FromDiscord<dom96> if you don't care about Windows you can just use asyncfile with stdin as the file descriptor
18:42:52FromDiscord<dom96> it's funny how often this comes up though
18:43:35PMunchPeople like making CLI applications I guess
18:43:45FromDiscord<dom96> I think it's important we make awaiting of spawned threads work well and then just implement this logic in the stdlib, with Windows using threads and Linux not
18:43:52PMunchIt's weird that you can't read Windows stdin asynchronously though..
18:44:20PMunchYeah I'd definitely want await for threads, channels, and locks
18:44:23PMunchThat'd be great
18:44:37FromDiscord<d4rckh> In reply to @dom96 "if you don't care": i do care about windows 😄
18:45:02FromDiscord<d4rckh> oh yeah, thats why it didnt work on python last year when i did something similar
18:47:16PMunch@Rika, hmm since I need the table lookup I could just store identifiers to other types as a list in the table
18:47:35PMunchInstead of a full blown tree structure with a table for indexing
18:47:43FromDiscord<dom96> In reply to @d4rckh "i do care about": then just copy the code in the link I gave you, it's in client.nim 🙂
18:47:48PMunchSure traversal will be a bit slower, but that's not really a problem
18:48:00FromDiscord<d4rckh> In reply to @dom96 "then just copy the": i need to adapt it, my server has the cli :\(
18:48:10FromDiscord<d4rckh> not clients
18:49:28FromDiscord<dom96> shouldn't be a problem
18:50:22*krux02 quit (Remote host closed the connection)
18:51:02*krux02 joined #nim
18:53:50FromDiscord<d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=3W8D
18:53:55FromDiscord<d4rckh> it is able to receive commands, but not listen to my stdin
18:54:12FromDiscord<d4rckh> just trying to echo back what im inputting for now
18:54:50FromDiscord<dom96> In reply to @d4rckh "it is able to": hm, not sure what you mean by this. What exactly doesn't work?
18:55:14FromDiscord<d4rckh> if i am entering something, it wont back
18:55:16FromDiscord<dom96> but actually I see the problem, you only check for messageFlowVar once
18:55:26FromDiscord<dom96> you should be doing this in a loop
18:55:50FromDiscord<dom96> create another procs called `pollStdin` and copy the `messageFlowVar.isReady():` if branch in there
18:56:08FromDiscord<dom96> do this in a while loop and `await sleepAsync(10)` to give time for the IO loop to do its work
18:58:16*vicfred quit (Quit: Leaving)
18:59:32FromDiscord<d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=3W8F
18:59:42*vicfred joined #nim
19:01:47FromDiscord<d4rckh> 🤔 i think im missing something
19:03:30FromDiscord<d4rckh> oh i fucked the order
19:03:34FromDiscord<d4rckh> silly me
19:05:09FromDiscord<d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=3W8I
19:06:41FromDiscord<dom96> sure, that works. You can also replace the `poll` with ` sleepAsync` and have a runForever() at the bottom
19:06:59FromDiscord<dom96> Doing `poll` in an async proc is bound to lead to issues 🙂
19:07:11FromDiscord<dom96> best to just do `poll` at the top-level
19:11:47FromDiscord<huantian> ☝️
19:16:07FromDiscord<d4rckh> In reply to @dom96 "sure, that works. You": sure!
19:24:08*duuude quit (Ping timeout: 248 seconds)
19:25:51FromDiscord<d4rckh> @dom96 do you have any idea how could i avoid repeating `var messageFlowVar = spawn stdin.readLine()`?
19:25:56FromDiscord<d4rckh> (edit) "@dom96 do you have any idea ... how" added "on"
19:26:25FromDiscord<huantian> Maybe you could make a generalized readLineAsync
19:26:42FromDiscord<huantian> Which you await in procStdin
19:28:51FromDiscord<huantian> Since this new proc would only read once you don’t have to reassign
19:44:05*Gustavo6046 quit (Quit: Goodbye! Leave messages at my XMPP @ [email protected] or my Discord Gustavo6046#9009 or possibly my Mastodon [email protected] – I don't check my email often since it's full of crap, but in any case, [email protected])
20:17:32*ssiyad quit (Remote host closed the connection)
20:32:22FromDiscord<TryAngle> can nim somehow do a seq of inherited objects?
20:34:59FromDiscord<demotomohiro> https://internet-of-tomohiro.netlify.app/nim/faq.en.html#coding-how-to-store-different-types-in-seqqmark
20:35:27PMunch@TryAngle, as long as they are ref objects, sure: https://play.nim-lang.org/#ix=3W94
21:00:29FromDiscord<TryAngle> In reply to @PMunch "<@147447489316913152>, as long as": thanks!↵but when I try to store this seq in a type I have to cast the vals to the RootObj type↵and then I'm kinda stuck "uncasting" them? 🤔
21:01:22FromDiscord<TryAngle> `x of X`↵only works for uncasted ref objects of T
21:02:04FromDiscord<huantian> No it doesn’t?
21:03:06FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3W9b
21:03:48FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3W9d
21:03:51FromDiscord<huantian> https://play.nim-lang.org/#ix=3W9c
21:03:54*vicfred quit (Ping timeout: 276 seconds)
21:04:31FromDiscord<huantian> Well yeah you’d have to check/know that all the values in the seq are of the type you want and then cast them
21:04:36FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3W9d" => "https://paste.rs/2pK"
21:05:05*xet7 quit (Remote host closed the connection)
21:06:05FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3W9e
21:07:03FromDiscord<TryAngle> but then for example in `$`↵`if e of Declaration:` does not work then
21:07:12FromDiscord<TryAngle> (edit) "e" => "expression"
21:07:37FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=3W9f
21:07:58FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3W9g
21:09:23FromDiscord<TryAngle> wait I will put all the code on play-nim
21:10:10FromDiscord<TryAngle> https://play.nim-lang.org/#ix=3W9h
21:12:18FromDiscord<TryAngle> I can also put everything into a variadic object but this would get big really fast 🤔
21:13:04FromDiscord<huantian> https://play.nim-lang.org/#ix=3W9j
21:13:06FromDiscord<huantian> Maybe?
21:13:38FromDiscord<huantian> I’d just use a variadic object personally
21:14:26FromDiscord<TryAngle> In reply to @huantian "I’d just use a": hmm maybe I should also...↵are how big do variadic objects get? their biggest variance or like everything is a field?
21:14:35FromDiscord<TryAngle> In reply to @huantian "https://play.nim-lang.org/#ix=3W9j": lol why does this work
21:14:41FromDiscord<Rika> Biggest variance
21:15:30*vicfred joined #nim
21:15:34FromDiscord<TryAngle> In reply to @Rika "Biggest variance": oh!
21:15:42FromDiscord<TryAngle> guess I use them also then
21:16:06FromDiscord<TryAngle> In reply to @TryAngle "lol why does this": ????? it does work now also, apparnelty I didn't press save button on my pc or something wtf
21:16:12FromDiscord<Rika> Lol
21:16:37FromDiscord<TryAngle> but vsc autosaves o_O
21:16:39FromDiscord<TryAngle> makes no sense
21:17:55FromDiscord<TryAngle> what is faster and less memory footprint @Rika @huantian, variadic or single ref objects for a lot of variance / different ref objects?
21:18:13FromDiscord<TryAngle> or is it same because it compiles to same
21:18:14FromDiscord<Rika> Benchmark if.
21:18:16FromDiscord<Rika> It
21:18:23FromDiscord<Rika> They do not compile the same
21:19:16*vicfred quit (Client Quit)
21:20:56*vicfred joined #nim
21:21:01*PMunch quit (Quit: leaving)
21:33:05FromDiscord<Nanozet> sent a code paste, see https://paste.rs/x2f
21:33:16FromDiscord<Nanozet> (edit)
21:33:44FromDiscord<Nanozet> sent a code paste, see https://play.nim-lang.org/#ix=3W9n
21:34:02FromDiscord<Elegantbeef> your `[]` doesnt return `var Machine`
21:34:14FromDiscord<Elegantbeef> 'machines[machineResult]' is immutable, not 'var'
21:35:15FromDiscord<Nanozet> so seq elements are immutable by default
21:35:43FromDiscord<Elegantbeef> No
21:36:00FromDiscord<Nanozet> ok I am stupid
21:36:03FromDiscord<Elegantbeef> If you're not passing `var seq[T]` it's immutable
21:36:03FromDiscord<Elegantbeef> Nim parameters are immutable by default and require `var T`
21:36:12FromDiscord<Nanozet> I was using let didnts see that
21:36:19FromDiscord<Nanozet> thx
21:36:32FromDiscord<Nanozet> (edit) "didnts" => "didn't"
21:36:44FromDiscord<Nanozet> (edit) "let" => ""let","
21:53:01*Zectbumo joined #nim
22:15:42*Zectbumo quit (Remote host closed the connection)
22:19:42*arkurious quit (Quit: Leaving)
22:24:11*krux02 quit (Quit: Leaving)
22:41:11*jjido joined #nim
22:43:53*fowl quit (Quit: cya pals)
22:44:36*fowl joined #nim
22:45:55*fowl quit (Client Quit)
22:48:36*fowl joined #nim
23:08:46*xet7 joined #nim
23:10:49*Zectbumo joined #nim
23:14:25FromDiscord<TryAngle> is there some way to call module a in b and b in a?
23:14:36FromDiscord<TryAngle> via a pragma, or partial import
23:16:05FromDiscord<ynfle> What do you mean by call a module?
23:21:45FromDiscord<TryAngle> In reply to @ynfle "What do you mean": import
23:21:52FromDiscord<TryAngle> (edit) "import" => "I mean import"
23:22:04FromDiscord<huantian> If you have recursive imports you need to restructure
23:23:09FromDiscord<TryAngle> In reply to @huantian "If you have recursive": are triangular importas allowed?↵A -> B↵A <- C <- B
23:23:12FromDiscord<Elegantbeef> Not always
23:23:35FromDiscord<Elegantbeef> Depends on what you need but you can do recursive imports if you delay them, but it only gives you up until that imported module
23:32:51*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
23:52:28FromDiscord<riplooke> How can I tell what Linux distro someone is using in nim
23:52:52*droidrage joined #nim
23:53:28FromDiscord<Elegantbeef> https://nim-lang.org/docs/distros.html
23:54:48FromDiscord<riplooke> Thx