<< 28-10-2021 >>

00:05:48*TakinOver joined #nim
00:50:24*vicfred quit (Quit: Leaving)
01:33:51*ad-absurdum joined #nim
01:43:22*arkurious quit (Quit: Leaving)
02:33:08*xet7 quit (Quit: Leaving)
02:51:57*TakinOver quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
03:22:57FromDiscord<evoalg> to get the max value in a seq containing ints, I can't seem to do: max(myseq), so I have to do: myseq[maxIndex(myseq)] ... is that really what I should do?
03:23:15FromDiscord<Elegantbeef> `myseq[^1]`?
03:23:39FromDiscord<evoalg> not the value of the max index, but the max value
03:23:55FromDiscord<Elegantbeef> `mySeq.high`?
03:24:41FromDiscord<evoalg> that's the max index, but I want the max value that myseq holds
03:25:06FromDiscord<Elegantbeef> you want the highest value stored in the seq?
03:25:15FromDiscord<evoalg> yes
03:26:49FromDiscord<evoalg> maxIndex returns the index of the maximum value of a seq, so maxIndex(myseq) returns the index of that highest value stored in seq, but to get that actual value, I seem to have to do: myseq[maxIndex(myseq)] ... other programming languages it's just "max(myseq)"
03:27:24FromDiscord<impbox [ftsf]> Sounds like something that would be in a statistics library
03:28:27FromDiscord<evoalg> ahhh ... I tried googling and looked at math, sequtils but they didn't have it ... and I couldn't see anything else in google .. I'll try stat library...
03:29:23FromDiscord<Rika> https://nim-lang.org/docs/sequtils.html#maxIndex%2CopenArray%5BT%5D
03:29:59FromDiscord<Elegantbeef> wait max should work
03:30:20FromDiscord<Rika> https://nim-lang.org/docs/system.html#max%2CopenArray%5BT%5D
03:30:27FromDiscord<Elegantbeef> !eval var a = @[10, 20, 5, 100, 3]; echo a.max
03:30:29NimBot100
03:30:58FromDiscord<evoalg> oh it works out of the box? ... gosh must be my code then ... thanks!
03:31:21FromDiscord<Elegantbeef> If you're doing `yourSeq.max = someVal` it wont work
03:32:31FromDiscord<evoalg> it works ... gosh I dunno what I was doing before ... hehe it was driving me a bit crazy ... thank you all for your help once again!
03:33:12FromDiscord<evoalg> (... and I thought it was strange that I could do "sum" but not "max" hehe)
03:44:00*ad-absurdum quit (Remote host closed the connection)
03:46:25*ad-absurdum joined #nim
03:57:22*ad-absurdum quit (Remote host closed the connection)
04:06:02*supakeen quit (Quit: WeeChat 3.3)
04:06:32*supakeen joined #nim
04:25:00*rockcavera quit (Remote host closed the connection)
04:39:28FromDiscord<theangryepicbanana> In reply to @Elegantbeef "If you're doing `yourSeq.max": wait this is a cool idea though
04:41:03FromDiscord<Elegantbeef> Sure it's doable just not clear what it should do 😛
04:41:55FromDiscord<theangryepicbanana> it would assign the max value in a seq to something else, no?
04:42:11FromDiscord<Elegantbeef> It could or it could just add a new value that's max
04:42:19FromDiscord<Elegantbeef> Both would be technically correct
04:42:37FromDiscord<Elegantbeef> I'm kidding mostly, it should mutate
04:42:40FromDiscord<theangryepicbanana> yeah but that seems less helpful and less intuitive
04:43:18FromDiscord<theangryepicbanana> ah ok
04:43:54FromDiscord<Elegantbeef> But luckily it's easy to implement https://play.nim-lang.org/#ix=3D7O
04:44:20FromDiscord<theangryepicbanana> yeah I figured, pretty neat
05:57:15NimEventerNew Nimble package! db_nimternalsql - An in-memory SQL database library, see https://github.com/rehartmann/nimternalsql
06:27:29FromDiscord<Revenant> hey there, just upgraded to 1.6.0 and i'm getting a lot of HoleEnumConv warnings in my code
06:27:34FromDiscord<Revenant> any way to suppress only those?
06:27:46FromDiscord<Revenant> can't use the hint disabling mechanism, because it's not a hint...
06:29:24FromDiscord<Revenant> ooooooo, just tried `warning "HoleEnumConv", false` and it worked!
06:29:43FromDiscord<Revenant> should be probably documented in the manual, though
06:31:03FromDiscord<Elegantbeef> It's in the compiler user guide and on the 1.6.0 changelogs
06:31:44FromDiscord<Revenant> cheers, but info about disabling hints is in the manual
06:31:58FromDiscord<Revenant> it's a bit counterintuitive to start looking for missing info in the compiler docs 🙂
06:32:09FromDiscord<Revenant> if you don't find it in the manual
06:32:24FromDiscord<Elegantbeef> The compiler docs document the compiler interface
06:32:42FromDiscord<Elegantbeef> Guess you're using the pragma though
06:33:01FromDiscord<Elegantbeef> https://nim-lang.org/docs/nimc.html#compiler-usage-list-of-warnings for reference
06:33:36FromDiscord<Revenant> yes yes, but the manual also partially contains info that's in the compiler manual, that is why it's misleading
06:34:00FromDiscord<Revenant> thanks for that link
06:34:29FromDiscord<Revenant> i'm talking about this
06:34:30FromDiscord<Revenant> https://nim-lang.org/docs/manual.html#pragmas-disabling-certain-messages
06:34:39FromDiscord<Revenant> that's in the manual but it only mentions hints
06:34:58FromDiscord<Elegantbeef> Yea it should mention warning/hints and link to the compiler guide for a list of them
06:35:06FromDiscord<Rika> Well it does
06:35:09FromDiscord<Rika> At the first line
06:35:19FromDiscord<Rika> Just the example doesn’t show warning disabling
06:35:20FromDiscord<Revenant> yes, because some people might just give up at that point instead of looking everywhere 🙂
06:35:31FromDiscord<Elegantbeef> Well time for a PR to docs revenant 😛
06:35:38FromDiscord<Revenant> haha yeah 😄
06:35:46FromDiscord<Revenant> i might do that actually
06:35:47FromDiscord<Rika> Smh beef you’re lazy why not do it yourself
06:35:53FromDiscord<Rika> I’m joking
06:35:57FromDiscord<Revenant> noticed the manual is lagging behind quite a bit in general
06:35:58FromDiscord<Elegantbeef> too busy looking at the VM
06:36:11FromDiscord<Rika> Man are you in love with it or something
06:36:22FromDiscord<Elegantbeef> No i'm trying to clean it up/optimize it
06:37:22FromDiscord<Elegantbeef> I did find something that can cause a sizable compilation impact if using macros so take that 😛
06:40:41FromDiscord<Rika> What is it
06:40:44FromDiscord<Revenant> umm, disabling warnings work when provided as a compiler flag, but how do i do it per file? or per proc would be even better
06:40:51FromDiscord<Revenant> tried this at the top of the file `{.warningHoleEnumConv:off.}`
06:40:58FromDiscord<Rika> Probably using push
06:41:03FromDiscord<Revenant> that just gives me an error
06:41:05FromDiscord<Rika> Push and pop
06:41:06FromDiscord<Revenant> `Error: cannot attach a custom pragma to 'persistence'`
06:41:10FromDiscord<Elegantbeef> you dont need to push it
06:41:30FromDiscord<Rika> In reply to @Revenant "tried this at the": Isn’t this missing the angle brackets
06:41:33FromDiscord<Rika> Sorry
06:41:37FromDiscord<Rika> Square brackets
06:41:47FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3D8b
06:41:50FromDiscord<Rika> Am I going insane
06:42:00FromDiscord<Revenant> right...
06:42:00FromDiscord<Elegantbeef> or do `{.push warningHoleEnumConf.}` with `{.pop.}`
06:42:00FromDiscord<Revenant> thanks
06:42:13FromDiscord<Revenant> the manual actually contains some references to that in an offhand manner
06:42:22FromDiscord<Revenant> in the examples
06:42:58FromDiscord<Revenant> yeah so a general comment, and don't take it a wrong way, i think it should be made easy to find this info in the manual for a clueless person like me 🙂
06:43:25FromDiscord<Revenant> anyway, thanks, that gets me past my problems for now 🙂
06:44:40FromDiscord<Revenant> that push pragma thing is nifty
06:47:17FromDiscord<Elegantbeef> Though sadly doesnt work with destructors so you cannot error selectively on implicit copies
06:47:29FromDiscord<Elegantbeef> And you cannot make your own
06:48:47FromDiscord<Rika> I think the push pragma is a hack
06:49:20FromDiscord<Yardanico> why?
06:49:46FromDiscord<Yardanico> imo it's actually a pretty good alternative to indentation if you want to switch some stuff for a big block of code
06:49:52FromDiscord<Revenant> seems like you can only use it around proc/template/etc declarations, but not inside them
06:49:55FromDiscord<Revenant> still, that's good enough
06:50:28FromDiscord<Revenant> tried to narrow it down the usage to just a single line, but that didn't work. had to wrap the whole proc.
06:50:58FromDiscord<Elegantbeef> given the work why not just do `enum.ord.otherEnum`?
06:52:37FromDiscord<Revenant> well if you have a HoleyEnum, say E, whenever you do E(intval), you get the warning
06:53:04FromDiscord<Revenant> even if you use `enumutils` and do `E.items`, you get the warning
06:53:27FromDiscord<Revenant> so to me it seems the only way it just to suppress it
06:53:34FromDiscord<Revenant> (edit) "it" => "is"
06:53:56FromDiscord<Revenant> now i have this which is fine
06:54:08FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=3D8e
06:54:17FromDiscord<Revenant> (edit)
06:54:39FromDiscord<Revenant> actually, could get rid of the `name`...
06:54:41FromDiscord<Elegantbeef> `YourEnum(range[YourEnum.low.ord..YourEnum.high.ord](yourInt))`
06:54:41FromDiscord<Elegantbeef> Seems to work to me
06:55:01FromDiscord<Elegantbeef> you're catching an enum defect
06:55:08FromDiscord<Elegantbeef> Dont catch defects
06:55:49FromDiscord<Revenant> ok, but why does that matter if they're catchable?
06:56:00FromDiscord<Elegantbeef> Cause they're not always catachable
06:56:07FromDiscord<Elegantbeef> They're only catchable in some dialects
06:56:09FromDiscord<Rika> There is a setting that will not make them catchable
06:56:23FromDiscord<Revenant> hmm okay
06:56:26FromDiscord<Rika> It will crash the program instead
06:56:37FromDiscord<Elegantbeef> Nah it'll silently work
06:56:51FromDiscord<Elegantbeef> here is a write up about it https://forum.nim-lang.org/t/8342#53776
06:57:04FromDiscord<Revenant> hmm, `std/enumutils` doesn't seem that useful then
06:59:55FromDiscord<Revenant> well, your example still gives me the warning
06:59:58FromDiscord<Revenant> `Warning: conversion to enum with holes is unsafe: Foo(range[low(Foo).ord .. high(Foo).ord](5)) [HoleEnumConv]`
07:00:05FromDiscord<Elegantbeef> Odd
07:00:10FromDiscord<Elegantbeef> maybe i did it wrong 😀
07:00:11FromDiscord<Revenant> in any case, i'm happy with catching the defect for now 🙂 it works
07:00:27FromDiscord<Elegantbeef> Is this for a library or your own code?
07:00:34FromDiscord<Revenant> my own code
07:00:47FromDiscord<Revenant> i mean, some app i will release in binary form
07:01:10FromDiscord<Elegantbeef> Well as long as you build it so you can catch defects you'll be fine, but it's bad form
07:01:14FromDiscord<Revenant> yeah i get your point it can be problematic for a library that people are going to use in different ways on different platforms etc
07:01:56FromDiscord<Elegantbeef> So just disregard the defect then and ensure you never accidently disable catching defects 😛
07:01:59FromDiscord<Revenant> yeah, the only option is to suppress the warning, convert the result to string
07:02:18FromDiscord<Revenant> and if you instantiated a "hole", then this will be the stringified value: `2 (invalid data!)`
07:02:47FromDiscord<Revenant> then check if the string contains `(invalid data!)`... i thought using `symbolRank` will be less hacky
07:03:06FromDiscord<Revenant> ...but then i need to catch a defect 🤷‍♂️ hence i said, `enumutils` doesn't seem that useful, after all...
07:03:32FromDiscord<Elegantbeef> Yea this is the prefered solution imo but i'm biased 😀 https://forum.nim-lang.org/t/8188#52705
07:03:36*pro joined #nim
07:05:37FromDiscord<Revenant> thanks, probably this could go into the stdlib
07:05:43FromDiscord<Revenant> i'll try this
07:05:57FromDiscord<Revenant> guess it's a bit slower, but it doesn't actually matter in my case
07:06:45FromDiscord<Elegantbeef> It's 3 checks 1 of which is bitwise, so it's not overly complex
07:11:27*PMunch joined #nim
07:33:50*casionaut joined #nim
07:53:36meowray`var a: seq[cint]; a.reverse` generates something like `reverse_a_175((a0.p)->data, a0.len);` which may be a null pointer dereference. Does reverse support empty seq?
07:56:54FromDiscord<haxscramper> !eval import std/algorithm; var a: seq[int]; a.reverse()
07:56:56NimBot<no output>
07:57:25FromDiscord<haxscramper> as you can see there is no failure in execution, so yes
07:57:34FromDiscord<Yardanico> @haxscramper wonder how that works though
07:57:48FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3D8w
07:58:30meowrayi get a failure by compiling with -fsanitize=undefined
07:58:50meowrayfor-submit.c:2057:23: runtime error: member access within null pointer of type 'struct tySequence__9apztJSmgERYU8fZOjI4pOg_Content'
07:59:51FromDiscord<Yardanico> well nim doesn't always play nice with C compiler sanitizers like this :)
07:59:56FromDiscord<Yardanico> especially refc
08:00:00FromDiscord<haxscramper> I guess it has something to do with pointer magic
08:03:57meowrayok, i believe `var a: seq[int]; a.reverse()` is an arc/orc specific problem due to `reverse_a_175((a0.p)->data, a0.len);` refc seems fine
08:26:14*casionaut quit (Remote host closed the connection)
09:28:48FromDiscord<Stuffe> Does anyone know how garbage collection works with multi threading? I am creating a new thread with createThread(), but it looks like the garbage of that thread is not getting collected
09:29:44FromDiscord<Rika> Every thread has its own collector I would be led to believe
09:29:51FromDiscord<Rika> How are you passing data between threads
09:29:59FromDiscord<Stuffe> I use 2 channels
09:30:07FromDiscord<Stuffe> one for each direction
09:31:00FromDiscord<Rika> What kind of garbage are you seeing that isn’t being collected
09:31:31FromDiscord<Stuffe> I can just tell from system monitor that the program memory grows each time I send a task to the thread
09:31:39FromDiscord<Stuffe> and it never goes away
09:32:09FromDiscord<Stuffe> I know you may think I could have a reference to the data somewhere, but I really don't think that is the case
09:32:56FromDiscord<Stuffe> I might try to kill the threads and respawn them after each task instead of keeping this one thread alive
09:33:36FromDiscord<Rika> You can force a GC call
09:33:56FromDiscord<Rika> https://nim-lang.org/docs/gc.html
09:35:28FromDiscord<Stuffe> I tried GC_step, it only seems to work in the main thread
09:36:54*Vladar joined #nim
09:36:57FromDiscord<Rika> https://nim-lang.org/docs/system.html#GC_fullCollect
09:41:10FromDiscord<Stuffe> ok just tried that and it didn't help. But checking getFreeMem() from the first page you sent
09:41:21FromDiscord<Stuffe> that number just increases explosively
09:41:38FromDiscord<Stuffe> meaning the GC reserves a bunch of memory it doesn't reuse for some reason
09:43:42FromDiscord<Stuffe> no actually the used memory is also exploading
09:44:16FromDiscord<enthus1ast> Is this the winapi createThread? If yes, does the gc also works there?
09:44:57FromDiscord<Stuffe> https://nim-lang.org/docs/threads.html it is the one mentioned here
09:45:00FromDiscord<enthus1ast> Maybe with orc?
09:45:48FromDiscord<Stuffe> no I am not using orc
09:45:58FromDiscord<enthus1ast> Can you try?
09:46:20FromDiscord<Stuffe> wouldn't that be worse since it doesn't collect cycles?
09:46:24FromDiscord<Stuffe> I can try though why not
09:46:29FromDiscord<Yardanico> In reply to @Stuffe "wouldn't that be worse": what?
09:46:34FromDiscord<Yardanico> orc does collect cycles, arc doesn't
09:48:03FromDiscord<Stuffe> ah yes sorry
09:48:27FromDiscord<Stuffe> the library I am using does not allow me to use orc, I was able to try a few of the other ones though
09:48:34FromDiscord<Rika> Why not
09:48:41FromDiscord<Yardanico> what library? just curious
09:48:51FromDiscord<Stuffe> `/Users/stefanlund/.nimble/pkgs/godot-0.8.5/nim/godotnim.nim(899, 3) Error: undeclared identifier: 'GC_disable'`
09:48:56FromDiscord<Yardanico> oh godot nim
09:48:56FromDiscord<Stuffe> (edit) "`/Users/stefanlund/.nimble/pkgs/godot-0.8.5/nim/godotnim.nim(899," => "`/Users/.nimble/pkgs/godot-0.8.5/nim/godotnim.nim(899,"
09:49:06FromDiscord<Yardanico> also why does it use GC_disable
09:49:09FromDiscord<Rika> Probably needs to put that under a when
09:49:28*xet7 joined #nim
09:49:36FromDiscord<Stuffe> I tried commented a few lines out just to try, but there are too many
09:49:50FromDiscord<Stuffe> it is built for the default GC with realtime I guess
09:49:58FromDiscord<Yardanico> not really
09:50:03FromDiscord<Rika> Comment them all with sed
09:50:05FromDiscord<Yardanico> i don't see it using any "realtime" features of refc :)
09:50:20FromDiscord<Yardanico> ah nvm, actually yes, it does use GC_step
09:50:25FromDiscord<Stuffe> yeah
09:50:30FromDiscord<Stuffe> In reply to @Rika "Comment them all with": sed?
09:50:31FromDiscord<Yardanico> but yeah, you can try just removing GC_disable and GC_step and see if it works
09:50:39FromDiscord<Yardanico> with orc
09:50:56FromDiscord<Stuffe> https://media.discordapp.net/attachments/371759389889003532/903219272447316018/Screen_Shot_2021-10-28_at_12.50.51.png
09:51:07FromDiscord<Stuffe> https://media.discordapp.net/attachments/371759389889003532/903219320073650186/Screen_Shot_2021-10-28_at_12.51.03.png
09:51:16FromDiscord<Stuffe> these places also throw errors using orc
09:51:33FromDiscord<Rika> That looks like funky code that shouldn’t be there ngl
09:51:38FromDiscord<Yardanico> oh well, seems like those leaks you are experiencing might as well come from godot nim itself
09:52:15FromDiscord<Yardanico> it does seem to use a lot of the gc options extensively :)
09:52:39FromDiscord<Stuffe> any suggestions?
09:53:49FromDiscord<Stuffe> I will try to respawn the thread for each task, just in case this somehow causes those objects to get collected
10:05:57FromDiscord<r2> sent a long message, see http://ix.io/3D9n
10:06:48FromDiscord<Rika> Async functions are iterator s
10:06:52FromDiscord<Rika> (edit) "iterator s" => "iterators"
10:11:23FromDiscord<r2> ah :D
10:35:52FromDiscord<Stuffe> trying to use threads that compute a single result and die, I keep getting this kind of error: `'threading_get_latest' is not GC-safe as it accesses 'data_result' which is a global using GC'ed memory`
10:37:07FromDiscord<Stuffe> I am guessing this means that I can't use dynamically sized global objects in threads in general?
10:42:14FromDiscord<Rika> You can’t use global objects period
10:42:16FromDiscord<Rika> Afaik
10:42:25FromDiscord<Rika> Unless you go tell the compiler shh it’s fine
10:42:32FromDiscord<Rika> With a cast gcsafe
10:42:36FromDiscord<Stuffe> how am I supposed to get data back then?
10:42:38FromDiscord<Rika> I don’t remember the specific syntax
10:43:00FromDiscord<Yardanico> In reply to @Stuffe "how am I supposed": with refc you can't use global variables that have GC'd types
10:43:08FromDiscord<Yardanico> because each thread has its own heap
10:43:16FromDiscord<Stuffe> ok I see
10:43:28FromDiscord<Yardanico> so you either pass by channels, messages, or something like that, or allocate memory by yourself with raw pointers
10:43:56FromDiscord<Stuffe> I was passing by channels
10:43:59FromDiscord<Yardanico> but if you're planning on accessing the same global variable from separate threads at the same time you should also use locks of course
10:44:35FromDiscord<Stuffe> just now I was trying to use the thread_pool thing
10:44:48FromDiscord<Stuffe> but I need to keep a reference to the resulting FlowVar
10:45:32FromDiscord<Stuffe> Idk, if you guys know the specifics of this, but basically a reference to the running thread, so I can ask it if it is done and has the result for me
10:46:41FromDiscord<Stuffe> I guess I could try using createThread like my first attempt, then pass the result back through Channel and then let it die and respawn it
10:46:43FromDiscord<Rika> Ideally you would just do message passing “I need this, parameters are this, my address is this, post back”
10:47:34FromDiscord<Stuffe> Ok, I never tried that before, could you please elaborate a little bit on how I get started
10:47:59FromDiscord<Rika> Well I was just saying that conceptually
10:48:38FromDiscord<Stuffe> I guess you are saying I should pass a pointer to the memory where I want the result to be stored?
10:50:04FromDiscord<Rika> No, address as in channel
10:50:23FromDiscord<Rika> “This is the channel you use to contact me back” I guess, but then the issue is how to pass such channel
10:51:06FromDiscord<Stuffe> Originally I used one channel for sending to the thread and one channel for receiving the results back
10:51:22FromDiscord<Stuffe> but yeah, it didn't garbage collect in the thread
11:48:44*rockcavera joined #nim
11:48:44*rockcavera quit (Changing host)
11:48:44*rockcavera joined #nim
12:06:02*supakeen quit (Quit: WeeChat 3.3)
12:06:32*supakeen joined #nim
12:16:35PMunch@r2, if you want to understand what's going on with Async check out this: https://peterme.net/asynchronous-programming-in-nim.html
12:16:43PMunchIn particular appendix A
12:30:27*tk quit (Quit: Well, this is unexpected.)
12:32:10*tk joined #nim
12:41:08*arkurious joined #nim
12:51:22FromDiscord<Imperatorn> Hey again guys
12:52:13FromDiscord<Imperatorn> (remember I'm a Nim noob) Have a question about async/await or coroutines or <<insert_name_that_nim_uses_here>>
12:52:47FromDiscord<Imperatorn> Coming from languages like Erlang, I'm used to having peace of mind when it comes to process isolation
12:53:05*neurocyte0132889 joined #nim
12:53:06*neurocyte0132889 quit (Changing host)
12:53:06*neurocyte0132889 joined #nim
12:53:15FromDiscord<Imperatorn> Someone told me about Go that, if a coroutine crashes, the entire program crashes, which sounded kinda insane to me.
12:53:51FromDiscord<Imperatorn> That made me wonder how Nim does it. Does it rely on normal threads, a fiber approach etc
12:54:47FromDiscord<Imperatorn> Or rather the question might be:↵If I want to isolate some unit of execution in Nim (so that a crash in A doesn't spread to B), how would I do it.↵↵Thanks
12:55:08PMunchTotal separation? Run it as a separate program
12:55:17FromDiscord<enthus1ast> Yes if you use async and your async procedure crash (and the exception is not catched) your whole application will crash as well
12:55:18PMunchBut you could also wrap things in a try statement
12:56:01FromDiscord<enthus1ast> Hu didn't know that erlang does this I maybe should have a look at erlang 😁
12:56:49FromDiscord<enthus1ast> I think the same is for threads but I'm not 100% sure
12:56:52FromDiscord<Imperatorn> Erlang is extreme in this sense
12:57:02PMunchI mean that is what it is designed for
12:57:05PMunchSo it makes sense
12:57:07FromDiscord<Imperatorn> Yeah
12:57:18PMunchThreads are the same in Nim, crash one thread and you crash them all
12:57:52FromDiscord<Imperatorn> Yes, I just thought maybe there are some green threads/fiber library which handled things for you in some way
12:59:42FromDiscord<Imperatorn> Anyway, thanks for answering. I think I'll still use the "let it crash" mindset, but wrap it in try-catch or something similar
13:00:32FromDiscord<Rika> not really the same idea i would say
13:00:35FromDiscord<Rika> when you catch stuff
13:01:03FromDiscord<Rika> if you really want to do it like erlang you'd prolly use different processes or design the system in nim yourself (though that might even need a language fork)
13:02:16PMunchI wonder how Erlang does that actually
13:02:23PMunchI mean it has to be separate processes right?
13:05:36FromDiscord<Imperatorn> Yes, separate stacks and heaps, everything is isolated
13:05:55FromDiscord<Imperatorn> Message passing between "processes"
13:06:14FromDiscord<Imperatorn> A process in Erlang is nothing like a OS process or thread
13:06:58FromDiscord<Rika> vm process afaik
13:07:00FromDiscord<Imperatorn> It's a lightweight thing, about 300 bytes or so
13:07:01PMunchNothing like it? It's gotta be somewhat like it if it doesn't cause a crash
13:07:03PMunchOh wait
13:07:05FromDiscord<Imperatorn> Yes
13:07:09PMunchDuh, Erlang runs in a VM
13:07:13FromDiscord<Rika> ya forgot? 😛
13:07:27proI always wondered how earlang bypasses limit of 65k TCP ports
13:07:32PMunchYeah I was super confused there for a second
13:08:24FromDiscord<Imperatorn> In reply to @pro "I always wondered how": Does it? I don't recall
13:08:52FromDiscord<Rika> "bypass" because its on the vm it doesnt need tcp ports i assume
13:09:01FromDiscord<Imperatorn> Oh you mean in the Erlang world
13:09:38FromDiscord<Imperatorn> Yeah it can be raised to 268 435 456
13:09:56probut how/why
13:10:07FromDiscord<Imperatorn> Why not 😎
13:10:40FromDiscord<Rika> why? prolly needed in erlang because of how it works
13:10:49FromDiscord<Rika> how? again, implemented in vm
13:10:59FromDiscord<Rika> a vm makes things easier
13:11:12progot it
13:24:43PMunchWhat does this mean? Warning: suspicious code: enum to enum conversion [EnumConv]
13:25:24FromDiscord<Rika> you uh
13:25:29FromDiscord<Rika> converted from an enum to another enum
13:25:43FromDiscord<Rika> apparently that isnt desirable, you have to convert from enum to ordinal to enum
13:25:48FromDiscord<enthus1ast> 65k TCP ports?
13:25:59FromDiscord<Rika> what about the tcp ports
13:26:07FromDiscord<enthus1ast> s socket constist if yourIP\:port + remoteIP\:port
13:26:15FromDiscord<Rika> yes
13:26:42FromDiscord<enthus1ast> only relevant afaik when you run behind a proxy or so
13:26:56FromDiscord<enthus1ast> but even then you can always assign another ip or use ipv6
13:27:21FromDiscord<Rika> assign another ip?
13:27:42FromDiscord<enthus1ast> that you have more allowed sockets
13:28:08FromDiscord<enthus1ast> or addressable sockets
13:30:04PMunch@Rika, I don't though. As far as I can tell
13:30:26PMunchI do `if someobject.field in {enumVal1, enumVal2}`
13:31:32FromDiscord<Rika> is that the line where the warning pops up? then it might be a system thing
13:40:33FromDiscord<Gumber> @Imperatorn I work in Elixir for my day job
13:42:34FromDiscord<Gumber> also writing the backend for my game in Elixir
13:47:24FromDiscord<Gumber> Nim doesn't have anything like BEAM's supervisor hierarchy / process isolation - it does have channels to facilitate message passing and previously there were some libraries that focused on the actor model but I think they're very old and outdated at this point
13:47:58FromDiscord<Gumber> as far as green threads go - nim has closure iterators and now CPS is in the works
13:48:08*pro quit (Quit: WeeChat 3.3)
13:48:26FromDiscord<Gumber> I've also implemented fibers /coroutines using boost's context library (deboostified)
13:59:57FromDiscord<Imperatorn> Interesting 👌
14:09:21*casionaut joined #nim
14:14:19*lively_sparkle joined #nim
14:30:37*pch is now known as kinkinkijkin
14:42:14FromDiscord<no name fits> I keep forgetting that ^1 is last element and not ^0. Is there a good way to memorize it other than repetition?
14:42:45FromDiscord<Rika> nth to the last
14:43:28FromDiscord<Rika> wrt deepcopy, why is it off by default on [ao]rc?
14:44:29nrds<Prestige99> @no name fits I think of it as -1
14:45:18nrds<Prestige99> but with ^ it moves "left" from the 0th element, bringing it to the rightmost element (like it loops around)
14:47:33FromDiscord<Rika> afaik its why it's 1 indexed, to copy python afaik
14:51:35FromDiscord<no name fits> In reply to @nrds "<Prestige> but with ^": That makes sense to me
14:55:54FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3DaS
14:56:08FromDiscord<haxscramper> for `var stack: seq[T]` and for `var generalList: seq[T]`
14:58:16FromDiscord<Rika> ~~tail~~
14:58:51FromDiscord<haxscramper> I have this one as well
14:59:16FromDiscord<haxscramper> Though ideal signature would be a `func tail[T](s: seq[T]): openarray[T]`, but without view types it is super expensive
14:59:41FromDiscord<haxscramper> and I think I ran into some bug when I tried to use it this, way so I just dropped it altogether
15:13:33*lain quit (Ping timeout: 265 seconds)
15:14:27*lain joined #nim
15:18:18FromDiscord<Rika> beef are ya here? if ya aint then ping me, do you have any benchmark numbers for ya nimscripter?
16:06:40FromDiscord<MrMadPie> hello
16:07:18FromDiscord<MrMadPie> i keep seeing things like `{.gcsafe}` in function definitions and i don't understand what those are called and what they do
16:07:24FromDiscord<MrMadPie> can anyone clear that up for me?
16:08:53nrds<Prestige99> They are called pragmas, I believe they are documented in the manual
16:09:35nrds<Prestige99> https://nim-lang.org/docs/manual.html#effect-system-gc-safety-effect
16:13:45*kayabaNerve quit (Ping timeout: 260 seconds)
16:15:36*kayabaNerve joined #nim
16:21:46NimEventerNew thread by Ggibson: Basic nimterop usage for simple c++ struct?, see https://forum.nim-lang.org/t/8555
16:23:12*vicecea quit (Remote host closed the connection)
16:23:44*vicecea joined #nim
16:33:53FromDiscord<MrMadPie> thank you
16:38:19*lively_sparkle quit (Ping timeout: 260 seconds)
16:51:10*andylearningnimt joined #nim
17:00:48andylearningnimtHello! I have some confusion about declaring objects: can I specify a field's initial value? can I specify that a certain proc be run whenever the object is instantiated?
17:02:03FromDiscord<Rika> no
17:02:03FromDiscord<Rika> no
17:02:26FromDiscord<Rika> common convention is to make an initialiser proc for instantiation
17:02:34FromDiscord<Rika> instead of using object construction synta
17:02:35FromDiscord<Rika> (edit) "synta" => "syntax"
17:02:47FromDiscord<Rika> initial values go in such proc as well
17:03:12FromDiscord<Rika> RFCs are in place for both initial values and more standardised initialisation procedures
17:03:33*lively_sparkle joined #nim
17:04:06*kayabaNerve quit (Remote host closed the connection)
17:04:16andylearningnimtThanks
17:04:25*kayabaNerve joined #nim
17:07:41andylearningnimtWhat's the simplest way to determine what a type's default value is? e.g. looking at https://nim-lang.org/docs/manual.html#types-boolean-type I can't tell if my objects' boolean fields will be true or false
17:09:57FromDiscord<Rika> default(T)
17:10:06FromDiscord<Rika> all values are zero initialised
17:10:18FromDiscord<Rika> eg booleans will always be false
17:10:22FromDiscord<Rika> integers 0
17:10:30FromDiscord<Rika> strings empty
17:10:51FromDiscord<Rika> (note that strings and seqs are somewhat special in that they are implemented as pointers but do not behave like such)
17:11:37andylearningnimtThank you again
17:17:35*casionaut quit (Quit: o7)
17:21:06FromDiscord<Alea> I used nim for a code signal test↵And I got boofed because of an index error that wouldn't show a line number 😒
17:21:21andylearningnimtOK now I have an object field that is seq[string], and in a proc try to add a string to it, but apparently that field is immutable? field is lst (line 18) add at line 30: http://ix.io/3DbX
17:21:27FromDiscord<Alea> I wonder if that was nim or codesignal's fault
17:22:19FromDiscord<Rika> andy, objects need to be marked as mutable
17:22:25FromDiscord<Rika> `proc init(self: var Allergies) =`
17:22:48FromDiscord<Rika> same with `is_allergic_to`
17:22:51andylearningnimtoh as a parameter? cool cool cool thanks
17:26:08andylearningnimtoof but the included tests from exercism use an immutable instance, so I guess I have to rethink how I'm doing everything
17:29:38FromDiscord<Rika> create a copy and return the copy
17:32:51andylearningnimtOK, thank you, I'll think this way. A copy of the object? None of my procs return an object right now, and if I copied it during init, I'd still have to add a whole caching mechanism anyway to prevent calculating the lst field every time is_allergic_to is called, I think.
17:34:36*kayabaNerve quit (Remote host closed the connection)
17:34:51andylearningnimtSo I think I'll start a cache as a map of score to seq
17:34:55*kayabaNerve joined #nim
17:57:24*PMunch_ joined #nim
18:03:04*PMunch quit (Killed (NickServ (GHOST command used by [email protected])))
18:03:10*PMunch_ is now known as PMunch
18:03:29*PMunch_ joined #nim
18:08:18andylearningnimtRika: The tests from exercism (so I shouldn't change them) have, e.g.:: let allergies = Allergies(score: 1); check allergies.lst == @["eggs"] :: How or where could I be returning a copy so I can modify the field?
18:09:19FromDiscord<Imperatorn> In reply to @Gumber "<@!750836245919170771> I work in": Btw, have you tried the BeamAsm?
18:10:58FromDiscord<Gumber> In reply to @Imperatorn "Btw, have you tried": I haven't! Thanks for cluing me into this - I figured something like this had to exist but I hadn't really poked around much yet
18:12:53FromDiscord<Gumber> I might already be using it and just not know - but I doubt it
18:14:59andylearningnimtI just don't understand how I can do the calculation when the instantiations and tests are outside my control, and the field is checked immediately after that initialization.
18:18:44FromDiscord<Rika> Is the object itself out of your control
18:18:52FromDiscord<Rika> Can you link me the exercise I’ll read it
18:19:11andylearningnimtRika: no I can define it, just the tests should be unchanged. 1 sec
18:19:48FromDiscord<Rika> Recall that in Nim, that syntax doesn’t only mean a field
18:19:55andylearningnimtinstructions: http://ix.io/3Dcj -- tests: http://ix.io/3Dci
18:20:31andylearningnimtRika: oh, I thought maybe I could make it a fake field and actually a proc, but then it complained about the field being missing so I must have done that wrong if it's possible
18:20:40andylearningnimt(lst, that is)
18:21:55andylearningnimtmy latest attempt: http://ix.io/3Dcl
18:22:23FromDiscord<Rika> “Complained that the field is missing” how
18:22:27FromDiscord<Rika> In what way
18:22:48FromDiscord<Rika> You didn’t export the proc
18:22:49andylearningnimt"test_allergies.nim(175, 20) Error: undeclared field: 'lst' for type allergies.Allergies"
18:22:52FromDiscord<Rika> That’s why it complained
18:22:54andylearningnimtohh
18:22:59andylearningnimtugh, thank you again
18:23:48andylearningnimtcompiling nicely, now to go find out all the other mistakes I've made
18:25:12andylearningnimtah yes I wanted to see if Tables filled in default values for missing keys, which they don't
18:25:55FromDiscord<Elegantbeef> Ah that's a nice challenge
18:27:47FromDiscord<Elegantbeef> More solutions than i'd think to use sets to solve it
18:35:31FromDiscord<Imperatorn> In reply to @Gumber "I might already be": Depends. I think atm you need to run 64-bit x86 for it to be enabled
18:41:11*lively_sparkle quit (Ping timeout: 264 seconds)
18:41:18FromDiscord<Gumber> In reply to @Imperatorn "Depends. I think atm": found out we're quite a few versions behind so I dont't hink we're using it
18:44:04andylearningnimtIs there a common, obvious way to prepend to a seq?
18:44:34FromDiscord<Elegantbeef> `insert`?
18:44:56PMunchOr concat if you want to add more than one value
18:46:05andylearningnimtthanks, I thought maybe I could add an element without first wrapping it in a second seq, I'll use insert
18:47:22andylearningnimtoh unless I can do that if I go find out what sink means. I'll check it out
18:53:37andylearningnimtThanks to all the help, I'm *almost* there, just one case to fix. current version: http://ix.io/3Dcs
18:54:04*lively_sparkle joined #nim
19:14:14*sagax quit (Remote host closed the connection)
19:21:52PMunchMan editing these videos on Badger takes forever..
19:21:58PMunchThere has to be a better way
19:29:17nrds<Prestige99> What are you doing?
19:31:48FromDiscord<Elegantbeef> Methinks he's editing videos of him using badger from his keyboard streams
19:32:07PMunchAlmost
19:32:20PMunchI'm editing down the original streams into a more watchable format
19:32:43PMunchLike I did for the first three videos
19:32:59PMunchI have 4-7 that I've recorded but not edited -_-
19:39:41FromDiscord<tandy> https://github.com/jjv360/nim-classes
19:39:50FromDiscord<tandy> has anyone used this?
19:40:34FromDiscord<Elegantbeef> I know impbox used oolib
19:41:10andylearningnimtwoohoo, just posting my finally-passing-the-tests but amateur solution to the exercism problem I've been working on: http://ix.io/3DcI
19:43:07FromDiscord<tandy> oh this looks good
19:45:01FromDiscord<Elegantbeef> Nice andy, very elaborate though 😀
19:45:12*lively_s1 joined #nim
19:46:11FromDiscord<tandy> whats the fastest / easiest gui library? i need to make a tictactoe game quick lol
19:47:01FromDiscord<Elegantbeef> Nigui, Nimx, Gintro, Nico one of these has to be usable for you
19:47:11*lively_sparkle quit (Ping timeout: 245 seconds)
19:47:20FromDiscord<tandy> ive used gintro
19:47:21PMunchNico would probably be a good match
19:47:32PMunchOr maybe even Pixie
19:47:34FromDiscord<Elegantbeef> Nico is a game framework so probably the easiest
19:47:34andylearningnimtElegantbeef: I figure there's a nim pattern/feature to do a more do-while style loop, but otherwise I'm not sure where/how to simplify. Not that I need to, but if something seems obviously too-much-work-for-the-job please do give me a hint
19:47:35FromDiscord<tandy> i was curious if there was anything that would be super fast / no boiler plate needed
19:47:37PMunchDoes it have inputs?
19:47:47FromDiscord<tandy> yep, mouse controled
19:48:16FromDiscord<Elegantbeef> Andy the challenge is written such to have a slightly lower level solution
19:48:21PMunchHaha, I meant Pixie :P
19:48:38FromDiscord<tandy> ohh
19:48:40FromDiscord<tandy> hahaha
19:48:44FromDiscord<Elegantbeef> Pixie is just a drawing library
19:48:54FromDiscord<Elegantbeef> So you use sdl2/gflw for inputs
19:48:55FromDiscord<tandy> il peep nico, would be cool to play with that
19:49:21PMunchAh right, so you can have it draw to a SDL2 surface or something, and then use that for input handling
19:49:23PMunchCool
19:49:34FromDiscord<Elegantbeef> Indeed
19:49:45FromDiscord<Elegantbeef> Treeform even has boxy if you wanted to do it efficiently
19:50:05andylearningnimtI know I could alternatively use a Table to make the known point values constant as well, but what kind of "lower level" do you mean?
19:50:14FromDiscord<Elegantbeef> Andy this is the intended solution https://exercism.org/tracks/nim/exercises/allergies/solutions/beef331
19:50:54andylearningnimtholy moly ok thanks
19:51:46FromDiscord<Elegantbeef> It's just a bitwise operation which was eluded to with the `1, 2, 4, 8, 16, 32, 64, 128`
19:53:55FromDiscord<Elegantbeef> If you have any questions feel free to ask
19:55:30*casionaut joined #nim
20:12:12PMunchUgh, this video is a mess..
20:12:39PMunchI have a 1 hour segment where I try to make some progmem stuff work and end up patching the compiler..
20:30:18*andylearningnimt quit (Quit: Leaving)
21:08:26*lively_s1 quit (Ping timeout: 245 seconds)
21:22:33*casionaut left #nim (o7)
21:22:47*PMunch quit (Quit: leaving)
21:30:14*lively_s1 joined #nim
21:34:39*lively_s1 quit (Ping timeout: 260 seconds)
21:43:11*Vladar quit (Quit: Leaving)
22:00:33*lively_s1 joined #nim
22:26:12FromDiscord<RattleyCooper> Hmmm, can't seem to compile anything with nim v1.6.0..
22:26:25FromDiscord<RattleyCooper> I guess it can't find `gcc.exe`
22:28:26FromDiscord<demotomohiro> does `gcc.exe --version` work?
22:28:52FromDiscord<RattleyCooper> no
22:29:06FromDiscord<RattleyCooper> But nim v1.4.8 worked. I'm just trying to `nim c script.nim`
22:30:33FromDiscord<RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3Ddw
22:33:40nixfreak_nim[m]whats a good library to parse columns and rows and to manipulate them ?
22:35:39FromDiscord<demotomohiro> How about to set path env var temporary like `set path=c:\full\path\to\gcc;%path%` and see if nim call gcc.
22:46:24FromDiscord<RattleyCooper> In reply to @demotomohiro "How about to set": hmmm, seems that `dist/mingw64/bin/gcc.exe` is in my nim v1.4.8 folder but not for v1.6.0. Guessing I downloaded it manually when I installed v1.4.8 and forgot about that step or something? But for some reason v1.6.0 still can't find it..
22:47:42FromDiscord<RattleyCooper> (edit) "it.." => "it when I copy it to the `dist` folder for v1.6.0"
22:50:29FromDiscord<demotomohiro> Probably you forget to run `finish.exe`.↵https://nim-lang.org/install_windows.html
22:55:12nixfreak_nim[m]I want to take an exported file which has columns and rows but if you try to import into a spreadsheet the columns are messed up, I would like to convert the exported file to a suitable csv file. Some rows are not together so it makes it really hard to print out say with awk
22:56:06nixfreak_nim[m]Can I use parsecsv to manipulate the data to turn into a useable csv file?
22:59:48FromDiscord<Elegantbeef> What's on those rows not together? empty lines?
22:59:48FromDiscord<Elegantbeef> Do you really need to be CSV aware is basically my question
23:04:26nixfreak_nim[m]Looks like this
23:04:34FromDiscord<Elegantbeef> Is what i'd suggest https://play.nim-lang.org/#ix=3DdD
23:04:42FromDiscord<Elegantbeef> But given i dont know the data inbetween 😀
23:05:12FromDiscord<Elegantbeef> did you forget to post it?
23:06:26FromDiscord<RattleyCooper> In reply to @demotomohiro "Probably you forget to": You would be correct 😊
23:07:01nixfreak_nim[m]2021-05-06 13:50:15 fname lname store1 Exit door... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/49b5c1c94b2eacb487547e80e3b4d582a9a937f7)
23:07:25nixfreak_nim[m]like this , but the rows will change depending on the access
23:07:39FromDiscord<Elegantbeef> Ah so it's a horizontal issue
23:07:49nixfreak_nim[m]yes
23:08:19FromDiscord<Elegantbeef> I guess the solution is to find the largest word in each column and pad the result to that size
23:09:12FromDiscord<Elegantbeef> So sadly a 2 step process
23:11:03nixfreak_nim[m]so the read the file line by line and search for largest word and pad the result
23:11:16FromDiscord<Elegantbeef> I'll give you what i'd do might not be best though
23:11:25nixfreak_nim[m]ok
23:28:15FromDiscord<Elegantbeef> Well the csv parser doesnt seem to play nice
23:29:12FromDiscord<Elegantbeef> If you want some shitty reference code https://play.nim-lang.org/#ix=3DdH
23:33:50FromDiscord<Elegantbeef> Ah i was dumb quick change made it work https://play.nim-lang.org/#ix=3DdJ
23:34:10*lively_s1 quit (Ping timeout: 260 seconds)
23:45:14nixfreak_nim[m]Ok thanks, so in this program you would still have to input what you want to see or was that just an example
23:49:08FromDiscord<Elegantbeef> your input can be a filestream
23:49:34FromDiscord<Elegantbeef> So you can do `yourInput = openFileStream("someFile.csv")` and it should work, though the `csv` open will not respect you seperator
23:53:51nixfreak_nim[m]ok interesting
23:54:17FromDiscord<Elegantbeef> You can also make the output a stream to
23:54:21FromDiscord<Elegantbeef> Even your stdout 😀
23:55:48FromDiscord<Elegantbeef> just do `newFileStream(stdout)` and that example will write right to your stdout
23:56:09nixfreak_nim[m]ok , thank you very much
23:56:59nixfreak_nim[m]Did something change with opening a file with nim ? I thought you could always just open using openFile("file.txt")
23:58:21FromDiscord<Elegantbeef> you can
23:58:25FromDiscord<Elegantbeef> fileStreams are not files