<< 14-06-2023 >>

00:00:03FromDiscord<Invisible> wtf
00:00:19FromDiscord<graveflo> what?
00:01:50*derpydoo joined #nim
00:04:11FromDiscord<Invisible> not all errors are catchable?
00:05:30FromDiscord<graveflo> again errors are not exceptions. When you are programming in a lower level language like nim you have to consider how things are implemented more so then a high level language. Any error handling / exceptions system needs to be implemented somewhere. They can be subverted or ignored its just how it is.
00:06:08FromDiscord<graveflo> You dont have to think too much about it if you dont want to but something like this might have more complexity then you would think
00:08:47FromDiscord<Elegantbeef> Think about nil dereferencing
00:09:16FromDiscord<graveflo> are you trying to segfault my brain?
00:09:29FromDiscord<Elegantbeef> That's a hard quit, it's just wrong to allow recovery from that 😄
00:17:36FromDiscord<Invisible> Any way I can prevent 2 of the same application from running at the same time?
00:18:28FromDiscord<graveflo> you mean recognize if the app you are making is already running at start up?
00:18:37FromDiscord<Invisible> In reply to @graveflo "you mean recognize if": No
00:18:42FromDiscord<Invisible> I mean like if the user spam opens it
00:18:45FromDiscord<Invisible> it wont open 60 windows
00:19:09FromDiscord<graveflo> yea so the program must recognize that it is already open and exit itself in that case, right?
00:19:15FromDiscord<Invisible> yup
00:19:23FromDiscord<Invisible> thought u meant pc startup
00:19:36FromDiscord<graveflo> okay there are several ways to do this but there are trade offs
00:19:42FromDiscord<Invisible> such as?
00:20:31FromDiscord<graveflo> the dumbest way to do it is to use a signal file. its stupid easy but fragile. If you just have the program check if a file exists and if it does then exit but if it doesnt then it starts and creates the file you will kinda have this behavior
00:20:47FromDiscord<graveflo> Im only mentioning this bc it seems you are trying to do things the easiest way possible
00:21:00FromDiscord<Invisible> but if it exits, it won't delete the file
00:21:07FromDiscord<Invisible> such as if the pc abruptly loses power or something
00:21:14FromDiscord<graveflo> the real way to do it is to use IPC or you can query the OS for information about the processes currently running
00:21:16FromDiscord<Elegantbeef> Right that's the issue with lock files
00:21:24FromDiscord<Elegantbeef> for reference the Unity engine uses a lock file
00:21:46FromDiscord<Elegantbeef> you can just search by process name for if your process exists
00:21:48FromDiscord<Invisible> I have na idea
00:22:00FromDiscord<Invisible> What if I try to edit the file and add 1 byte to it, and if it doesn't let me then it's running
00:22:03FromDiscord<Invisible> but if it does then it's not
00:22:07FromDiscord<Invisible> nvm
00:22:11FromDiscord<Invisible> it cant edit itself
00:22:12FromDiscord<Invisible> im dumb
00:22:14FromDiscord<graveflo> no thats the lock file method
00:22:25FromDiscord<graveflo> you have to keep it "open" at all times
00:22:37FromDiscord<graveflo> but that will work and the OS usually will free the lock on its own
00:22:43FromDiscord<Elegantbeef> It's just a file with a read/write lock
00:22:46FromDiscord<graveflo> in some bad events that is
00:23:02FromDiscord<Invisible> As long as it works and I can edit it easily and not shit myself trying to understand it, I don't care
00:23:12FromDiscord<Invisible> any method that isn't overly complicated will work for me
00:23:24FromDiscord<graveflo> looks like you will use a lock file then
00:23:53FromDiscord<Invisible> sent a code paste, see https://play.nim-lang.org/#ix=4yb3
00:24:22FromDiscord<graveflo> yea p much
00:24:24FromDiscord<Invisible> But if the program is constantly running, and then crashes / the pc shuts off, it will still think it's running when it restarts
00:24:29*Jjp137 quit (Ping timeout: 240 seconds)
00:24:52FromDiscord<Elegantbeef> Right
00:24:54FromDiscord<graveflo> well thats why you should try and open it for writing and see how it reacts instead... idk if nim has a file access query
00:25:06FromDiscord<Elegantbeef> The unity engine has(had?) this problem
00:25:13FromDiscord<Elegantbeef> So many times I've had to manually delete a lock file
00:25:34FromDiscord<graveflo> right but you can get around this if you use the OS locking mech.. again there are choices here with trade offs
00:25:44FromDiscord<graveflo> using the OS write lock can get around this issue
00:25:50FromDiscord<Invisible> In reply to @graveflo "well thats why you": can you provide me with a basic exmaple to get me started?
00:25:54FromDiscord<Elegantbeef> \nix generally doesnt use file locks iirc, might be crazy
00:26:02FromDiscord<Invisible> Ill figure the rest out on my own, I just want something to base myself off of
00:26:15FromDiscord<graveflo> Im sure you can but this is a windows user i think
00:28:18FromDiscord<huantian> In reply to @Elegantbeef "So many times I've": one way to counter this is to write your pid to the file
00:28:29FromDiscord<huantian> and other instance not only check if the file exists, but if a process with that pid exists I think
00:28:33*Onionhammer quit (Server closed connection)
00:28:36FromDiscord<Invisible> No easy way to get the PID from nimlang
00:28:39FromDiscord<Elegantbeef> Yea that makes sense
00:28:43FromDiscord<Invisible> or check it
00:28:49*Onionhammer joined #nim
00:29:00FromDiscord<Elegantbeef> https://nim-lang.org/docs/os.html#getCurrentProcessId
00:29:18FromDiscord<Elegantbeef> Damn I hate how hard that is
00:29:22FromDiscord<Elegantbeef> I'm going to write a PR to make it easier
00:29:55FromDiscord<graveflo> In reply to @huantian "one way to counter": hey thats pretty smart 😄
00:30:42FromDiscord<huantian> the internet does occasionally have good ideas 😛
00:30:45FromDiscord<Elegantbeef> There is a chance that you have a program with that PID open
00:30:55FromDiscord<Elegantbeef> It's not like PIDs are GUIDs
00:31:02FromDiscord<Invisible> In reply to @Elegantbeef "Damn I hate how": How bout checking if the PID is active?
00:31:07FromDiscord<huantian> yeah I'm not too sure what the chance of that is for a userland process on unix
00:31:18FromDiscord<Elegantbeef> Using class names or program names makes more sense imo
00:31:24FromDiscord<graveflo> In reply to @Elegantbeef "There is a chance": true ig you would have to follow that up with another check but its still p cool.. You ruined it a little
00:31:58FromDiscord<Invisible> In reply to @Elegantbeef "Using class names or": they could js rename it between executions, which would defeat this entire thing
00:32:00FromDiscord<Elegantbeef> I just iterate `/proc` 😄
00:32:10FromDiscord<Elegantbeef> rename it between executions?
00:32:14FromDiscord<graveflo> In reply to @Invisible "they could js rename": who is "they"
00:32:17FromDiscord<Elegantbeef> Are you writing malware or a proper program
00:32:26FromDiscord<Invisible> In reply to @Elegantbeef "Are you writing malware": A proper program, what malware has a GUI
00:32:33FromDiscord<Elegantbeef> Ransomware
00:32:34FromDiscord<graveflo> youd be suprised
00:32:38FromDiscord<graveflo> yea exactly XD
00:32:42FromDiscord<Invisible> In reply to @Elegantbeef "Ransomware": 🤷‍♂️ ig
00:32:48FromDiscord<Invisible> don't most ransomwaes use text notes?
00:32:49FromDiscord<graveflo> but anyway this is a proper example of user error
00:32:55FromDiscord<graveflo> if they mess with the lock file thats on them
00:33:03FromDiscord<Invisible> In reply to @graveflo "if they mess with": ig
00:33:09FromDiscord<Invisible> 🤷‍♂️
00:33:17FromDiscord<Invisible> ill use cmd to query all of the pids
00:33:30FromDiscord<Elegantbeef> Or use winlean or winim
00:33:30FromDiscord<Invisible> and check if the one in the file matches one in there
00:33:37FromDiscord<Elegantbeef> There is no reason to go out to a shell
00:33:48FromDiscord<Invisible> Dont know how to use eiteher
00:35:42FromDiscord<graveflo> I already posted code that queries all PIDs and uses them to get process handles
00:37:10*oldpcuser_ joined #nim
00:39:59*oldpcuser quit (Ping timeout: 240 seconds)
00:40:06*oldpcuser_ quit (Max SendQ exceeded)
00:40:34*oldpcuser_ joined #nim
00:42:38*oldpcuser_ quit (Read error: Connection reset by peer)
00:42:41FromDiscord<Elegantbeef> The best way to learn how to use any system API is to look how they're used in C/C++
00:42:51*oldpcuser joined #nim
00:42:56*oldpcuser quit (Remote host closed the connection)
00:44:14*oldpcuser joined #nim
00:45:13FromDiscord<graveflo> does not really not have a divmod?
00:46:07FromDiscord<JeysonFlores> can I specify the javascript backend in nimble?
00:49:34FromDiscord<Elegantbeef> make a `config.nims` with `--backend:js`
00:50:22FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4yb6
00:51:01FromDiscord<juan_carlos> `backend = "js"` https://nim-lang.org/docs/nimscript.html#backend
00:51:13*jkl quit (Server closed connection)
00:51:21FromDiscord<JeysonFlores> thanks
00:51:34*jkl joined #nim
01:05:56*jmdaemon quit (Ping timeout: 240 seconds)
01:12:19*m5zs7k quit (Ping timeout: 255 seconds)
01:12:47*blackbeard420 quit (Ping timeout: 255 seconds)
01:12:47*cedb quit (Ping timeout: 255 seconds)
01:12:49*mahlon quit (Ping timeout: 255 seconds)
01:13:03*krydos5 joined #nim
01:13:13*systemdsucks quit (Ping timeout: 255 seconds)
01:14:41*mronetwo quit (Ping timeout: 260 seconds)
01:15:50*casaca quit (Ping timeout: 260 seconds)
01:15:51*henrytill quit (Ping timeout: 260 seconds)
01:15:55*hexeme quit (Ping timeout: 260 seconds)
01:16:25*oldpcuser_ joined #nim
01:16:26*noeontheend quit (Ping timeout: 260 seconds)
01:16:26*oddish quit (Ping timeout: 260 seconds)
01:16:27*anddam quit (Ping timeout: 260 seconds)
01:16:28*oisota quit (Ping timeout: 260 seconds)
01:16:29*mal`` quit (Ping timeout: 260 seconds)
01:17:01*fallback quit (Ping timeout: 260 seconds)
01:18:04*calebtj quit (Ping timeout: 255 seconds)
01:18:04*mahlon_ joined #nim
01:18:04*Lord_Nightmare quit (Ping timeout: 255 seconds)
01:18:05*tiorock joined #nim
01:18:15*tiorock quit (Changing host)
01:18:15*tiorock joined #nim
01:18:48*mal``` joined #nim
01:19:03*fallback_ joined #nim
01:19:52*rockcavera quit (Killed (tungsten.libera.chat (Nickname regained by services)))
01:19:52*tiorock is now known as rockcavera
01:20:15*blackbeard420_ joined #nim
01:20:15*Onionhammer2 joined #nim
01:20:20*tk quit (Ping timeout: 240 seconds)
01:20:20*derpydoo quit (Ping timeout: 240 seconds)
01:20:20*Amun-Ra quit (Ping timeout: 240 seconds)
01:20:21*marcus quit (Ping timeout: 240 seconds)
01:20:21*Onionhammer quit (Ping timeout: 240 seconds)
01:20:22*dza quit (Ping timeout: 240 seconds)
01:20:22*krux02 quit (Ping timeout: 240 seconds)
01:20:22*antranigv quit (Ping timeout: 240 seconds)
01:20:22*xet7 quit (Ping timeout: 240 seconds)
01:20:22*krydos quit (Ping timeout: 240 seconds)
01:20:22*Onionhammer2 is now known as Onionhammer
01:20:27*anddam_ joined #nim
01:20:29*Onionhammer quit (Read error: Connection reset by peer)
01:20:35*blackbeard420 joined #nim
01:20:36*mronetwo_ joined #nim
01:20:38*deadmarshal_ quit (Ping timeout: 240 seconds)
01:20:39*oddish_ joined #nim
01:20:40*krydos5 quit (Ping timeout: 240 seconds)
01:20:41*jkl quit (Ping timeout: 240 seconds)
01:20:41*oldpcuser quit (Ping timeout: 240 seconds)
01:20:43*042AAA61F joined #nim
01:20:44*tiorock joined #nim
01:20:45*anddam_ quit (Changing host)
01:20:45*anddam_ joined #nim
01:21:00*Onionhammer joined #nim
01:21:16*oddish_ quit (Read error: Connection reset by peer)
01:21:19*mronetwo_ quit (Read error: Connection reset by peer)
01:21:22*oddish joined #nim
01:21:24*tiorock quit (Changing host)
01:21:24*tiorock joined #nim
01:21:24*rockcavera is now known as Guest3205
01:21:24*Guest3205 quit (Killed (molybdenum.libera.chat (Nickname regained by services)))
01:21:24*tiorock is now known as rockcavera
01:21:25*Amun-Ra joined #nim
01:21:27*mronetwo joined #nim
01:22:59*042AAA61F quit (Ping timeout: 240 seconds)
01:23:08*blackbeard420_ quit (Ping timeout: 240 seconds)
01:23:27*mahlon_ quit (Ping timeout: 255 seconds)
01:24:20*anddam_ quit (Ping timeout: 240 seconds)
01:25:44*azimut quit (Ping timeout: 240 seconds)
01:25:49*mahlon_ joined #nim
01:30:50*tk joined #nim
01:31:00*xet7 joined #nim
01:31:43*noeontheend joined #nim
01:31:44*Lord_Nightmare joined #nim
01:31:48*casaca joined #nim
01:32:05*henrytill joined #nim
01:32:07*deadmarshal_ joined #nim
01:32:36*hexeme joined #nim
01:32:45*m5zs7k joined #nim
01:32:57*jkl joined #nim
01:33:58*systemdsucks joined #nim
01:34:01*marcus joined #nim
01:35:15*oldpcuser_ is now known as oldpcuser
01:35:54*anddam_ joined #nim
01:36:59*ced1 joined #nim
01:37:46*calebjohn joined #nim
01:39:51*dza joined #nim
01:42:16FromDiscord<!&luke> Is there a way to get vars/functions from nimscript with nimscripter without them being exported
01:47:32FromDiscord<Elegantbeef> Nope
01:48:55FromDiscord<Invisible> How do I get the last item in a list
01:49:03FromDiscord<Invisible> list[-1] doesn't work
01:49:11FromDiscord<Elegantbeef> \`^1
01:49:16FromDiscord<Elegantbeef> `list[^1]`\
01:49:26FromDiscord<Invisible> ty
01:58:42FromDiscord<!&luke> In reply to @Elegantbeef "Nope": Oh
02:00:08*deadmarshal_ quit (Ping timeout: 255 seconds)
02:00:35*m5zs7k_ joined #nim
02:01:12*Lord_Nightmare2 joined #nim
02:01:21*m5zs7k quit (Quit: m5zs7k)
02:01:22*calebjohn quit (Ping timeout: 255 seconds)
02:01:22*ced1 quit (Ping timeout: 255 seconds)
02:01:28FromDiscord<Elegantbeef> If you care to know, the VM only allows you to access global variables which must be exported
02:01:48*ced1 joined #nim
02:01:48*calebjohn joined #nim
02:01:49*Lord_Nightmare quit (Ping timeout: 255 seconds)
02:04:10*Lord_Nightmare2 is now known as Lord_Nightmare
02:04:12FromDiscord<!&luke> In reply to @Elegantbeef "If you care to": Yea it makes sense
02:05:14FromDiscord<!&luke> Do you know how I can call a function only if it exists?
02:06:29FromDiscord<Elegantbeef> Invoke should raise an exception, so handle that i guess
02:08:40FromDiscord<!&luke> Ok
02:09:11FromDiscord<!&luke> Would the same work for variables
02:09:15*m5zs7k_ is now known as m5zs7k
02:10:45FromDiscord<Elegantbeef> Seems so
02:11:17FromDiscord<!&luke> Oh wait for variables I can just use defaults
02:16:48*deadmarshal_ joined #nim
02:25:22*Jjp137 joined #nim
02:57:17FromDiscord<!&luke> Is there something like strformat that works with runtime strings
02:58:15FromDiscord<Elegantbeef> `%` in strutils
02:58:47FromDiscord<!&luke> Ok thanks
03:27:49*jtbx joined #nim
03:32:16*calebjohn quit (Ping timeout: 255 seconds)
03:34:06*calebjohn joined #nim
03:59:29*Jjp137 quit (Ping timeout: 240 seconds)
03:59:53*Jjp137 joined #nim
04:45:22*jtbx quit (Quit: Lost terminal)
04:45:56*ntat joined #nim
04:51:55*rockcavera quit (Remote host closed the connection)
05:54:10FromDiscord<Invisible> Is there a thing in nim that's similar to python's f strings?
05:54:22FromDiscord<Invisible> like var string = "{string1}, hello, {string2"
05:54:28FromDiscord<Invisible> (edit) "{string2"" => "{string2}""
05:56:14FromDiscord<Elegantbeef> `std/strformat`
05:57:30FromDiscord<Invisible> k
06:05:12FromDiscord<dissolved.girl> The syntax you're probably looking for is `&"{string1}, hello, {string2}"`
06:05:27FromDiscord<dissolved.girl> From `std/strformat`
06:09:30FromDiscord<Invisible> In reply to @dissolved.girl "The syntax you're probably": It doesn't work if I have curly brackets in my string tho
06:09:35FromDiscord<Invisible> And I can't escape them
06:09:51FromDiscord<Elegantbeef> `{{`
06:10:04FromDiscord<Invisible> Doesn't work
06:10:16FromDiscord<Invisible> already tried
06:10:19FromDiscord<Elegantbeef> > Parts of the string that are enclosed in the curly braces are interpreted as Nim code. To escape a { or }, double it.
06:10:25FromDiscord<Elegantbeef> It certainly does
06:10:27FromDiscord<Invisible> nvm, worded that wrong
06:10:37FromDiscord<Invisible> It works when I run it but it fucks up my syntax coloring
06:11:10FromDiscord<dissolved.girl> That doesn't seem like a Nim issue 😅
06:11:26FromDiscord<Invisible> 🤷‍♂️
06:47:21termerclicked on #nim
06:47:24termersaw Beef
06:47:31termerjust another typical day
06:51:48*PMunch joined #nim
07:27:11FromDiscord<Chronos [She/Her]> Would it be easy to treat Redis as a native Nim variable using a proc or something? Why shouldn't I do that?
08:54:39FromDiscord<kaddkaka> NIM spells WIN if u spin it 180 degrees 🤯
08:56:37FromDiscord<heysokam> you need to spin it recursively to get the real message
08:59:58*beholders_eye joined #nim
09:02:07*anddam_ is now known as anddam
10:21:43FromDiscord<chmod222> You need an australian mirror
11:03:15FromDiscord<Andreas> hi, i have a minor problem passing a proc into a constructor-proc. Heres a simplified example https://play.nim-lang.org/#ix=4ycr↵It involves two concepts, which test ok. Calling `makeChunk` from inside the constructor works. I'm too dump to pass it in. ↵I'm happy for any insight..
11:11:37NimEventerNew thread by ploxotnuj1: Library for tracking pressed keys, see https://forum.nim-lang.org/t/10273
11:14:18*azimut joined #nim
12:21:13FromDiscord<deech> Is there a `seq` iterator that yields the items in reverse order?
12:21:41FromDiscord<deech> (edit) "Is there a `seq` iterator that yields the items in reverse order? ... " added "I get that `deque` exists but sometimes it's convenient."
12:22:59PMunch`iterator backwards[T](x: seq[T]): T = for i in countdown(x.high, x,low): yield x[i]`
12:23:33FromDiscord<deech> Does this exist in the standard library?
12:25:00FromDiscord<Andreas> @pmunch hi, pls take a look here https://play.nim-lang.org/#ix=4ycr i worked around it, but that solution is silly..
12:25:10FromDiscord<Andreas> (edit) "that" => "my"
12:25:21PMunchdeech, no only in your imagination :P
12:25:47PMunchI don't think there's anything like that in there, if there was I'd hope it would take an openarray instead
12:26:03PMunchAndreas, take a look at what?
12:26:39FromDiscord<intellj_gamer> There's `reversed` (https://nim-lang.org/docs/algorithm.html#reversed%2CopenArray%5BT%5D) but it sadly doesn't have an iterator overload
12:26:49FromDiscord<deech> Thanks! I try to use the stdlib when possible but this is neat as well.
12:28:02FromDiscord<deech> In reply to @intellj_gamer "There's `reversed` (https://nim-lang.org/docs/algor": I saw that but it actually does the work of in place reversing the seq which is I don't need, I just need to read it backwards so an iterator or for loop is ideal.
12:28:18FromDiscord<deech> (edit) removed "is"
12:30:41FromDiscord<intellj_gamer> That's `reverse`, `reversed` returns a new seq.
12:30:45FromDiscord<intellj_gamer> (edit) "seq." => "seq"
12:31:06FromDiscord<Andreas> In reply to @PMunch "<@754284517316886598>, take a look": https://play.nim-lang.org/#ix=4ycL this on. i am obviously too dumb too pass a proc into a constructor
12:31:25FromDiscord<Andreas> (edit) "on." => "one here."
12:31:25FromDiscord<deech> Oh I missed that! I'll keep it in mind for the future. Thanks!
12:31:38*ntat_ joined #nim
12:31:55*ntat quit (Ping timeout: 260 seconds)
12:33:19*ced1 is now known as cedb
12:34:46FromDiscord<intellj_gamer> think the convention is past tense means it returns a new value while present does in place 🤔 like `sort` is in place but `sorted` returns a new seq
12:35:47*oisota joined #nim
12:37:31PMunchAndreas, should just be a matter of passing the name
12:37:56PMunchBut I'm not reading 83 lines of code to figure out where you actually try to do it
12:40:10FromDiscord<Andreas> In reply to @PMunch "But I'm not reading": i want to pass `proc chunkMaker[T]` into the `initPool`-constructor, and thats not working. Neither when i defina a type for it or describe it as `proc initPool[T]( cb :proc( pc :PoolConcept[T]) :ChunkConcept[T] ) :DumbArena[T] `
12:41:51PMunchTry to create a minimal reproduction
12:46:09FromDiscord<Andreas> In reply to @PMunch "Try to create a": its < 50-loc https://play.nim-lang.org/#ix=4ycO problem is line-48
13:03:29*krux02 joined #nim
13:22:15*xet7 quit (Quit: Leaving)
13:25:30*ntat_ is now known as ntat
13:27:29FromDiscord<voidwalker> Do I remember well, was there some way to tell nim not to pre-allocate/initialize the result var in procs ?
13:27:40PMunch{.noinit.}
13:29:45PMunchAndreas, what is up with this spacing?!
13:30:17FromDiscord<Andreas> In reply to @PMunch "<@754284517316886598>, what is up": wdym ? its great and VSCode wants it that way
13:30:37PMunchYou should fix your VSCode setup, nothing about this is great..
13:31:38FromDiscord<Andreas> In reply to @PMunch "You should fix your": well, its your playground, isn't it - you could pipe all user-code thru nimpretty ?
13:31:43FromDiscord<voidwalker> hm ok that skips the initialization, but it still allocates memory for the result, right ? can this be skipped as well if we return another variable ?
13:31:58PMunchHmm, I thought [:int] would work, but then it complains about braces.. Not sure if there's a way to do this, might not like the concepts mixed with generics in that way..
13:32:35PMunchvoidwalker, what do you mean? The result needs space to live in..
13:33:46PMunchWhen you make a call the arguments are pushed onto the stack, then it skips forward the amount of space of the return value, and then it jumps to the code. When the code returns the caller can expect the return value to be the last thing on the stack, that's just how function calling works
13:34:01FromDiscord<voidwalker> yeah I guess I don't really understand how this works internally. let's say you return the string and choose to build it in another variable, not result (cause result is too long, maybe if it was ret like in Go..). That means you have two initializations of memory space for the same goal. How can this be avoided ?
13:34:21PMunchBy using result..
13:34:36PMunchThat's the whole point of result
13:34:40FromDiscord<voidwalker> is there no way to alias result to another name ? : )
13:34:47FromDiscord<voidwalker> like r or ret or res
13:34:48PMunchWell..
13:34:55PMunchYou could use a template
13:35:45FromDiscord<odexine> In reply to @PMunch "<@754284517316886598>, what is up": You haven’t met them yet huh
13:35:45FromDiscord<Andreas> In reply to @PMunch "Hmm, I thought [:int]": hmm, that was my assumption, too. Is that smth. i should report ? Cos' passing around concepts is important and the only way to make use of them - other than that it a pretty "java-ish"-kata for the docs..
13:36:09PMunchvoidwalker, like so: https://play.nim-lang.org/#ix=4yd0
13:37:23FromDiscord<voidwalker> hm i guess.. this is quite an okay solution
13:37:53PMunchOf course if you want it slightly more ergonomic and plan to use this a lot you could do something like this: https://play.nim-lang.org/#ix=4yd1
13:38:19PMunchFeel free to swap x and y if you prefer that
13:38:37FromDiscord<voidwalker> yeah that is quite perfect now : )
13:39:05PMunchodexine, I think I've complained about it before :P
13:39:09FromDiscord<voidwalker> Good for when you have a big ass proc with a huge object to build, and have to type result 100 times
13:39:44FromDiscord<voidwalker> if it's a ref object, you can just do `var r = result`
13:39:50FromDiscord<odexine> Personally I don’t think “ret” explains enough of what it actually is
13:39:59FromDiscord<odexine> Nor does “r”
13:40:00PMunchAndreas, sure reporting it seems like a good idea. But I guess since the concept is still open I'm not sure that could work..
13:40:33PMunchDefinitely makes your code harder to scan
13:40:50PMunchEspecially if your editor highlights `result` in a different colour like mine does
13:40:55FromDiscord<voidwalker> well, there's a middle ground between readability (by non nim user), readability by nim user, and writing efficiently, succint code as a proficient nim user
13:41:37FromDiscord<voidwalker> I normally don't mind `result` except when it's all over the place, and makes lines too long so you have to split them etc
13:43:41FromDiscord<voidwalker> Another topic I'd like some insight into. Nim strings allow 0/null value, cstrings don't. Should strings be used as storage for raw binary data then?
13:46:26FromDiscord<odexine> In reply to @voidwalker "Another topic I'd like": ?
13:46:28FromDiscord<odexine> They do?
13:46:37FromDiscord<odexine> Please check again
13:46:52FromDiscord<voidwalker> they do ? I thought strings in C (not cstrings) don't
13:47:01FromDiscord<odexine> Wait you mean in the fact that they can contain zeroed bytes
13:47:06FromDiscord<odexine> Okay that’s a strange sentence to parse
13:47:23FromDiscord<Andreas> In reply to @PMunch "<@754284517316886598>, sure reporting it": wdym "concept is still open" ? it's experimental ?
13:48:18FromDiscord<arnetheduck> In reply to @voidwalker "Good for when you": you can avoid both problems by using the object construction syntax (`Obj(field: a, field2: b)`: https://status-im.github.io/nim-style-guide/language.objconstr.html)
13:50:07*PMunch_ joined #nim
13:50:36FromDiscord<odexine> In reply to @voidwalker "Another topic I'd like": Strings can indeed be used to store raw binary data but i would point you at seq[byte] instead
13:51:16*PMunch quit (Ping timeout: 260 seconds)
13:51:28*psydruid quit (Write error: Connection reset by peer)
13:51:28*frenchboy[m] quit (Write error: Connection reset by peer)
13:51:33FromDiscord<arnetheduck> In reply to @PMunch "Of course if you": fwiw, solutions like this go out of their way to preserve the poor style that results from `result` usage, ie that of mutating an object that initially starts out in an invalid state - it's a very common source of bugs in Nim, that code either forgets to write or overwrites a partially initialized obect because of this
13:51:43FromDiscord<voidwalker> @arnetheduck that's not efficient, I don't want double initialization
13:53:06FromDiscord<voidwalker> why would I init with 0/empty values only to init again with the proper computed values
13:53:26FromDiscord<odexine> You wouldn’t using object constructor syntax?
13:53:58FromDiscord<odexine> Not sure where you think the double initialisation comes from
13:54:13FromDiscord<arnetheduck> In reply to @voidwalker "why would I init": you're in for a bad surprise: nim will zero your object twice _before_ you can start using `result....` due to bugs
13:54:32FromDiscord<odexine> Why twice? That sounds strange
13:54:54FromDiscord<voidwalker> I know it inits it once, and with {.noInit.} we're supposed to get 0 inits
13:54:59FromDiscord<arnetheduck> once in the caller and once in the function itself
13:55:16*PMunch joined #nim
13:55:18FromDiscord<voidwalker> that sounds like a bad bug, but if it's a bug, then it will be fixed some day ?
13:55:30FromDiscord<voidwalker> We should code for the future, not the buggy present : P
13:55:32*PMunch_ quit (Ping timeout: 240 seconds)
13:55:59FromDiscord<voidwalker> if the function returns a ref object, does it still do inits ?
13:56:05FromDiscord<arnetheduck> in that future, you want to use object construction syntax as much as possible - it's the one that gives the most relevant intent to the compiler so the compiler can know how to optimize it
13:56:16FromDiscord<voidwalker> https://github.com/sgmihai/torrentim/blob/8e9e0491a3eae432b28b9d0e6a11ffd80658c802/torrentim.nim#L112
13:56:22FromDiscord<arnetheduck> `noinit` is another bug workaround, essentially
13:56:40FromDiscord<voidwalker> this is the constructor I had in mind when asking about this
13:56:52FromDiscord<arnetheduck> compilers can _generally_ understand that when writing 0 then writing a value to a memory location, the first write can be removed - that only works for specific cases though
13:56:53FromDiscord<voidwalker> What could I do better ?
13:57:33FromDiscord<arnetheduck> nim here does a few things which prevents this optimization from happening, but that's a different story (related to said bugs)
13:58:15FromDiscord<demotomohiro> sent a long message, see http://ix.io/4yda
13:58:46FromDiscord<arnetheduck> In reply to @voidwalker "https://github.com/sgmihai/torrentim/blob/8e9e0491a": this is exactly the kind of code that would be better off using init syntax - it would save performance and be more elegant / less boiler-plated
13:59:00*frenchboy[m] joined #nim
13:59:19FromDiscord<arnetheduck> you'd also reduce the risk of overwriting fields several times and a few other ugly things..
13:59:20*psydruid joined #nim
14:00:05*PMunch_ joined #nim
14:00:35*PMunch quit (Ping timeout: 260 seconds)
14:00:39FromDiscord<voidwalker> still not sure how this would look like..
14:01:45FromDiscord<voidwalker> put each field of the object in a separate var, then call init again with all that huge chunk of values ?
14:01:56FromDiscord<voidwalker> that sounds very messy
14:01:56FromDiscord<arnetheduck> sent a code paste, see https://paste.rs/lQThu
14:02:05FromDiscord<voidwalker> oh
14:03:06FromDiscord<arnetheduck> when written like that, nim usually makes use of something called RVO where if you call `field: someFunction()`, the function will write to the field directly instead of makign a copy first
14:03:16FromDiscord<arnetheduck> (edit) "makign" => "making"
14:04:12FromDiscord<voidwalker> so I should have a function to parse every field :\
14:05:06FromDiscord<arnetheduck> well, you don't have to - you can mix in expressions and other things as well - they will _typically_ write directly to the memory location of the field except for a number of cases which are bugs
14:06:29*azimut_ joined #nim
14:06:43*azimut quit (Remote host closed the connection)
14:09:35FromDiscord<arnetheduck> sent a code paste, see https://play.nim-lang.org/#ix=4ydg
14:11:08FromDiscord<odexine> I was going to mention whether these double initialisations actually mattered in the application
14:11:19FromDiscord<odexine> Sounded like premature optimisation
14:12:23FromDiscord<voidwalker> this all talk is about premature optimisation : P
14:13:19FromDiscord<voidwalker> Probably doesn't matter too much, it's about adding/parsing a torrent. There's many more optimisations to be done at parsing the bencoded data efficiently, vs using a generic parser
14:13:50FromDiscord<arnetheduck> I look at it from the point of view of clarity - if you're doing lots of redundant repetitive work (such as repeating `result` all the time in your code), so does the reader _and so does the compiler preventing it from optimising for you_ - it's a lose-lose-lose situation
14:14:01FromDiscord<demotomohiro> Nim and backend C compiler do many good optimizations. You don't need to do manual optimization that compiler do.
14:14:29FromDiscord<arnetheduck> there are a few notable exceptions to that rule, but unless you can notice them when running the app, well ..
14:16:10*PMunch_ quit (Quit: Leaving)
14:17:41*xet7 joined #nim
14:21:45*rockcavera joined #nim
14:21:58FromDiscord<spotlightkid> Why do I see many threads with activity since my last visit on the Nim forum, but if I open them, the last post is from months ago? Spam? New posts from moderated users?
14:25:20FromDiscord<yandall> Hi, someone has already faced this problem? I have a memory leak when using prologe, I think my problem is related to this one but I haven't been able to find a solution https://github.com/nim-lang/Nim/issues/21631
14:28:28FromDiscord<mratsim> In reply to @deech "I saw that but": you can use `dup`to transform in-place in out-place, reusing buffers if needed.
14:30:28FromDiscord<mratsim> In reply to @voidwalker "yeah I guess I": stack allocation is just `sub rsp, 0x10` assuming you need 16 bytes on the stack
14:31:02FromDiscord<mratsim> if the compiler finds that 200 bytes are needed for 10 objects it won't make 10 allocations, it will do it all at once.
14:32:42FromDiscord<odexine> In reply to @spotlightkid "Why do I see": both yes
14:32:51FromDiscord<voidwalker> Alright, about using strings to store null values, should that be done ? What are the downsides ? compatibility problems if using the nim->c code in a c lib ?
14:33:34FromDiscord<mratsim> In reply to @voidwalker "Alright, about using strings": null values?↵↵a null pointer? or a 0x00 byte?
14:33:35FromDiscord<voidwalker> I am asking cause, I asked for a patch for a great nim library, binarylang, to support 0 values in strings, and author told me strings should be used for text only :\
14:33:40FromDiscord<voidwalker> 0 value byte
14:34:08FromDiscord<mratsim> he is right. And cstring ends with 0x00 byte.
14:34:22FromDiscord<mratsim> so you can't use them
14:34:27FromDiscord<voidwalker> I have fixed/known-size string to parse in binarylang, and it breaks before the size because the default end termination for strings is 00 value
14:34:42FromDiscord<voidwalker> (edit) "I have fixed/known-size string to parse in binarylang, and it breaks before the size because the default end termination ... for" added "check in binaryalng"
14:35:02FromDiscord<voidwalker> but there is no other data structure to hold chunks of binary data in binarylang, so we have to use string
14:35:13FromDiscord<odexine> strings can have \0 bytes in them
14:35:17FromDiscord<mratsim> if you want to deal with binary data, use seq[byte]
14:35:39FromDiscord<graveflo> In reply to @demotomohiro "Anyone know how to": Are you looking to do something specific? It seems you have most of all you need to get started
14:35:41FromDiscord<mratsim> In reply to @odexine "strings can have \0": not if you need to pass them to a C function after
14:35:57FromDiscord<odexine> that is correct only if the C function expects \0 termination
14:36:08FromDiscord<voidwalker> ok so the whole nim stdlib is badly design by using mostly strings for everything binary
14:36:11FromDiscord<odexine> if it uses buf+len style, then it could work
14:36:32FromDiscord<odexine> In reply to @voidwalker "ok so the whole": thats what backward compatibility gets you id say
14:36:42FromDiscord<mratsim> In reply to @voidwalker "ok so the whole": I agree: https://github.com/nim-lang/RFCs/issues/32
14:36:47FromDiscord<odexine> but yes
14:37:39FromDiscord<spotlightkid> @voidwalker\: then binarylang apparently isn't the right tool for the job. If the author won't change it, you have two options\: fork it or look for another tool.
14:38:30FromDiscord<voidwalker> he might change it, I was just curious if the reasoning is right, about strings having/not having 0x00 values in them
14:39:19FromDiscord<voidwalker> this whole null terminated string bs is 50 year old legacy now :\
14:41:56FromDiscord<demotomohiro> In reply to @graveflo "Are you looking to": It seems `jiro4989/setup-nim-action` installs devel Nim using choosenim and I think installed Nim contains compiler modules.↵But `import compiler/platform` fails.↵Setting `--path` options might fix the problem but there are 3 OS that tests runs and they installs Nim in different places.
14:41:57FromDiscord<spotlightkid> maybe point him at https://docs.python.org/3/library/struct.html ?↵`struct.unpack("4s", b"foo\0")` will happily include the null-byte in the returned string.
14:45:42FromDiscord<voidwalker> https://sealmove.github.io/binarylang/#features-strings
14:45:53FromDiscord<voidwalker> `Strings are special because they don't have a fixed size. Therefore, you must provide enough information regarding their termination. `
14:46:02FromDiscord<voidwalker> `s: a # null/eos-terminated (because next field doesn't use assertion)`
14:46:47FromDiscord<voidwalker> But I also think it's kind of wrong to arbitrarily assume a string would be terminated by a null byte, in a binary data structure ?
14:46:56FromDiscord<odexine> i think thats a different string from what we thought what you meant?
14:47:11*azimut_ quit (Remote host closed the connection)
14:47:41*azimut joined #nim
14:48:06FromDiscord<odexine> `Strings are null/eos-terminated unless assertion is used on the same field or on the next field`\
14:48:08FromDiscord<odexine> (edit) "field`\" => "field`"
14:48:20FromDiscord<odexine> so use an assertion on the next field, i dont understand the problem
14:48:25FromDiscord<voidwalker> I was asking in a general sense, about the theoretical (philosophical even) aspects of using strings vs other data structures. In the context of trying to figure out the correct way to fix binarylang
14:48:55FromDiscord<odexine> strings are not meant to hold binary data, the meaning of string is usually attributed to text
14:49:44FromDiscord<voidwalker> well I cannot force my data structure to use assertion, if there's no assertion to be had. I just know the length of the string to be read. And this works, unless the string has 0x00 inside it, in which case the parsing breaks (it could be argued that no parsing should be done in this case, but a simple blind copy)
14:52:46FromDiscord<odexine> then use a seq[byte] (or integer)↵`8: thefield[length]`
14:53:51FromDiscord<odexine> i dont understand why you wanted to use a string for this
14:54:41FromDiscord<voidwalker> well I guess I could do that, and then I would have to copymem into a string again.. would have been better if it was string to begin with
14:55:39FromDiscord<odexine> why do you want it to be a string
14:56:16FromDiscord<voidwalker> Cause it's data that gets sent/received from socket, at a high speed. It would be best to avoid it being copied uselessly many times
14:56:27FromDiscord<odexine> that does not answer my question
14:56:48FromDiscord<odexine> what does the string type net you that the seq[int] data type does not
14:56:50FromDiscord<voidwalker> well, socket works with pointers as well..
14:57:12FromDiscord<voidwalker> convenience I guess, and not having to rewrite any code : D
14:57:53FromDiscord<voidwalker> I guess I have no choice but to rewrite to `8: field[length]` style, and use pointers for socket instead of string var
14:58:17FromDiscord<odexine> so basically nim stdlib strikes again i guess
14:58:17FromDiscord<odexine> xd
15:00:08FromDiscord<voidwalker> why couldn't they make string type in nim with no backwards compatibility, so it can be interchanged with arrays, seq of byte etc, without needing copies and such. This is one of the things that bugs me the most about nim. In other languages, data arrays are more homogenous
15:00:15FromDiscord<odexine> okay so uh
15:00:33FromDiscord<odexine> technically you can cast strings to seqs as long as the backing type is 8 bits
15:00:49FromDiscord<odexine> strings and seqs are internally represented the same as of now
15:01:37FromDiscord<voidwalker> https://github.com/nim-lang/Nim/issues/14810
15:02:05FromDiscord<odexine> yes
15:02:54FromDiscord<voidwalker> it's really breaking ergonomics if I can't have a byte array be treatead as a string and so on
15:27:15NimEventerNew Nimble package! nimmicrograd - Nim implementation of micrograd autograd engine., see https://github.com/soheil555/nimmicrograd
15:30:01FromDiscord<odexine> huh
15:43:06FromDiscord<michaelb.eth> In reply to @voidwalker "why couldn't they make": string is a gc'd thing in Nim, which leads to it needing to be treated separately from other datastructures that have the same shape internally, that's what I understood from the manual, if I'm remembering correctly
15:44:02FromDiscord<michaelb.eth> maybe things are different/better with orc/arc, but with refc I'm aware you have to be a bit careful going back and forth betweeng string and seq
15:44:28FromDiscord<michaelb.eth> stew/byteutils has facilities for that purpose which avoid problems you can run into
15:46:41FromDiscord<odexine> In reply to @michaelb.eth "string is a gc'd": but sequences are as well, so
15:47:18FromDiscord<michaelb.eth> true, I'm re-reading now
15:48:27FromDiscord<voidwalker> not closing httpclient in a proc.. the http objects gets garbage collected, but it will leak file descriptors ? am I right ?
15:49:54FromDiscord<voidwalker> I thought it was okay not to close it, but running the program in console got me an exception because of too many file descriptors, while running it in vscode didn't. Probably vscode sets some env vars so the value is higher ?
15:49:59FromDiscord<Chronos [She/Her]> Does `chronos` just slot in to any async project when changing the async backend or does that screw with anything?
15:50:17FromDiscord<Chronos [She/Her]> Like do I need to do anything specifically besides toggling the flag?
15:50:34FromDiscord<voidwalker> I'd very much like to know that myself, I found no info of how this swapping actually works, what to look out for etc
15:50:46FromDiscord<voidwalker> what happens if you import libs that import asyncdispatch
15:51:23FromDiscord<Chronos [She/Her]> Yeah, I've heard orc can cause memory leaks with async so I'd like to avoid it
15:51:44FromDiscord<Chronos [She/Her]> In reply to @voidwalker "what happens if you": I believe in the docs it says it'll use the other backend?
15:51:51FromDiscord<Chronos [She/Her]> But not sure tbh
15:51:52FromDiscord<michaelb.eth> asyncdispatch event loop and chronos event loop cannot run on the same thread, so I believe that per-thread you have to be consistent
15:52:11FromDiscord<Chronos [She/Her]> In reply to @michaelb.eth "asyncdispatch event loop and": If my entire application uses chronos then it's fine?
15:52:46FromDiscord<michaelb.eth> as long as you're not making use of some async thing that will implicitly start the asyncdispatch event loop
15:52:54FromDiscord<michaelb.eth> you should be ok
15:52:55FromDiscord<voidwalker> how does this compile param switch even work ? you can import either chronos or asyndispatch and it won't matter ?
15:54:55FromDiscord<michaelb.eth> In reply to @voidwalker "how does this compile": is it `-d:useChronos` or something like that?
15:54:56FromDiscord<voidwalker> if so, what stops the nim stdlib asyncdispatch stuff to be compiled to work with chronos ?
15:55:16FromDiscord<voidwalker> (edit) "if so, what stops the nim stdlib asyncdispatch stuff to be compiled to work with chronos ? ... " added "(if otherwise compatible syntax/features are used)"
15:55:32FromDiscord<Chronos [She/Her]> In reply to @michaelb.eth "is it `-d:useChronos` or": Iirc `--asyncBackend:chronos`...?
15:56:09FromDiscord<michaelb.eth> ah right: https://github.com/status-im/nim-chronos#multiple-async-backend-support
15:56:28FromDiscord<michaelb.eth> that's not something baked into Nim, it's a suggested convention that library/module authors can use
15:58:48FromDiscord<voidwalker> oh so it comes from importing chronos, it cannot work without import chronos
16:01:25FromDiscord<michaelb.eth> per that readme, a library author could choose which async backend libary to import by checking `when defined(asyncBackend): if asyncBackend == chronos: ... else: ...`
16:01:46FromDiscord<michaelb.eth> (edit) "per that readme, a library author ... could" added "(or you in your code)"
16:02:07FromDiscord<voidwalker> ohhh so it's just a convention to be used
16:02:11FromDiscord<michaelb.eth> alternatively, a library may provide different entrypoints, one for chronos compat, another for asyncdispatch compat
16:02:16FromDiscord<michaelb.eth> In reply to @voidwalker "ohhh so it's just": yes, correct
16:02:26FromDiscord<voidwalker> WHY didn't they say so 😄
16:02:55*junaid_ joined #nim
16:02:56FromDiscord<michaelb.eth> I think they do, just may not have been clear on first reading
16:05:38*beholders_eye quit (Ping timeout: 265 seconds)
16:08:56FromDiscord<michaelb.eth> In reply to @voidwalker "if so, what stops": the dispatchers (event loops) are different; I'd need to check, but I think the `{.async.}` macro of asyncdispatch ties you to asyncdispatch's dispatcher, while chronos' `{.async.}` ties you to chronos' dispatcher
16:09:09FromDiscord<michaelb.eth> and as I mentioned before, you can't have both dispatchers running in the same thread
16:09:51FromDiscord<voidwalker> yes I am aware of that. I read that doc entry a few times and it is still not clear to me that asyncBackend is a convention and not something built in chronos (or asyncdispatch)
16:10:01FromDiscord<voidwalker> (edit) "yes I am aware of that. I read that doc entry a few times and it is still ... not" added "was"
16:12:51FromDiscord<voidwalker> I wonder then how much of stdlib works with chronos out of the box, maybe they could patch the sources to allow this chronos/asyncdispatch switch, would make using it in such projects easier
16:13:23FromDiscord<michaelb.eth> good point, maybe it does need to be stated more clearly:↵> Libraries built on top of async/await may wish to support multiple async backends. The are suggested conventions for doing that, but keep in mind they are only conventions and it is up to individual library and package authors to implement them↵> ↵> Tthe best way to do so is to create separate modules for each backend that may be imported side-by-side....
16:13:33FromDiscord<michaelb.eth> (edit) "The" => "There"
16:13:53FromDiscord<michaelb.eth> (edit) "that," => "so," | "them↵>" => "them.↵>"
16:21:57*junaid_ quit (Quit: leaving)
17:05:16FromDiscord<!&luke> Is there a way to use fakeroot in nim
17:10:55FromDiscord<!&luke> Can setCurrentDir be used in conjunction with exec
17:15:37FromDiscord<demotomohiro> `proc execProcess` has `workingDir` parameter.
17:16:48*oldpcuser quit (Ping timeout: 248 seconds)
17:33:31*oldpcuser joined #nim
17:55:57*beholders_eye joined #nim
18:05:27FromDiscord<!&luke> In reply to @demotomohiro "`proc execProcess` has `workingDir`": I don't think I can use that in nimscript can I?
18:16:52*frenchboy[m] quit (Remote host closed the connection)
18:18:10*frenchboy[m] joined #nim
18:19:28*cedb quit (Quit: WeeChat 3.8)
18:29:00FromDiscord<Prestige> Anyone else using the latest release of pixie? It seems broken
18:30:14FromDiscord<demotomohiro> In reply to @ripluke "I don't think I": Probably you cannot use them in nimscript.
18:31:25FromDiscord<Prestige> Ah it was an issue with nimble I guess, I had to delete chroma and reinstall dependencies
19:06:31*beholders_eye quit (Ping timeout: 240 seconds)
19:26:36*ntat quit (Quit: Leaving)
19:52:40NimEventerNew Nimble package! nimegenerator - Random name/word generator., see https://github.com/nirokay/nimegenerator
21:25:43*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
21:26:33*adium quit (Server closed connection)
21:26:49*adium joined #nim
21:27:10*ehmry joined #nim
22:00:08*candlestick joined #nim
22:00:13*candlestick left #nim (#nim)
22:21:41*ced1 joined #nim
22:21:51*ced1 is now known as cedb
23:51:04termerDoing a livestream trying out the CPS concurrency library. I'm aiming to learn it for some experiments outside of async/await since asyncdispatch is so bad
23:51:07termerhttps://live.termer.net/