<< 14-12-2021 >>

00:25:44*noeontheend joined #nim
00:45:36*krux02 quit (Remote host closed the connection)
01:09:32*src quit (Quit: Leaving)
01:33:25*noeontheend quit (Ping timeout: 240 seconds)
01:38:59*noeontheend joined #nim
01:53:49*noeontheend quit (Ping timeout: 240 seconds)
01:56:21NimEventerNew post on r/nim by 4runninglife: Nim is great, that is all, see https://reddit.com/r/nim/comments/rfw71y/nim_is_great_that_is_all/
02:00:33*lumo_e quit (Ping timeout: 252 seconds)
02:11:46*vicfred quit (Quit: Leaving)
02:20:32*crem quit (Ping timeout: 240 seconds)
02:21:23*crem joined #nim
02:28:07NimEventerNew thread by Prestige: Maze solver benchmark - How would you optimize?, see https://forum.nim-lang.org/t/8709
02:54:45FromDiscord<huantian> <https://github.com/huantianad/advent-of-code/blob/150bb6642b246c4b3094c89ebe77bf0214cc0214/2021/day13.nim#L31> ↵why does changing this line to just an `else:` make nim unhappy
03:19:19FromDiscord<impbox [ftsf]> what does it say?
03:20:34FromDiscord<impbox [ftsf]> also it's hard to say when you're including stuff and it can't be run
03:25:52FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=3Ikd
03:27:26FromDiscord<impbox [ftsf]> what's the error?
03:28:41FromDiscord<huantian> `invalid type: 'void' in this context: 'seq[void]' for var`↵`expression 'x' is of type 'int' and has to be used (or discarded)`↵both on the bottom x
03:59:51FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3Iko
04:00:38FromDiscord<geekrelief> (edit) "https://play.nim-lang.org/#ix=3Iko" => "https://paste.rs/DhG"
04:01:26FromDiscord<valerga> i wonder why the arch repos still have nim 1.4.8 hmm
04:02:18FromDiscord<valerga> `Last Updated: 2021-06-07 `
04:03:05FromDiscord<valerga> hmm the maintaner of it maintains a ton of packages though
04:03:10FromDiscord<valerga> (edit) "maintaner" => "maintainer"
04:03:19FromDiscord<valerga> https://archlinux.org/packages/?packager=anthraxx
04:06:02*supakeen quit (Quit: WeeChat 3.3)
04:06:31*supakeen joined #nim
04:18:23*arkurious quit (Quit: Leaving)
04:22:29*rockcavera quit (Remote host closed the connection)
04:31:16*noeontheend joined #nim
05:02:51*PersonMcGuy joined #nim
05:04:20PersonMcGuyHello everyone. Quick question. What exactly is the difference between waitFor and await? A lot of times I've used waitFor in non-async procs while being lazy, but I'm sure this is not how it was intended to be used
05:06:19FromDiscord<Rika> It is, it’s the only thing you can use in sync procs
05:06:28FromDiscord<Rika> You use await in async procs
05:09:23PersonMcGuy@Rika ah okay, so then is there any weird behavior if waitFor is used within an async proc?
05:15:39FromDiscord<Rika> Yes, you block
05:15:53FromDiscord<Rika> Effectively negating the use of async
05:18:58PersonMcGuy@Rika That makes sense. Thanks for the insight, I appreciate it
05:19:31*PersonMcGuy quit (Quit: Client closed)
05:20:12FromDiscord<Schelz> Does directx exist in nim ?
05:24:39FromDiscord<Rika> It can
05:24:51FromDiscord<Rika> I don’t know if someone has made a wrapper
05:25:02FromDiscord<impbox [ftsf]> what is directx even anyway?
05:25:51FromDiscord<impbox [ftsf]> wow, it's a lot of stuff
05:25:57FromDiscord<impbox [ftsf]> would be a lot of work to wrap manually i guess
05:26:10FromDiscord<impbox [ftsf]> i guess just wrap the bits you need
05:26:26FromDiscord<Rika> I just assumed he meant D3D
05:27:06FromDiscord<valerga> sent a code paste, see https://play.nim-lang.org/#ix=3IkE
05:27:23FromDiscord<valerga> how can I do that... or what's a better structure to hold [int, string] ?
05:30:11FromDiscord<valerga> i'll just make an object
05:33:09FromDiscord<impbox [ftsf]> what are you trying to do?
05:34:28FromDiscord<Elegantbeef> The relatiionship between the data is very important here
05:34:57FromDiscord<valerga> it an association of indexes (int) and strings
05:38:09FromDiscord<impbox [ftsf]> are you expecting all the indices to be filled out?
05:38:13FromDiscord<impbox [ftsf]> or random numbers to strings?
05:38:38FromDiscord<impbox [ftsf]> array[N,string] or seq[string] if the first
05:38:47FromDiscord<impbox [ftsf]> or Table[int,string] for the latter
05:42:43FromDiscord<valerga> i don't expect all indices, just some
05:43:33FromDiscord<valerga> object is cleaner to work with I think
05:45:11FromDiscord<impbox [ftsf]> what kind of operations will you be doing?
05:45:26FromDiscord<impbox [ftsf]> indexing will be slow if you're searching through the objects to find the correct one
05:45:32FromDiscord<impbox [ftsf]> that's where a table is nice
05:50:12FromDiscord<valerga> what im doing is havea seq of objects, then sort that seq by the object's index property
05:50:17FromDiscord<valerga> (edit) "havea" => "have a"
05:57:24FromDiscord<impbox [ftsf]> yep, you'd be better off using a table most likely
05:57:42FromDiscord<impbox [ftsf]> but depends what kind of operations you're doing most often
05:58:03FromDiscord<impbox [ftsf]> sorting and searching is generally slow
06:13:26*noeontheend quit (Ping timeout: 260 seconds)
06:16:50FromDiscord<valerga> but how do I iterate the table keys in a sorted manner?
06:19:23FromDiscord<valerga> oh OrderedTable
06:25:32FromDiscord<Professor Actual Factual> sent a code paste, see https://play.nim-lang.org/#ix=3IkP
06:26:20FromDiscord<Rika> Do you need compile date and time?
06:27:54FromDiscord<Elegantbeef> The compiler can be built with libffi
06:32:05FromDiscord<impbox [ftsf]> OrderedTable is not sorted, it is based on insertion order
06:32:32FromDiscord<Elegantbeef> It can be sorted though
06:33:12FromDiscord<impbox [ftsf]> or get the keys and sort them
06:34:08FromDiscord<Rika> Doesn’t it have a sort function
06:34:57FromDiscord<Professor Actual Factual> In reply to @Rika "Do you need compile": Dont need compile time, i just want a cimport function to work. Times.now was the first to come to mind but it could be anything
06:36:56FromDiscord<Elegantbeef> Like i said build the compiler yourself with `-d:nimHasLibffi` then you should be able to
06:36:59FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/pull/10150 for reference
06:37:53FromDiscord<Professor Actual Factual> In reply to @Elegantbeef "https://github.com/nim-lang/Nim/pull/10150 for refe": Thank you for the quick reply, will def look into this.
06:39:02FromDiscord<valerga> I'm hitting a limit using string.insert. would it be faster to concatenate manually?
06:39:30FromDiscord<Michal58> Some questions about tables: What is the equivalent of Python's defaultdict?
06:39:41FromDiscord<Elegantbeef> what does defaultDict do?
06:40:35FromDiscord<Elegantbeef> Is it just `Table[string, T]`?
06:40:38FromDiscord<Michal58> Why is there no dec for CountTable?
06:41:57FromDiscord<Elegantbeef> No clue but you can do `inc` with a negative
06:42:16FromDiscord<impbox [ftsf]> defaultdict i believe returns a specific value if you try to get an index that hasn't been set
06:42:30FromDiscord<impbox [ftsf]> you could do similar with `getOrDefault`
06:42:36FromDiscord<Elegantbeef> Yea
06:44:24FromDiscord<Michal58> In reply to @impbox "you could do similar": Wa afraid you'd say that
06:44:35FromDiscord<Elegantbeef> Why afraid?
06:45:33FromDiscord<impbox [ftsf]> you could make your own type that does it fairly trivially i think
06:45:35FromDiscord<Michal58> Since it's not that convenient
06:45:57FromDiscord<Elegantbeef> Sure but it's easy to alias or replicate
06:47:29nrds<Prestige99> Maybe an example is in order
06:49:17FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3IkT
06:49:22FromDiscord<Elegantbeef> I can only write so fast my dear boy
06:51:23FromDiscord<impbox [ftsf]> https://play.nim-lang.org/#ix=3IkU
06:51:31FromDiscord<impbox [ftsf]> faster than me
06:52:02FromDiscord<impbox [ftsf]> even had time to add in `std/`
06:52:18FromDiscord<Elegantbeef> and `contains`
06:55:45FromDiscord<Elegantbeef> If the value was compile time known this could even be done with just a distinct
06:56:29FromDiscord<valerga> how can I get the last key in an OrderedTable?
06:56:39FromDiscord<valerga> seems keys is only an iterator
06:57:20FromDiscord<valerga> actually nvm I can do it without that
07:01:09FromDiscord<Michal58> "Paste removed malware"? 👮‍♂️
07:01:52FromDiscord<Michal58> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=3IkT": Yeah, I understand, thanks
07:02:46FromDiscord<Schelz> Is possible in nim to specify the type of a variable to return HANDLE ?
07:03:27FromDiscord<impbox [ftsf]> In reply to @Schelz "Is possible in nim": I don't understand the question... you can specify the type of variable a function returns
07:03:48FromDiscord<impbox [ftsf]> `proc procName(arg: ArgType): ReturnType =`
07:03:51FromDiscord<Schelz> If its possible to get the HANDLE of a process by its name
07:04:45FromDiscord<impbox [ftsf]> are you talking about a Windows thing?
07:04:54FromDiscord<Schelz> Yes :))
07:05:29FromDiscord<impbox [ftsf]> if it's exposed by the windows api then probably
07:05:42FromDiscord<valerga> sorting the OrderedTable is taking seconds...
07:06:05FromDiscord<impbox [ftsf]> valergra, just sort the keys
07:06:09FromDiscord<impbox [ftsf]> how many keys do you have?
07:06:28FromDiscord<valerga> thousands
07:06:49FromDiscord<valerga> I'm doing `ins.sort(system.cmp, order = SortOrder.Ascending)`
07:07:07FromDiscord<impbox [ftsf]> if you have a lot of keys probably just use a seq[string]
07:07:15FromDiscord<impbox [ftsf]> that way you don't need to sort
07:07:47FromDiscord<impbox [ftsf]> though i'm not sure why you need to sort
07:07:53FromDiscord<impbox [ftsf]> what are you actually trying to do?
07:08:11FromDiscord<valerga> im concatenating a string with some replacements. i need the indexes to be ordered to increment them properly
07:09:12FromDiscord<Michal58> CountTable is basically an implementation of multiset so there should be the basic operations - intersection, union, difference available. merge implements (even tho only in-place) union, but I don't see the rest?
07:09:14FromDiscord<valerga> sent a code paste, see https://play.nim-lang.org/#ix=3IkZ
07:09:20FromDiscord<impbox [ftsf]> @Schelz https://nim-lang.org/docs/winlean.html#getCurrentProcess
07:09:39FromDiscord<Elegantbeef> Michal i can only say be the change you want in the stdlib
07:11:34FromDiscord<impbox [ftsf]> In reply to @valerga "im concatenating a string": is that the only operation you're doing?
07:11:44FromDiscord<impbox [ftsf]> if so, use a seq
07:12:05FromDiscord<impbox [ftsf]> but i don't understand your usecase
07:12:42FromDiscord<Michal58> In reply to @Elegantbeef "Michal i can only": I don't understand.
07:13:11FromDiscord<impbox [ftsf]> if you need a feature that doesn't exist yet, feel free to add it. because otherwise probably no one else has needed it yet
07:13:39FromDiscord<impbox [ftsf]> or it may exist in another library, check nimble
07:13:54FromDiscord<Michal58> Yeah I just wanted to check that I'm not missing anything
07:14:07FromDiscord<impbox [ftsf]> well there are sets in nim
07:14:23FromDiscord<impbox [ftsf]> which have set operations
07:15:09FromDiscord<impbox [ftsf]> but CountTable is not a set, so I'm not sure why it would have set operations, but I'm not an expert on CountTables.
07:15:27FromDiscord<Elegantbeef> Me either it seems they're all weird operations for count table
07:16:19FromDiscord<Elegantbeef> Is `intersection(a, b) == intersection(b, a)`?
07:16:43FromDiscord<Hamid_Bluri> hey, i found `--checks:off` breaks Tables module with my code
07:16:53FromDiscord<Hamid_Bluri> (edit) "Tables" => "`tables`"
07:16:54FromDiscord<Elegantbeef> Cause i very much see them not being commutative
07:17:13FromDiscord<Elegantbeef> Does the code have runtime errors without checks?
07:17:23FromDiscord<Elegantbeef> Well with checks 😀
07:18:02FromDiscord<Hamid_Bluri> no it does not have any checks
07:18:03FromDiscord<Hamid_Bluri> https://github.com/hamidb80/problem-solving/blob/main/advent-of-code/2021/d14/main.nim#L48
07:19:02FromDiscord<Elegantbeef> So running with checks it works fine?
07:19:08FromDiscord<Hamid_Bluri> yep
07:19:38FromDiscord<Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=3Il2
07:19:43FromDiscord<Elegantbeef> That's with checks
07:19:56FromDiscord<Hamid_Bluri> no its `--checks:off`
07:20:08FromDiscord<Elegantbeef> Are you sure?
07:20:09FromDiscord<Hamid_Bluri> with checks it works fine
07:20:35FromDiscord<Hamid_Bluri> yes
07:20:41FromDiscord<Hamid_Bluri> you can check it your self
07:20:54FromDiscord<Hamid_Bluri> it doesn't have any dependencies
07:21:00FromDiscord<Hamid_Bluri> nim 1.6.0
07:21:11FromDiscord<Hamid_Bluri> (edit) "your self" => "by yourself"
07:21:55FromDiscord<Elegantbeef> Both dont run
07:22:19FromDiscord<Hamid_Bluri> with what error?
07:22:41FromDiscord<Elegantbeef> Index error with checks on and without the same error as you've got
07:23:17FromDiscord<Hamid_Bluri> how can i remove compile cache?
07:23:23FromDiscord<Elegantbeef> do `-f`
07:23:59FromDiscord<Hamid_Bluri> https://media.discordapp.net/attachments/371759389889003532/920214518573973534/unknown.png
07:24:04FromDiscord<Hamid_Bluri> it works fine
07:24:09FromDiscord<Elegantbeef> Not here
07:24:22FromDiscord<Hamid_Bluri> where then?
07:24:58FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Il3
07:25:27FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Il4
07:25:42FromDiscord<Hamid_Bluri> windows stores next line as `\r\n`
07:25:59FromDiscord<Elegantbeef> You know there is a splitlines proc?
07:27:39FromDiscord<Hamid_Bluri> yeah but i wanted to split where there are 2 next lines
07:27:53FromDiscord<Hamid_Bluri> line 29
07:28:06FromDiscord<Elegantbeef> Anywho yea i dont know what to say
07:30:36FromDiscord<Michal58> In reply to @impbox "but CountTable is not": Well CountTable (multiset) is a generalisation of a set. In set every element is present either zero times or once. In multiset each item can be present any (natural) number of times. So those operations are also just generalisations. Intersection and union are commutative, while difference is not.
07:31:33FromDiscord<Michal58> @ElegantBeef
07:31:42FromDiscord<Hamid_Bluri> https://play.nim-lang.org/#ix=3Il5
07:40:08FromDiscord<Schelz> In reply to @impbox "<@!354911589029380097> https://nim-lang.org/docs/wi": Inst there something to get process by id or name ?
07:40:50FromDiscord<impbox [ftsf]> Process ID is not the same as HANDLE
07:42:02FromDiscord<Schelz> Ik but rather getCurrentProcess
07:48:34*PMunch joined #nim
07:49:36*jjido joined #nim
07:50:02*PMunch quit (Client Quit)
07:52:17*PMunch joined #nim
07:52:43*PMunch quit (Remote host closed the connection)
07:53:42*PMunch joined #nim
08:04:37FromDiscord<impbox [ftsf]> Ooh you want a HANDLE of another windows process, I dunno, you should really check the Microsoft docs
08:05:02FromDiscord<impbox [ftsf]> Then use the corresponding function from the nim windows wrapper
08:19:28FromDiscord<Schelz> The nim windows api wrapper its import window ?
08:19:52FromDiscord<enthus1ast> import winim
08:19:58FromDiscord<enthus1ast> ^ this is the big one
08:20:12FromDiscord<Schelz> I found now thx
08:20:12FromDiscord<enthus1ast> or most complete one
08:22:19FromDiscord<enthus1ast> to get a handle to an process you must call OpenProcess
08:26:51FromDiscord<Hamid_Bluri> In reply to @hamidb80 "https://play.nim-lang.org/#ix=3Il5": why did I think `assert` discards the following statement 😕
08:27:34FromDiscord<Hamid_Bluri> sorry beef
08:27:40FromDiscord<Elegantbeef> You mean you though assert turns into discard without checks?
08:27:47FromDiscord<Hamid_Bluri> yep
08:28:04FromDiscord<Elegantbeef> Nah assert is basically for documenting what values should be
08:34:44*krux02 joined #nim
08:37:15*krux02 quit (Remote host closed the connection)
08:41:52PMunchHmm, does anyone have a packed bool sequence implementation?
08:44:41FromDiscord<enthus1ast> this maybe? https://github.com/treeform/bitty
08:45:06FromDiscord<enthus1ast> but, in my tests, a seq[bool] is way faster
08:45:24PMunchYeah I just got mine working and it's way slower
08:46:13FromDiscord<enthus1ast> why do you need it?
08:46:20FromDiscord<enthus1ast> or for what?
08:46:27FromDiscord<Rika> why is the BitArray a ref?
08:46:45FromDiscord<Elegantbeef> Probably to reduce copies
08:47:24FromDiscord<Rika> idk imo that should be to the discretion of the user
08:47:52FromDiscord<Elegantbeef> Sure but a lot of the stuff like this is made specifically for their usages
08:51:13PMunchOh wow, yeah that was an order of magnitude slower than my custom solution, which itself was an order of magnitude slower than seq[bool]
08:52:55*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
08:59:37FromDiscord<Elegantbeef> What's your indexing logic?
09:00:19FromDiscord<enthus1ast> i mean do packed bitsets even have the potential to be faster than array (or preallocated seq) ?
09:00:27FromDiscord<enthus1ast> bitarrays i mean
09:01:19FromDiscord<Elegantbeef> They probably remove a bit of speed
09:04:27FromDiscord<enthus1ast> what i can imagine is that they have a speed bonus when reading and unrolled 8 times
09:10:38*jmdaemon joined #nim
09:11:57NimEventerNew thread by Araq: Nim devel now supports Nimble 0.14, see https://forum.nim-lang.org/t/8710
09:15:48*jmd joined #nim
09:16:07*jmdaemon quit (Quit: WeeChat 3.3)
09:24:06FromDiscord<hieu.nt> hi guys
09:24:08FromDiscord<hieu.nt> sent a code paste, see https://play.nim-lang.org/#ix=3Ilw
09:24:32FromDiscord<hieu.nt> when i try the code above to delete file from google drive
09:24:35FromDiscord<hieu.nt> i got error
09:24:39FromDiscord<Rika> what error
09:25:08FromDiscord<hieu.nt> no handles or timers registered in dispatcher
09:25:15FromDiscord<Rika> how are you running it
09:25:48FromDiscord<enthus1ast> this happens when you have a runForever and the only async proc returns, then there are none left
09:26:05FromDiscord<hieu.nt> let resp = await conn.delete(url)
09:26:13FromDiscord<hieu.nt> echo resp
09:26:38FromDiscord<hieu.nt> then i wrap it in waitfor deleteDriveFile proc
09:26:55FromDiscord<hieu.nt> it throws error
09:27:03FromDiscord<hieu.nt> but the file still got deleted in google drive
09:27:04PMunchDo you have a complete snippet we can look at?
09:27:24PMunchYeah, that error just means that the pool of asynchronous tasks is empty when the dispatcher goes to find something to run
09:27:53PMunchIt's only fired by runForever I believe
09:28:33*jmd quit (Quit: ZNC 1.8.2 - https://znc.in)
09:28:54FromDiscord<hieu.nt> sent a long message, see http://ix.io/3Ilx
09:29:03PMunchAah, apparently it's from everything which happens to call runOnce, which is pretty much everything in async
09:29:06FromDiscord<hieu.nt> (edit) "long message," => "code paste," | "http://ix.io/3Ilx" => "https://play.nim-lang.org/#ix=3Ily"
09:29:46*jmdaemon joined #nim
09:30:14FromDiscord<hieu.nt> the issue is: per google api for deleting file "If successful, this method returns an empty response body."
09:30:16PMunchThat's still not a complete snippet
09:30:34PMunchI don't think that should be an issue
09:30:35FromDiscord<hieu.nt> only then it throws an error if it successfully delete a file
09:30:54FromDiscord<hieu.nt> it it fails to delete a file, let resultStr = await resp.bodyStream.readAll()
09:30:59FromDiscord<hieu.nt> then this run and there is no error
09:31:16FromDiscord<enthus1ast> we need the full snipped that we see how you call the connect\_and\_delete\_all\_files proc
09:31:38PMunchHmm, I guess maybe resp.bodyStream.readAll() doesn't register anything if the bodyStream doesn't have any data, and then await errors out that nothing is register
09:31:42PMunchBut that seems odd
09:32:17FromDiscord<hieu.nt> the way i call it is:
09:32:33FromDiscord<hieu.nt> when isMainModule:
09:32:44FromDiscord<hieu.nt> waitfor connect_and_delete_all_files()
09:34:20PMunchWhere do you get `readAll` from?
09:34:27PMunchIt's not defined in asyncstreams..
09:35:30FromDiscord<hieu.nt> import asyncdispatch, cgi, httpclient, json, jwt, os, streams, strformat, times, strutils
09:35:34FromDiscord<hieu.nt> full import
09:35:45FromDiscord<hieu.nt> (edit) "import asyncdispatch, cgi, httpclient, json, jwt, os, streams, strformat, times, strutils" => "sent a code paste, see https://play.nim-lang.org/#ix="
09:36:26FromDiscord<hieu.nt> here is another snippet to upload to google drive, its almost the same
09:36:50FromDiscord<hieu.nt> sent a code paste, see https://play.nim-lang.org/#ix=3Ilz
09:37:03FromDiscord<hieu.nt> this one run successfully, never have any error
09:37:17PMunchHmm, I think this might be a bug with FutureStream when no data is written to the stream
09:38:01PMunchCould you try `deleteContent` instead of delete?
09:38:32FromDiscord<hieu.nt> not sure if it works for google drive, let me try
09:38:55*greyrat joined #nim
09:39:18*rwb joined #nim
09:39:21FromDiscord<hieu.nt> but i think you might be right about error with FutureStream
09:39:38FromDiscord<hieu.nt> sent a code paste, see https://play.nim-lang.org/#ix=3IlA
09:39:41*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
09:39:47FromDiscord<hieu.nt> because the code works when it has error deleting file
09:40:10FromDiscord<hieu.nt> for example resp.status returns 404 No Permission or something like that
09:40:46FromDiscord<hieu.nt> but when it succeeds, it throws "no handles or timers registered ..."
09:41:01FromDiscord<hieu.nt> because there is no body response from google api
09:43:10PMunchHmm, it's not immediately obvious though where the error is
09:43:13*jmdaemon joined #nim
09:43:23FromDiscord<enthus1ast> could it be that the parseJson excepts but it is not catched and leaks to the waitFor?
09:43:38FromDiscord<enthus1ast> not sure what happens then
09:44:07PMunchI don't think so
09:44:15PMunchI mean this is where the error is raised: https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncdispatch.nim#L360-L362
09:44:19FromDiscord<enthus1ast> i would try to wrap all parseJson in an try except anyhow
09:44:35PMunchAnd that is called from various parts of the async libraries
09:46:41FromDiscord<hieu.nt> In reply to @enthus1ast "i would try to": i tried that. It doesnt fall into the try except block
09:46:44*stkrdknmibalz quit (*.net *.split)
09:46:44*nrds quit (*.net *.split)
09:46:44*cornfeedhobo quit (*.net *.split)
09:46:44*nisstyre quit (*.net *.split)
09:46:44*greyrat_ quit (*.net *.split)
09:46:44*rb quit (*.net *.split)
09:46:57FromDiscord<hieu.nt> it throws error before that
09:47:40FromDiscord<hieu.nt> anyhow, i search around and see there are some workarounds with adding dummy timer
09:47:57FromDiscord<hieu.nt> any idea how can do that ?
09:48:27PMunchI think you rather want to check the error like you did
09:48:41PMunchOr even read the Content-Length header, and if it's 0 just don't call readAll
09:49:24FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3IlD
09:49:36FromDiscord<hieu.nt> let resp = await client.delete(url)
09:50:11FromDiscord<hieu.nt> it dies before it gets to await
09:50:30FromDiscord<hieu.nt> so i cannot read anything from the resp
09:51:20FromDiscord<hieu.nt> i only call readAll() it fails
09:51:22FromDiscord<hieu.nt> if(resp.status != success_status):
09:51:52*nisstyre joined #nim
09:51:59PMunchWait, it fails already at the delete call?
09:52:13FromDiscord<hieu.nt> yes
09:52:30*Colt quit (Remote host closed the connection)
09:52:48PMunchSo if you do `let deleteFut = client.delete(url); let resp = await deleteFut` it fails on the second line?
09:52:57*Colt joined #nim
09:53:01FromDiscord<hieu.nt> the echo doesnt print
09:53:01FromDiscord<hieu.nt> sent a code paste, see https://play.nim-lang.org/#ix=3IlE
09:53:16FromDiscord<hieu.nt> error is thrown
09:54:03PMunchHmm, can you boil this down to a minimal example?
09:54:54PMunchPreferably not actually calling the Google APIs, but rather trying to call a small Jester API that behaves the same way
09:55:31*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
09:57:48*cornfeedhobo joined #nim
09:58:51FromDiscord<hieu.nt> wait my bad, i think might know what the errors are from
09:58:52FromDiscord<hieu.nt> let resultStr = await resp.bodyStream.readAll()
09:59:02FromDiscord<hieu.nt> this line, when bodyStream is empty
09:59:10FromDiscord<hieu.nt> it throws error
09:59:43FromDiscord<hieu.nt> there are some other error status from Google when it returns an empty response body.
10:00:00FromDiscord<hieu.nt> i think i just have to make a better nulll/empty check
10:00:08FromDiscord<Elegantbeef> Should you use `finished` or `failed` on the body stream?
10:01:18FromDiscord<hieu.nt> In reply to @Elegantbeef "Should you use `finished`": how can i do it ? still pretty new to Nim
10:02:16PMunch`readAll` is basically a loop which calls `read` which in turn should call `finished`
10:02:32PMunchThat's why I said it wasn't obvious where the error came from
10:03:21PMunchBut yeah, the error coming from `await resp.bodyStream.readAll()` was the only thing I could get to make sense
10:03:29PMunchBut it's not obvious why this errors out
10:04:11FromDiscord<Elegantbeef> Well `.bodyStream` doesnt run any code so awaiting it probably kicks the dispatcher in and as there are no async procs waiting it poops the bed?
10:04:19FromDiscord<Elegantbeef> You know async better than i so i dont know
10:04:30FromDiscord<Elegantbeef> Just a guess based off the code and error
10:04:51PMunchBut he awaits readAll, not bodyStream
10:05:12FromDiscord<Elegantbeef> Ah right
10:07:25FromDiscord<enthus1ast> just tried it, it reads empty body just fine
10:07:40FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3IlK
10:07:54FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3IlL
10:09:38FromDiscord<hieu.nt> so specifically, it fails when the status is 204 No Content
10:10:19FromDiscord<hieu.nt> i mean it throws the "no handles or timers registered"
10:10:35FromDiscord<hieu.nt> i remove the whole resp.bodyStream.readAll()
10:10:45FromDiscord<hieu.nt> and it doesnt throw error anymore
10:12:28PMunchYeah I think I found the error
10:12:33FromDiscord<hieu.nt> "Although this status code is intended to describe a response with no body, servers may erroneously include data following the headers." From firefox
10:12:34PMunchGive me a sec to check it out
10:12:47PMunchThat shouldn't be an issue
10:13:35FromDiscord<enthus1ast> it seems to be though
10:14:02FromDiscord<enthus1ast> returning Http204 makes the client stuck in my example
10:14:57FromDiscord<enthus1ast> so this\:↵ resp Http204, ""
10:15:29PMunch@enthus1ast, yeah and if you turn it into a proc with {.async.} and replace your waitFors with await then you get the same error
10:16:15FromDiscord<enthus1ast> yeah
10:16:45FromDiscord<enthus1ast> so then @hieu.nt do a↵`if resp.status == Http200:`
10:17:24PMunchThen it should work
10:19:08*xet7 joined #nim
10:20:28PMunchI believe the error is here: https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/httpclient.nim#L861
10:20:57PMunchOr rather reading from a stream with Http204 is an error, but it should be a better error than just making asyncdispatch freak out..
10:24:08FromDiscord<hieu.nt> thanks guys really appreciate all the help
10:38:35FromDiscord<dom96> Please be sure this is reported on GitHub 🙂
11:20:43NimEventerNew thread by Xigoi: How would this endianness check be translated to Nim?, see https://forum.nim-lang.org/t/8711
11:48:42FromDiscord<valerga> any idea why this code is still running after minutes of execution? https://play.nim-lang.org/#ix=3IlW
11:48:48FromDiscord<valerga> what's the bottleneck?
11:49:44FromDiscord<impbox [ftsf]> enable profiler
11:50:35FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/estp.html
11:50:53PMunchSo hard to help people without getting AoC spoilers :(
11:51:42FromDiscord<valerga> oh :d
11:52:04FromDiscord<impbox [ftsf]> oh yeah, if you're asking questions about aoc stuff, do it in the aoc channel and use spoiler tags
11:52:26PMunchAaah, that's what people are doing in the AoC channel?
11:52:34PMunchThose don't really come through to IRC :P
11:53:19FromDiscord<impbox [ftsf]> well I guess the IRC client doesn't render them the same?
11:53:46PMunchIt shows them as two pipes :P
11:54:06FromDiscord<impbox [ftsf]> yeah, i'm pretty sure that's what people are typing to do them
11:54:20FromDiscord<impbox [ftsf]> client would just need to render it as markdown or whatever
11:57:12FromDiscord<valerga> will the profiler work if I stop in mid execution?
11:58:34PMunch@dom96, @hieu.nt, issue and PR to fix it: https://github.com/nim-lang/Nim/issues/19253
12:06:01*supakeen quit (Quit: WeeChat 3.3)
12:06:31*supakeen joined #nim
12:16:02FromDiscord<dom96> cool, thx
12:16:58FromDiscord<Forest> Anyone know how I'd implement a dynamic programming language in Nim? Any tools i can use?
12:17:44PMunchNot quite sure what you mean
12:17:54PMunchIf you want to write your own language in nim then it's just to start writing
12:18:13PMunchNothing special about writing a language compared to writing any other pgroam
12:19:38FromDiscord<Forest> I'm trying to reimplement python, and i have no idea where to start, this is a brand new field to me and I'm just confused lol, i know i need to work on a lexer but don't know how to begin implementing one in Nim
12:20:25FromDiscord<enthus1ast> you could have a look at\:↵https://nim-lang.org/docs/lexbase.html
12:20:31FromDiscord<enthus1ast> and also nimja's lexer
12:20:40FromDiscord<Forest> How did that not come up in google- thanks!
12:20:49FromDiscord<enthus1ast> https://github.com/enthus1ast/nimja/blob/master/src/nimja/lexer.nim
12:21:06FromDiscord<Forest> Nimja?
12:21:47FromDiscord<Forest> Thanks!
12:22:52FromDiscord<enthus1ast> there are also a few others more complete langs written in nim
12:24:01FromDiscord<enthus1ast> [haxscramper](https://matrix.to/#/@haxscramper:matrix.org)\: has a nice gist where he has collected links for nim language development
12:24:03FromDiscord<enthus1ast> https://gist.github.com/haxscramper/3562fa8fee4726d7a30a013a37977df6
12:27:12FromDiscord<Forest> In reply to @enthus1ast "there are also a": Ooh neat!
12:31:57FromDiscord<Forest> htsparse looks really neat and useful 👀
12:33:25FromDiscord<enthus1ast> i would recommend that you write your own stuff first (does not have to be great or complicated) so that you get a feeling for lexing and parsing stuff
12:33:55FromDiscord<enthus1ast> eg write a toy assembler and a virtual machine
12:34:37*jjido joined #nim
12:34:38*jjido quit (Client Quit)
12:34:44FromDiscord<enthus1ast> super easy parsing and lexing but requires roughly the same skills as with a full lang
12:36:29FromDiscord<Forest> Fair enough aha
13:01:42*src joined #nim
13:05:34PMunchHmm, is it possible to create a type which is different across modules? Might sound weird but I was thinking of TaintedString and came up with an idea for CleanString. CleanString would be a `static string or currentModule.EscapedString`, so string literals and other compile-time strings are fine, but if you want to use a runtime string you need to escape it. But I only want the `escape` procedure for module X to work for procedures accepting a CleanString in
13:05:34PMunchmodule X and not procedures accepting a CleanString in module Y.
13:06:46PMunchSo essentially `X.escape(input: string): X.EscapedString` and `X.someProc(arg: CleanString)` there I want CleanString to be `static string or X.EscapedString`
13:07:32PMunchBut I want to define CleanString generically
13:22:40FromDiscord<vindaar> use a `concept` that requires the `escape` proc and returns some type defined in the module (which then still must use a different name of course). You can call the concept `CleanString` though and you get the usage you want I think
13:22:55*noeontheend joined #nim
13:24:11PMunchI thought about that, but you I can't think of a way to write a concept that allows `escape` to take a string and return a module-specific type
13:27:19*noeontheend quit (Ping timeout: 252 seconds)
13:29:04*rockcavera joined #nim
13:29:05*rockcavera quit (Changing host)
13:29:05*rockcavera joined #nim
13:36:59FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=3ImS
13:40:46PMunchAah, yeah that works
13:43:56*arkurious joined #nim
13:45:31PMunchYup, seems to work fine: http://ix.io/3ImV/
13:46:22FromDiscord<vindaar> nice!
13:57:16*lumo_e joined #nim
14:03:15PMunchIf you couldn't tell I'm looking at how TaintedString failed, and what other alternatives we could use, spurred on by the Log4Shell exploit
14:03:25PMunchAfter all it's basically just SQL-injection all over again
14:03:29PMunchJust 10x worse :P
14:04:49PMunch@dom96, I think that's the fastest bug discovery -> merged to devel time I've ever had :P
14:05:45FromDiscord<dom96> 😄
14:05:54FromDiscord<dom96> Glad to hear it 🙂
14:09:07*rockcavera quit (Remote host closed the connection)
14:13:52*lumo_e quit (Quit: Quit)
14:32:30*xet7 quit (Remote host closed the connection)
14:42:10FromDiscord<retkid> so uh
14:42:17FromDiscord<retkid> i wanted to compile only a single
14:42:19FromDiscord<retkid> (edit) "single" => "single..."
14:42:24FromDiscord<retkid> (edit) "single..." => "single proc"
14:42:31FromDiscord<retkid> so i deleted all the other code
14:42:38FromDiscord<retkid> well that was a week ago
14:42:41PMunchPlease try to avoid editing your messages too much..
14:42:58PMunchEditing creates a new message on platforms that don't support edits
14:43:14FromDiscord<retkid> that is unfortunate, sorry
14:43:20PMunchNo worries :)
14:43:38FromDiscord<retkid> but yea i lost 500 lines of code
14:44:09PMunchYou didn't have it in a Git repo?
14:44:22FromDiscord<retkid> i write my code locally
14:44:32PMunchYou can have local Git repos
14:44:37PMunchWithout a remote
14:44:50PMunchIt's a great way to avoid losing 500 lines of code
14:44:59FromDiscord<retkid> its fine the code was bad anyway
14:45:04FromDiscord<retkid> but im not rewriting i
14:45:06FromDiscord<retkid> (edit) "i" => "it"
14:45:22FromDiscord<retkid> so i guess I'll just suck a fat chode
14:46:22PMunchAgain, git is your friend :)
14:46:59PMunchIt also means you can roll back stuff, create branches, bisect, and just generally enjoy all the features git provides
14:47:18PMunch(And if you get used to it you get really good at using Git, which is always handy)
14:48:40FromDiscord<retkid> wait a second
14:48:44FromDiscord<retkid> i have a backup
14:49:22FromDiscord<retkid> I might setup a master git just in my dev folder
14:49:47FromDiscord<retkid> so i only have to do it once
14:55:22*nrds joined #nim
15:05:39FromDiscord<planetis> which syntax looks better? `for i in traverse(x, {&quot;emp_data&quot;: JArray, &quot;employee&quot;: JObject, /&quot;name&quot;: JString}):` or `for i in traverse(x, (JArray, &quot;emp_data&quot;) (JObject, &quot;employee&quot;) / (JString, &quot;name&quot;)):` ?
15:06:18*PMunch quit (Quit: Leaving)
15:08:21FromDiscord<planetis> which syntax looks better? `for i in traverse(x, (JArray, "emp_data") (JObject, "employee") / (JString, "name")):` or `for i in traverse(x, {"emp_data": JArray, "employee": JObject, /"name": JString}):`
15:21:37FromDiscord<Solitude> yes
15:26:35FromDiscord<IsaacPaul> use triple back ticks please lol
15:28:39FromDiscord<IsaacPaul> The first one. In the second the quote looks like it's escaped and could cause confusion.. Honest it is all a bit confusing because you're applying math operations to data and strings, so It all doesn't make much sense.
15:44:37FromDiscord<planetis> you have a point, supposedly ["emp\_data", "employee", "name"] is a path to a json node the / between means direct child and \ it can be any.
15:45:05FromDiscord<planetis> to be sure, you mean the one with {} is better?
15:45:56FromDiscord<planetis> I am also trying to encode that "emp\_data" field is of kind JArray and stuff
15:49:25FromDiscord<hmmm> yo nimlets how can I redirect an echo to a file
15:50:07FromDiscord<planetis> echo is for debug use the write procs
15:51:01FromDiscord<hmmm> 😦
15:51:44FromDiscord<hmmm> and if I wanted to redirect an echo to a var?
15:52:40FromDiscord<planetis> what? you pbl have in mind `cin >> a` ?
16:12:48FromDiscord<Fish-Face> I have a type alias for an array type and want to re-initialise the variable. Is there a simple way to do this? existingVariable = MyArrayType() does not work as it would if it were an object type
16:25:36FromDiscord<planetis> maybe `a = default()` works
16:29:44FromDiscord<IsaacPaul> In reply to @hmmm "yo nimlets how can": echo goes to `stdout` I believe you can redirect it to a file: https://stackoverflow.com/questions/29154056/redirect-stdout-to-a-file
16:30:04FromDiscord<IsaacPaul> There maybe a nim / easier way tho
16:31:37FromDiscord<hmmm> oh I was looking for something like that do we have a freopen() in nim?
16:33:28FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3IoM
16:36:03FromDiscord<IsaacPaul> It always helps to just have the nim source code open lol
16:36:27*rockcavera joined #nim
16:36:27*rockcavera quit (Changing host)
16:36:27*rockcavera joined #nim
16:37:59FromDiscord<planetis> do you just meant to do `./myprogram > output.txt` ?
16:40:33FromDiscord<hmmm> nay I have a blackbox library that spits in echo or stdout and I wanted to capture the spit 🤔
16:53:54FromDiscord<eyecon> What is the most idiomatic way to convert from a string o a built-in `set` of `char`s?
16:54:32FromDiscord<eyecon> I.e. `"abcdabc".convert() == {'a','b','c','d'}`
16:54:53FromDiscord<eyecon> (edit) "o" => "into"
16:58:22FromDiscord<Hamid_Bluri> In reply to @eyecon "I.e. `"abcdabc".convert() == {'a','b','c','d'}`": https://nim-lang.org/docs/setutils.html#toSet.t%2Cuntyped
16:58:58FromDiscord<eyecon> Ah, setutils, good to know, thanks a lot @Hamid_Bluri
16:59:28FromDiscord<Hamid_Bluri> actually thanks to pmunch 😄
17:02:45FromDiscord<Hamid_Bluri> since when we can write `13u8` instead of `13'u8` ?
17:05:16FromDiscord<Hamid_Bluri> where is github page of https://nim-lang.org/docs/manual.html
17:05:18FromDiscord<Hamid_Bluri> ?
17:05:29FromDiscord<Hamid_Bluri> (edit) "page" => "repo"
17:16:41FromDiscord<konsumlamm> `13u8` worked since before `13'u8` iirc
17:17:02FromDiscord<konsumlamm> however `13'u8` is more consistent with user defined literals
17:17:39FromDiscord<konsumlamm> In reply to @hamidb80 "where is github repo": there's literally a source link at the top
17:40:39*fputs3 joined #nim
17:42:09*fputs quit (Ping timeout: 252 seconds)
17:42:09*fputs3 is now known as fputs
17:47:41FromDiscord<retkid> so what if instead of generating JS manually, it creates a map of the nim compiled code to its c functions that see which c functions are called by JS and then approximates it to the JS
17:47:48FromDiscord<retkid> hopefully that makes sense
17:48:02FromDiscord<retkid> go to JS via their common link
17:48:45FromDiscord<retkid> IE nim rand goes to C rand and so does JS rand so does JS rand, so then you use the function which goes to the same function you do
17:49:05FromDiscord<retkid> ((idk if nim goes to C rand im just thinking of an example))
18:30:10*xet7 joined #nim
19:05:43FromDiscord<Michal58> In reply to @konsumlamm "however `13'u8` is more": What is the reason for the apostrophe anyways?
19:21:17*Guest58 joined #nim
19:21:32FromDiscord<konsumlamm> makes it clear that it's calling a routine
19:21:37FromDiscord<konsumlamm> also looks better imo
19:26:02*Guest58 quit (Client Quit)
19:27:03*xet7 quit (Quit: Leaving)
19:44:05FromDiscord<IsaacPaul> It's calling a routine?
19:44:34*jmdaemon joined #nim
19:50:22FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3Iqc
19:51:06FromDiscord<IsaacPaul> Or maybe the routine resolves into a cast?
19:56:12*neurocyte0132889 joined #nim
20:19:39FromDiscord<konsumlamm> well, u8 is special cased, it's calling a routine for user defined suffixes
20:34:36FromDiscord<IsaacPaul> https://github.com/nim-lang/RFCs/issues/216 ah ok I didn't know nim did that
20:37:51FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3Iqx
20:38:21FromDiscord<IsaacPaul> but I'm just nitpicking at this point
20:42:10*xet7 joined #nim
20:48:29NimEventerNew question by How2: Pythonic string.replace() in Nim?, see https://stackoverflow.com/questions/70355338/pythonic-string-replace-in-nim
20:49:10FromDiscord<konsumlamm> In reply to @IsaacPaul "But if you look": i literally told you that u8 is special cased
20:50:42FromDiscord<IsaacPaul> I guess I misunderstood you 🙂
21:10:48NimEventerNew thread by Miran: Release candidates for Nim 1.6.2 and 1.2.16, see https://forum.nim-lang.org/t/8712
21:12:17FromDiscord<hmmm> o boi we got new stuff?
21:12:36FromDiscord<hmmm> what kind of new stuff we got 😋
21:14:10*rwb is now known as rb
21:17:33FromDiscord<impbox [ftsf]> Mmm a changelog would be nice to include in these posts
21:52:52*tiorock joined #nim
21:52:52*tiorock quit (Changing host)
21:52:52*tiorock joined #nim
21:52:52*rockcavera is now known as Guest3263
21:52:52*Guest3263 quit (Killed (molybdenum.libera.chat (Nickname regained by services)))
21:52:53*tiorock is now known as rockcavera
21:59:10*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
22:01:32*Lord_Nightmare joined #nim
22:15:21FromDiscord<ynfle (ynfle)> I'm trying to make a minimal docker image for nim without nimble and stuff like that. Can someone help me? I get this error when copying `/nim/lib/` from `1.6.0-alpine-regular`
22:15:30FromDiscord<ynfle (ynfle)> /nim/lib/pure/json.nim(162, 16) Error\: cannot open file\: tables
22:15:40FromDiscord<ynfle (ynfle)> So it at least has some stuff
22:46:31*krux02 joined #nim
23:19:11*noeontheend joined #nim
23:27:51*noeontheend quit (Remote host closed the connection)
23:28:49*noeontheend joined #nim
23:29:38*src_ joined #nim
23:30:24*noeontheend quit (Client Quit)
23:30:37*noeontheend joined #nim
23:33:14*src_ quit (Client Quit)
23:33:25*src quit (Ping timeout: 256 seconds)
23:33:25*src_ joined #nim
23:45:11NimEventerNew thread by Parra: Using C, C#, Java, Wasm, Ruby, Python NodeJS, TypeScript... libraries from Nim with MetaCall, see https://forum.nim-lang.org/t/8713
23:52:48*krux02 quit (Remote host closed the connection)