<< 07-12-2022 >>

00:03:39*dtomato4 quit (Quit: Ping timeout (120 seconds))
00:03:56*dtomato4 joined #nim
00:57:01FromDiscord<exelotl> I guess it's about preserving the good ergonomics of having 1 string type that everyone agrees on
00:57:08*neceve joined #nim
00:58:24FromDiscord<Elegantbeef> Think it was more that "no one needs strutils to be fast"
00:58:36FromDiscord<Elegantbeef> But i dont know
01:00:57FromDiscord<Elegantbeef> I dont see how it impedes though↵(@exelotl)
01:01:04FromDiscord<Elegantbeef> `openarray[char]` accepts `string`
01:02:44FromDiscord<Elegantbeef> The simple fact is that `openarray[char]` works on `array[char]` `seq[char]` `cstring` and `string` means it's just the best
01:03:12FromDiscord<Yepoleb> is string something different than just a renamed seq[char] internally?
01:03:47FromDiscord<Elegantbeef> Yes
01:03:51FromDiscord<Elegantbeef> It's a null terminated `seq[char]`
01:24:53FromDiscord<Goat> I completely forgot NimScript was a standalone thing that I could use instead of compiling these very small programs
01:28:10FromDiscord<Goat> sent a code paste, see https://play.nim-lang.org/#ix=4hVU
01:34:30FromDiscord<Elegantbeef> The compile times arent much for these small one-offs in my experience
01:37:47FromDiscord<exelotl> yeah nim is generally preferable to nimscript even for quick and dirty scripts (just as easy to use, and you don't have to worry about nimscript's limitations)
01:43:02FromDiscord<exelotl> I use nimscript as a task runner for my library, to read user config, set compiler options, and run certain tools pre-and-post build, all in a single invocation of the compiler (well actually I guess there's 2 invocations because `selfExec` works like that...)
01:43:24FromDiscord<exelotl> but even for this purpose it's kind of annoying because it has no facilities to check when a file was last modified
01:49:08FromDiscord<Elegantbeef> Maybe one day all the wanted procedures will be properly interoped 😄
01:49:37FromDiscord<Elegantbeef> Or we just use libffi
01:55:19FromDiscord<Yepoleb> is it hard to implement?
01:59:58*sagax joined #nim
02:04:04FromDiscord<Girvo> Are there any good references/libraries/implementations for high-perf vectorisation instruction usage in Nim?
02:08:06FromDiscord<auxym> simd stuff? mratsim is probably the local expert, you can have a look at his libs. also treeform shared this recently, looks like they are using SIMD in the latest pixie version: https://www.youtube.com/watch?v=Did21OYIrGI
02:08:33FromDiscord<auxym> not aware of good references though, I still have no idea how this black magic works
02:08:35FromDiscord<Girvo> Yeah 🙂 Though in this case its the weird Tensilica Instruction Extension SIMD instructions, but they're pretty similar
02:09:23FromDiscord<Girvo> The LX6/LX7 GCC fork doesn't really do auto-vectorisation very well, and the ESP32-S3 has a tonne of useful instructions I want to take advantage of. I'll check out their stuff, cheers!
02:54:32FromDiscord<Girvo> https://github.com/guzba/nimsimd is what Treeform seems to use in Pixie, interesting
02:54:57FromDiscord<Girvo> I could add support for the TIE set to it, neat
03:11:05FromDiscord<Yepoleb> In reply to @Girvo "https://github.com/guzba/nimsimd is what Treeform": Guzba is also a pixie dev
03:20:41*arkurious quit (Quit: Leaving)
03:28:58FromDiscord<voidwalker> https://nim-lang.org/docs/asyncdispatch.html#withTimeout%2CFuture%5BT%5D%2Cint
03:31:58FromDiscord<voidwalker> calling withTimeout will get you a Future[bool] (owned, not sure what that is). How would I get the value of the Future then ? Like this ? https://github.com/waku-org/nwaku/blob/6811af328cfae8b23755faaf3a30dae5df15880e/tests/v1/test_waku_mail.nim#L49
03:32:11*ensyde joined #nim
03:33:14FromDiscord<voidwalker> Wouldn't be nicer if `withTimeout` wrapped the called Future's return value as well ?
03:45:24FromDiscord<Yepoleb> Just get the value from the future you wrapped
03:45:55FromDiscord<Yepoleb> At least i assume that's how it's intended to be used
03:46:45FromDiscord<voidwalker> yeah well I first have to assign it to another variable so that I can later read its value
04:25:55FromDiscord<Elegantbeef> It's for erroring
04:36:55FromDiscord<demotomohiro> @Girvo If there are no Nim libraries for simd instructions you want to use, I think you can import intrinsic functions in the same way as C functions if your C compiler provides intrinsic functions for simd.
04:39:38FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hWs
04:55:43FromDiscord<Girvo> In reply to @demotomohiro "<@823468778704076810> If there are": Yeah that's basically what I'm digging in to, it seems thats mostly what nimsimd does
04:57:27FromDiscord<Girvo> Though it seems the PIE instructions don't use intrinsics, more-so just straight assembly instructions!
05:00:01FromDiscord<Girvo> Whats the easiest way to find what intrinsics exist in a given GCC install?
05:01:41FromDiscord<Girvo> https://gcc.gnu.org/onlinedocs/gcc/Target-Builtins.html annoyingly the Xtensa stuff dosen't appear to be in here lol
05:03:34FromDiscord<Girvo> Oooh `-mdensity` will be useful. Unrelated to what I'm searching for, but useful
05:03:52FromDiscord<Girvo> To adjust my question then: are there any existing resources for handling assembly in Nim I should look at?
05:48:38*rockcavera quit (Remote host closed the connection)
05:54:09FromDiscord<Cheeseinator> i just found a really weird bug in nimpretty, every time it saves it doubles every indent, like it goes from 2 spaces to 4 and so on
05:55:39FromDiscord<ringabout> In reply to @Cheeseinator "i just found a": You mean like https://github.com/nim-lang/Nim/issues/21018
05:56:14FromDiscord<Cheeseinator> yeah
05:57:05FromDiscord<ringabout> You can add you case to the issue,
05:57:09FromDiscord<ringabout> (edit) "you" => "your"
06:04:03FromDiscord<Gumbercules> I don't think nimsimd uses the correct calling conventions in certain situations
06:04:24*ltriant quit (Ping timeout: 264 seconds)
06:04:34FromDiscord<Gumbercules> This is why I'm rolling my own simd linear algebra libt
06:04:42FromDiscord<Gumbercules> (edit) "libt" => "lib"
06:05:28FromDiscord<Gumbercules> Well, that among other reasons
06:19:08FromDiscord<Gumbercules> I guess `vmath` doesn't use `simd` which is another reason...
06:42:57*kenran joined #nim
06:44:35*kenran quit (Remote host closed the connection)
07:18:09FromDiscord<Gumbercules> seems that we're being increasingly forced into relying on exceptions
07:18:30FromDiscord<Gumbercules> looking at `std/json` there isn't a `parseJson` proc that doesn't raise....
07:20:30FromDiscord<Gumbercules> I guess I have to add another dependency to my project now...
07:24:21FromDiscord<voidwalker> speaking of exceptions, I haver never used them before. What is a good read about this subject ? I need to handle socket timeout in my code and no idea how to design it
07:25:51FromDiscord<Gumbercules> I only use exceptions when I am trying to deal with exceptional situations
07:26:03FromDiscord<Gumbercules> something I can expect to happen in my code that I am in control of - is not exceptional
07:26:11FromDiscord<voidwalker> I have this code to initialize connection `var (socket, connection_id) = await udpTrackerHello(tracker) ` - returns the connected socket with protocol initalization sent, and the connection_id
07:26:27FromDiscord<Gumbercules> if I'm dealing with an external service - like making HTTP requests to a server - I can't predict how the server will behave
07:26:33FromDiscord<Gumbercules> so in these situations exceptions make sense
07:26:42FromDiscord<Gumbercules> I don't need to use exceptions to handle errors from parsing JSON though....
07:27:10FromDiscord<voidwalker> Do I need to add a 3rd var to the tuple to handle the timeout ? Or do I use a magic value ? Or what kind of socket var to message it's not valid, as this is udp, so no .connected ?
07:27:44FromDiscord<voidwalker> Do I use the Option type (which I also never used) ? Or is there some special mehcanism to send exceptions between procs ?
07:27:56FromDiscord<Gumbercules> you can re-raise an exception
07:28:14FromDiscord<Gumbercules> maybe check out the tagged union library
07:28:19FromDiscord<Gumbercules> I find this a very nice way to deal with errors
07:28:26FromDiscord<Gumbercules> sorry the anonymous union lib I mean
07:28:36FromDiscord<Gumbercules> https://github.com/alaviss/union
07:30:19FromDiscord<voidwalker> but unions are already in nim, no ?
07:31:44FromDiscord<Gumbercules> tagged / discriminated unions / object variants are, and C-style unions are
07:32:00FromDiscord<voidwalker> welp, no idea about unions, never touched them
07:32:24FromDiscord<Gumbercules> anonymous unions are not and they can serve well for acting as an easy way to represent an error or lack of one
07:33:05FromDiscord<voidwalker> ok, so with exceptions, I have to do try: some code.. if bad condition: raise newException("blah blah"), and then except it ?
07:33:21FromDiscord<voidwalker> if I don't do except for it, I get a crash, right ?
07:35:19FromDiscord<Gumbercules> generally you will wrap some code that raises in a `try / except`
07:35:29FromDiscord<Gumbercules> in the `try` block you invoke whatever code potentially raises
07:35:41FromDiscord<Gumbercules> in the `except` block you deal with any exceptions which were raised
07:36:03FromDiscord<Gumbercules> there's an option `finally` block where you can do whatever else you might need to (closing file handles, etc...)
07:37:49FromDiscord<voidwalker> well the code I have does not raise anything. I use `withTimeout` proc to set a timeout to network event, and I want to "do something" when it times out
07:38:06FromDiscord<Gumbercules> sure you could raise there
07:38:39FromDiscord<voidwalker> simplest thing I could do, is just return an empty seq as result. Ideally I'd want the timeout signal to be passed along, for precision's sake, even though atm I have no use for this info
07:39:08FromDiscord<voidwalker> so I manually raise, and catch my raise.. that's funny
07:41:02FromDiscord<voidwalker> uhm, so then I do a `try myHelloProc` and `except` , in the proc that calls the timeout-able connection ?
07:41:27FromDiscord<Gumbercules> have you checked to see if the network call you're making doesn't already raise in the case of a timeout?
07:41:47FromDiscord<voidwalker> of course I did, sync sockets have built in timeout, async ones don't
07:42:06FromDiscord<voidwalker> withTimeout merely returns a bool
07:43:09FromDiscord<voidwalker> ok, let me give it a try and see what happens
07:43:51FromDiscord<voidwalker> I hope there's maybe a shorter solution with this.. otherwise all of my code will be full of try raise except:/
07:45:01FromDiscord<Gumbercules> don't use exceptions 🙂
07:45:15FromDiscord<voidwalker> use what then ?
07:46:06FromDiscord<Gumbercules> I'd have to see some code
07:46:07FromDiscord<voidwalker> maybe a macro can handle this timeout case in an uniform and shortened manner
07:46:33FromDiscord<Gumbercules> or at least have a better understanding of what procedures you're invoking and when
07:46:39FromDiscord<voidwalker> https://github.com/sgmihai/torrentim/blob/main/udp_tracker2.nim#L47
07:46:58FromDiscord<voidwalker> this is the state of the code now, no withTimeout, no error handling
07:48:01FromDiscord<Gumbercules> `withTimeout` says it returns a `Future[bool]` indicating whether it timed out or not
07:48:03FromDiscord<Gumbercules> isn't that enough?
07:52:37FromDiscord<voidwalker> well, I need to: 1. stop executing the rest of the proc as it's pointless. 2. return something to the caller proc to let it know we failed, and it should stop executing the rest of the code, and at least return @[] if not the fail itself
07:53:51FromDiscord<Gumbercules> so use an option type or anonymous union
07:54:04FromDiscord<Gumbercules> and then have an error enum or something
07:54:09FromDiscord<voidwalker> what would jesus (Araq) do ? : D
07:54:22FromDiscord<Gumbercules> Araq would probably use exceptions
07:54:51FromDiscord<voidwalker> I've no idea about the exception vs union consequences down the road
07:56:05FromDiscord<Gumbercules> https://flylib.com/books/en/2.254.1/stack_unwinding.html#:~:text=When%20an%20exception%20is%20thrown%20but%20not%20caught,to%20the%20statement%20that%20originally%20invoked%20that%20method.
07:57:05FromDiscord<Gumbercules> https://mattwarren.org/2016/12/20/Why-Exceptions-should-be-Exceptional/#:~:text=So%20we%20clearly%20see%20there%20is%20an%20extra,stack%2C%20the%20more%20work%20it%20has%20to%20do.
07:57:13FromDiscord<voidwalker> When an exception is thrown but not caught in a particular scope, the method-call stack is "unwound," and an attempt is made to catch the exception in the next outer try block. This
07:57:14FromDiscord<voidwalker> Ohhhhh
07:57:16FromDiscord<Gumbercules> Nim doesn't follow this advice - it uses exceptions everywhere
07:57:27FromDiscord<voidwalker> So I don't need to catch in the innermost proc.. otherwise it would not go further up
07:57:30FromDiscord<Gumbercules> well, in the stdlib anyawy
07:57:34FromDiscord<Gumbercules> (edit) "anyawy" => "anway"
07:57:38FromDiscord<Gumbercules> (edit) "anway" => "anyway"
07:57:50FromDiscord<Gumbercules> yeah but I mean - this doesn't always happen
07:58:43FromDiscord<voidwalker> so I guess a tracker has like a ~10+% chance of timeout or so, considering many torrents have trackers that have died, but their url is kept in the metadata for eternity
07:58:52FromDiscord<voidwalker> so not very exceptional
07:59:15FromDiscord<Gumbercules> it's more about the unpredictability of a certain error
07:59:20FromDiscord<Gumbercules> and how much control you have over what you're calling into
07:59:28FromDiscord<Gumbercules> timeouts are a good case for exceptions
07:59:46FromDiscord<Gumbercules> when it comes to something like calling out to a web server that you don't own
07:59:55FromDiscord<Gumbercules> or making a socket request to a server you don't control
08:00:11FromDiscord<Gumbercules> you have no idea how that external service is going to behave or what it will do, so the behavior you encounter may indeed be excpetional
08:00:24FromDiscord<Gumbercules> opening a file on your local filesystem - well you can pretty much guess every single error you might run into here
08:00:41FromDiscord<Gumbercules> these are not exceptional errors but instead very predictable ones and using exceptions is probably overkill
08:02:12FromDiscord<Gumbercules> same with parsing JSON which is what I originally made the comment about - I'd much prefer a `parseJson` overload that returns `nil` to being forced into exceptions (even though there are much better ways than to return `nil`)
08:02:31FromDiscord<voidwalker> timeout for torrent peers and torrent trackers is pretty common. I'd guess that at least 20%
08:03:26FromDiscord<Gumbercules> if you're already planning on blocking till the request times out or completes, I'd just inspect the returned future and then reuturn a value or an error
08:03:27FromDiscord<voidwalker> So if that article you linked has good advice, maybe exception is not the best idea
08:04:05FromDiscord<voidwalker> I wonder why "error" is not a built in return type for any proc
08:04:38FromDiscord<voidwalker> not sure how other languages do it.. as I don't have experience
08:04:57FromDiscord<Gumbercules> C lacks exceptions all together
08:05:29FromDiscord<Gumbercules> languages don't really dictate error handling patterns - they leave it up to the user
08:05:41FromDiscord<Gumbercules> most languages higher level than C feature exceptions
08:05:54FromDiscord<Gumbercules> but there's no reason you have to use them - it's not like it's forced on the programmer
08:06:10FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hX3
08:06:17FromDiscord<Gumbercules> `error` is not a built-in return type because not every call will produce an error
08:06:28FromDiscord<Gumbercules> pure functions cannot produce an error by definition
08:06:55FromDiscord<Gumbercules> I honestly don't think this is a bad place for exceptions
08:07:13FromDiscord<Gumbercules> even if the timeouts occur 20% of the time - you're still making a network request to a server you don't own
08:07:32FromDiscord<Gumbercules> the request might timeout - but you don't know why it timed out or the true reason for the failure, you just know your request timed out
08:08:54FromDiscord<Gumbercules> you shouldn't even need `withTimeout`
08:09:05FromDiscord<Gumbercules> according to async socket.sendTo - `If an error occurs an OSError exception will be raised.`
08:10:23FromDiscord<voidwalker> well, for sendTo udp, it's hard to get an error, maybe an OS error if there is no network at all or something
08:10:33FromDiscord<voidwalker> maybe fail to resolve
08:10:54FromDiscord<voidwalker> you get no error just sending data to a dead host
08:11:25FromDiscord<voidwalker> I think failing to resolve host will block it forever if I don't put timeout
08:11:58FromDiscord<Gumbercules> yeah - I've never used Nim's socket modules in the stdlib because tmk they're lacking
08:12:00FromDiscord<albassort> alright im back and asking for some assistance
08:12:10FromDiscord<albassort> how do i iterate over a carray
08:12:26FromDiscord<voidwalker> @Gumbercules what socket modules did you use then ?
08:12:31FromDiscord<albassort> ie a pointer to a single type which is actually an unchecked array of an unknown amount
08:12:34FromDiscord<Gumbercules> Enet
08:12:57FromDiscord<voidwalker> https://github.com/fowlmouth/nimrod-enet/ ?
08:13:10FromDiscord<Gumbercules> I wrapped it myself most likely but yeah
08:13:26FromDiscord<Gumbercules> I think treeform wrote a reliable upd socket lib but I can't speak to its correctness
08:13:50FromDiscord<voidwalker> yeah but with this "reliable" over udp, you expect both hots to use it, otherwise it's meaningless
08:13:59FromDiscord<albassort> because i have a ptr to an array of culong
08:14:00FromDiscord<Gumbercules> In reply to @albassort "ie a pointer to": cast it to a `ptr UncheckedAray[T]`?
08:14:02FromDiscord<voidwalker> so good for game server/client, useless otherwise
08:14:29FromDiscord<albassort> like that?
08:14:31FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hX4
08:15:40FromDiscord<Gumbercules> if it's a C array of unsigned longs then yes
08:16:10FromDiscord<albassort> alright so how do i convert it to a seq
08:16:16FromDiscord<albassort> i know the size
08:16:25FromDiscord<albassort> therapeutically... it is c
08:16:32FromDiscord<Gumbercules> @voidwalker pretty sure ENet's reliability feature is optional
08:16:39FromDiscord<albassort> (edit) "therapeutically..." => "theoretically c..."
08:16:51FromDiscord<albassort> beef said i need to alloc the size of the type
08:17:03FromDiscord<albassort> unless i misunderstood him
08:17:06FromDiscord<Gumbercules> `toOpenArray`
08:17:12FromDiscord<Gumbercules> then `toSeq`
08:17:28FromDiscord<Gumbercules> unless `toSeq` will accept a `ptr UncheckedArray[T]` but I dobut it
08:17:33FromDiscord<Gumbercules> (edit) "dobut" => "doubt"
08:18:05FromDiscord<albassort> ah
08:18:10FromDiscord<albassort> yep
08:18:14FromDiscord<albassort> thank [email protected]!
08:18:16FromDiscord<albassort> (edit) "[email protected]!" => "you!"
08:18:17FromDiscord<Gumbercules> np
08:18:23FromDiscord<Gumbercules> @voidwalker asyncnet doesn't work on windows either
08:18:29FromDiscord<voidwalker> what ? :\
08:18:44FromDiscord<Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hX5
08:19:09FromDiscord<Gumbercules> pretty sure on windows they're blocking
08:20:41FromDiscord<voidwalker> I understood that on windows you can't work with all the "layers" of the asyncnet lib on windows
08:20:49FromDiscord<voidwalker> meaning you only get the higher level one ?
08:20:57FromDiscord<Gumbercules> no
08:21:05FromDiscord<EchoPouet> In reply to @starch "how do i use": The sunset of Atom is very closed, use VSCode -> https://github.blog/2022-06-08-sunsetting-atom/
08:21:12FromDiscord<Gumbercules> Nim has no non-blocking sockets for Windows
08:21:15FromDiscord<Gumbercules> it's been like this for quite some time
08:22:00FromDiscord<voidwalker> oh :\
08:22:16FromDiscord<voidwalker> That is quite unfortunate... they gonna fix, no ?
08:22:37*pro joined #nim
08:22:44FromDiscord<voidwalker> hm actually, I don't believe this
08:22:47FromDiscord<Gumbercules> I believe you could get away with using - https://nim-lang.org/docs/nativesockets.html
08:22:49FromDiscord<voidwalker> proof : P
08:23:02FromDiscord<Gumbercules> but you're not going to be able to use anything in the net / async net packages
08:23:45FromDiscord<Gumbercules> fine if you don't want to believe me
08:23:46*pro left #nim (#nim)
08:23:51FromDiscord<Gumbercules> (edit)
08:23:56FromDiscord<voidwalker> I am pretty sure I would have read it somewhere by now, it's a pretty big thing
08:24:11FromDiscord<Gumbercules> well you didn't know about unions so...
08:24:24FromDiscord<Gumbercules> and you didn't know about stack unwinding and exceptions
08:24:34FromDiscord<Gumbercules> I've been using Nim since 2015
08:24:46FromDiscord<Gumbercules> I might know a thing or two about the stdlib...
08:24:49FromDiscord<voidwalker> i just googled and there is nothing about this :\
08:24:52FromDiscord<Rika> gumberbacca is right
08:25:08FromDiscord<Rika> at least from my own memory, i believe it is right
08:25:21FromDiscord<Gumbercules> In reply to @voidwalker "i just googled and": yeah well google doesn't hold all the answers all of the time
08:25:31FromDiscord<Rika> especially with nim stuff lol
08:25:43FromDiscord<Rika> most of the stuff is here in this discord server and that doesnt get indexed by google
08:25:47FromDiscord<voidwalker> I mean, araq uses windows afaik, surely he'd not allow such an important feature to not work on windows
08:25:52FromDiscord<Rika> and discord search is ass
08:26:14FromDiscord<Gumbercules> maybe stop comparing him to Jesus and you'll be less surprised when things don't work 🙂
08:26:35FromDiscord<Gumbercules> I believe core devs have been fine with - go out and roll your own socket solution / bind to some C lib
08:26:42FromDiscord<Gumbercules> which is what most folks have done
08:27:39FromDiscord<Gumbercules> https://gitter.im/nim-lang/Nim?at=5b8e432cf5402f32aad6233e
08:27:44FromDiscord<Gumbercules> I was able to find an old gitter convo pretty quick
08:30:55FromDiscord<Elegantbeef> Also araq uses mac
08:33:03FromDiscord<voidwalker> why didn't anyone help him install linux ? :\
08:33:14FromDiscord<Elegantbeef> It's an m1 mac
08:33:34FromDiscord<voidwalker> asahi linux
08:35:29FromDiscord<Elegantbeef> Until recently you had 0 gpu acceleration
08:37:40FromDiscord<Gumbercules> If I remember, fowl wrote some pretty nice macros for working with enet
08:38:27FromDiscord<Elegantbeef> \I just wish we could get optionals with semantics of exceptions
08:38:30FromDiscord<Gumbercules> https://github.com/fowlmouth/nimrod-enet/blob/master/pkt_tools.nim
08:39:28FromDiscord<Gumbercules> gd that repo has a `.babel` file
08:39:31FromDiscord<Gumbercules> I forgot about that shit....
08:39:59FromDiscord<Gumbercules> back when nim was all biblican
08:40:03FromDiscord<Gumbercules> (edit) "biblican" => "biblical"
08:40:14FromDiscord<Gumbercules> (edit) "biblical" => "biblican"
08:40:16FromDiscord<Gumbercules> (edit) "biblican" => "biblical"
08:40:27FromDiscord<Gumbercules> alright I can't type anymore, type for bed 😄
08:40:40FromDiscord<Elegantbeef> type for bed?
08:40:48FromDiscord<Gumbercules> see???
08:40:51FromDiscord<Elegantbeef> What is this a shitty text adventure game
08:40:53FromDiscord<Gumbercules> ugh
08:41:06FromDiscord<Gumbercules> pretty much describes my life
08:41:08FromDiscord<Gumbercules> shitty text adventure game
08:41:21FromDiscord<Rika> luk 0
08:53:29FromDiscord<voidwalker> so what is your opinion Elegantbeef, on handling socket timeouts ? Use exceptions ?
08:53:58FromDiscord<Elegantbeef> I personally like exceptions but it's likely not the 'correct' way of handling it
08:54:47FromDiscord<voidwalker> ah wait, status has an articole on it, ima read it first https://status-im.github.io/nim-style-guide/errors.html
08:56:14FromDiscord<albassort> whats the best way of taking someones code, chopping it up, and putting it in your code
08:56:17FromDiscord<albassort> on a git level
08:56:20FromDiscord<albassort> do i fork it?
08:56:23FromDiscord<albassort> do i just copy it and credit?
08:56:40FromDiscord<albassort> i usually copy it and credit
08:57:07FromDiscord<Elegantbeef> I generally say fork
09:04:27FromDiscord<voidwalker> status seems to like using this lib : https://github.com/arnetheduck/nim-result
09:04:57FromDiscord<Gumbercules> that's because `arnetheduck` works at status
09:05:13FromDiscord<Gumbercules> but I mean - it's probably good
09:05:23FromDiscord<Gumbercules> just have no experience using it
09:05:25FromDiscord<Elegantbeef> I still dislike results, so invasive
09:07:43FromDiscord<albassort> actually
09:07:59FromDiscord<albassort> im just gonna extract the guts and leave
09:08:09FromDiscord<albassort> HORIZON
09:08:10FromDiscord<Horizon [She/Her]> In reply to @Gumbercules "back when nim was": Biblical? How so?
09:08:13FromDiscord<albassort> HOW
09:08:15FromDiscord<albassort> HEWO
09:08:23FromDiscord<Gumbercules> the language was named Nimrod
09:08:23FromDiscord<albassort> they means it was old (?)
09:08:26FromDiscord<Elegantbeef> The name of the language was named nimrod the packagemanger babel
09:08:30FromDiscord<Gumbercules> the package manager was named babel
09:08:41FromDiscord<Elegantbeef> nimrod is the name of the 'first' king in the bible
09:08:42FromDiscord<albassort> i thought nimrod was a different thing
09:08:46FromDiscord<Horizon [She/Her]> In reply to @albassort "HEWO": Hi xD
09:08:50FromDiscord<albassort> HI XD
09:09:12FromDiscord<Horizon [She/Her]> In reply to @Gumbercules "the language was named": Aah i remember hearing that ages ago, didn't it need to ge tchanged cuz people got angry?
09:09:19FromDiscord<voidwalker> they should have kept it nimrom.. nim is so hard to search for on youtube
09:09:21FromDiscord<Horizon [She/Her]> get changed
09:09:22FromDiscord<Gumbercules> no
09:09:26FromDiscord<voidwalker> (edit) "nimrom.." => "nimrod.."
09:09:42FromDiscord<Gumbercules> well maybe - I don't know, if people were offended by the name of a biblical king I think they have bigger issues than the naming of a programming language
09:10:02FromDiscord<Gumbercules> I believe it was probably the connotation that nimrod means stupid person in the West
09:10:16FromDiscord<Horizon [She/Her]> Ah
09:10:37FromDiscord<Gumbercules> not because people were offended about the biblical references
09:10:41FromDiscord<Elegantbeef> I'm relatively anti-religion, and I just find it inane 😄
09:10:45FromDiscord<voidwalker> what's wrong with stupid ?
09:11:00FromDiscord<Gumbercules> well the old testament predates religion
09:11:08FromDiscord<Horizon [She/Her]> I don't really follow religion, keep it away from me and y'all are gucci 👍
09:11:10FromDiscord<Gumbercules> but it's neither here nor there really
09:11:21*disso_peach quit (Quit: Leaving)
09:11:27FromDiscord<Elegantbeef> "predates religion"
09:11:31FromDiscord<Gumbercules> I mean - it works both ways
09:11:32FromDiscord<Elegantbeef> Yea we're going to leave that there
09:11:51FromDiscord<Gumbercules> I mean there were no organized religions when the old testament was authored, there were cults
09:12:05FromDiscord<Gumbercules> but the concept of religion emerged later
09:12:18FromDiscord<Gumbercules> or at least organized religions
09:12:43FromDiscord<Gumbercules> what one thinks of when they think of modern day Christianity / Judaism / Islam etc
09:13:32FromDiscord<Gumbercules> tower of babel dates back to Mesopotamia
09:13:46FromDiscord<Horizon [She/Her]> I wonder how hard it'll be to implement a basic python interpreter in Nim ngl
09:14:12FromDiscord<Horizon [She/Her]> Shouldn't be too hard in theory? (Famous last words)
09:14:18FromDiscord<Gumbercules> and the Babylonian kings so yeah - very much a different thing
09:14:59FromDiscord<Gumbercules> probably as hard as it would be in any other language
09:15:00FromDiscord<Elegantbeef> Sure but i consider many thousands of people believing in a belief system a religious organisation
09:15:09FromDiscord<Horizon [She/Her]> In reply to @Gumbercules "probably as hard as": True
09:15:23FromDiscord<Elegantbeef> The old testament was only written in around 1000bce which isnt that far ago
09:15:23FromDiscord<Gumbercules> well it wasn't really a belief system then
09:15:46FromDiscord<Gumbercules> at least not according to theologians and historians
09:16:06FromDiscord<Gumbercules> Christianity had so many sects / cults back then
09:16:29FromDiscord<Elegantbeef> So many given it didnt even exist yet
09:16:32FromDiscord<Gumbercules> take the Gnostics for instance which is what I would classify my beliefs as being most closely aligned with
09:16:48FromDiscord<Gumbercules> well no one was running around calling it Christianity
09:17:17FromDiscord<Gumbercules> and many of the sects were persecuted by other sects that wanted their dogma to prevail
09:18:36FromDiscord<Gumbercules> the Gnostics were essentially snuffed out by the Christians who rose to power and founded the church
09:19:08FromDiscord<Gumbercules> and take the movie The Matrix for instance - it's steeped in Gnosticism but most wouldn't associate Christianity and religion with The Matrix
09:20:46*ltriant joined #nim
09:20:50FromDiscord<Elegantbeef> Sure but Ancient Greeks, Egyptians and Hinduism were established before or around the time Hebrews were also writing their book
09:20:58FromDiscord<Elegantbeef> So there was establish organised religion
09:21:02FromDiscord<Elegantbeef> But anyway this isnt Nim
09:21:05FromDiscord<Gumbercules> yeah
09:21:34FromDiscord<arkanoid> Nim is not religion? Sounds new to me
09:21:40FromDiscord<Gumbercules> I was a religious studies minor so I enjoy talking about it
09:22:07FromDiscord<Elegantbeef> It clearly is a religion a bunch of diluted individuals follow it's teachings and use it.
09:22:22FromDiscord<Gumbercules> when's the next crusade again?
09:22:35FromDiscord<Elegantbeef> I misplaced my chainmail you go on without me
09:22:55FromDiscord<Gumbercules> bout to burn some heathens
09:23:10FromDiscord<Elegantbeef> Nah keep them alive, can turn them into contributors
09:23:13FromDiscord<arkanoid> Writing AST in the heavens
09:28:45FromDiscord<Horizon [She/Her]> Used GitHub Actions to compile my Nim code for my website
09:29:48FromDiscord<Rika> wtf gumberbacca why tf you still awake
09:29:53FromDiscord<Rika> didnt you say it was type for bed
09:29:57FromDiscord<Gumbercules> yeah this is a good question
09:30:02FromDiscord<Gumbercules> it was and then it wasn't 😦
09:30:10FromDiscord<Rika> story of everyone's life
09:30:15FromDiscord<Rika> "im gonna sleep in a bit"
09:30:19FromDiscord<Rika> "just one more"
09:30:28FromDiscord<Rika> "itll be quick i promise"
09:30:37FromDiscord<Rika> and other lies we tell ourselves
09:30:41FromDiscord<Gumbercules> seriously closing the laptop now though, baby is probably going to wake up any minute and I am woefully unprepared
09:30:46FromDiscord<Gumbercules> cya all later
09:30:56FromDiscord<Rika> yes the baby will force you to know when to sleep
09:31:00FromDiscord<Rika> because otherwise you will never sleep
09:31:04FromDiscord<voidwalker> eek, added `try: ` block to handle shitty timeouts.. variables declared there are not visible outside the block :\
09:31:08FromDiscord<voidwalker> this is going to totally ruin my linecount
09:31:13FromDiscord<Rika> actually what am i saying you're never gonna sleep even if you wanted to
09:32:55FromDiscord<Horizon [She/Her]> In reply to @voidwalker "eek, added `try: `": Can't you just define them before the try block?
09:33:04FromDiscord<voidwalker> yeah +1 lines of code 😦
09:33:15FromDiscord<Horizon [She/Her]> Do they need to be visible outside the block?
09:33:21FromDiscord<Horizon [She/Her]> In reply to @voidwalker "yeah +1 lines of": Not that bad
09:33:31*ltriant quit (Ping timeout: 248 seconds)
09:33:38FromDiscord<Horizon [She/Her]> Could be worse
09:33:43FromDiscord<Horizon [She/Her]> ~~Like being JS~~
09:33:54FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXm
09:33:58FromDiscord<voidwalker> yeah but it totally defeats the purpose of using nim : P
09:34:20FromDiscord<voidwalker> could they not make a try variant that did not create a new scope ?
09:35:25FromDiscord<Horizon [She/Her]> In reply to @voidwalker "could they not make": Iirc i think defer did that? But is being removed because of the issues it causes
09:36:43FromDiscord<voidwalker> ok so I raise the exception in the `updTrackerHello` proce. I thought I did not need to catch it there, so that it gets pushed up the stack to the caller proc
09:36:57FromDiscord<voidwalker> where I have the try except.. but program just closes with the exception ?
09:37:16FromDiscord<voidwalker> Do I need to use that pragma for exceptions , raises?
09:37:16FromDiscord<Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4hXn
09:37:18FromDiscord<Horizon [She/Her]> Looks more readable imo
09:37:31FromDiscord<Horizon [She/Her]> In reply to @voidwalker "Do I need to": Nope but it's good for documentation
09:37:42FromDiscord<voidwalker> then what am I doing wrong ? :\
09:37:46FromDiscord<Horizon [She/Her]> I think so, at least (but it isn't needed)
09:38:02FromDiscord<voidwalker> do I need to catch it in all places so it does not crash the program?
09:38:05FromDiscord<Horizon [She/Her]> In reply to @voidwalker "where I have the": Maybe because the connection isn't handled properly?
09:38:35*anddam quit (Quit: WeeChat 3.7.1)
09:38:38FromDiscord<Horizon [She/Her]> In reply to @voidwalker "do I need to": Any places it may raise an error probably, but shouldn't be needed if it should be running without issue
09:38:42FromDiscord<voidwalker> well yeah, that's the whole idea, I am using an unresponsive host to test the timeout case
09:38:50FromDiscord<Horizon [She/Her]> Ah
09:39:21FromDiscord<voidwalker> which will happen a lot in a p2p program..
09:41:48FromDiscord<voidwalker> well, what do you know.. if I catch inside the inner/called proc, then there is no exception when it returns
09:42:45FromDiscord<voidwalker> ah nvm, I was writing the code in the wrong proc ;\
09:57:19FromDiscord<voidwalker> uhm, it seems that if I do `return` in the except block, the exception is not passed up. without return, it is. But if I don't return, the proc continues executing, encountering a real exception this time.
09:58:16*GreaseMonkey quit (Remote host closed the connection)
09:59:54*greaser|q joined #nim
10:00:21FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=
10:04:07FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXu
10:06:55FromDiscord<voidwalker> I shortened it to this, since I don't really need an except block if I'm only going to raise it again ?
10:07:02FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXv
10:07:43FromDiscord<voidwalker> but like this, it doesn't trigger the except in the calling proc. Unless I add a `raise` before return. But I have no except here, what is consuming it ? :\
10:23:26FromDiscord<Rika> thats fucked
10:23:27FromDiscord<Rika> lmao
10:37:47*disso_peach joined #nim
10:41:36*ltriant joined #nim
10:44:04NimEventerNew thread by drkameleon: Get time at compile-time, see https://forum.nim-lang.org/t/9698
10:47:08FromDiscord<voidwalker> well, code works, I am getting empty result all the way to the top. I certainly do not like the number of lines needed. certainly I am doing something wrong.
10:53:36FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXC
10:56:53FromDiscord<voidwalker> before having to add timeout, I had just `let resp = await socket.recvFrom(UDP_MAX_SIZE)`
11:04:40*jmdaemon quit (Ping timeout: 256 seconds)
11:14:31*neceve quit (Ping timeout: 268 seconds)
12:04:55FromDiscord<ghkdgfs> can you enumerate a openArray without using a for loop?
12:24:10FromDiscord<planetis> std/enumerate only works in loops
12:24:37FromDiscord<planetis> write your own, the way sequtils works
12:49:24*rockcavera joined #nim
12:51:17FromDiscord<juelix> I currently have an older version of nim installed and would like to install a newer version of nim. Is there any way to remove the old version of nim and install the new version of nim I am using windows 11.
12:55:51FromDiscord<fbpyr> @juelix\: I like chocolatey for keeping nim up to date on win
13:01:34FromDiscord<juelix> In reply to @fbpyr "<@996411185933066301>\: I like": I don't understand your reply to ...... Do you mean that chocolatey is a clue to my question? Or is it just a bunch of bot nonsense?
13:09:37FromDiscord<Rika> chocolatey is a package manager for windows
13:09:59FromDiscord<Rika> how did you first install nim
13:12:21FromDiscord<locria> Is there a `echo` that puts space in between?
13:13:27FromDiscord<juelix> In reply to @Rika "how did you first": Not an exact recollection, but maybe I installed from choosnim.
13:14:17FromDiscord<locria> In reply to @ghkdgfs "can you enumerate a": zero_functional
13:16:03FromDiscord<fbpyr> sorry, I should have typed the whole url\: https://chocolatey.org↵@Rika thx for hinting↵(@juelix)
13:18:55FromDiscord<fbpyr> @juelix\: so with that package manager one can install nim via powershell\:↵`choco install nim`↵listed here\: https://community.chocolatey.org/packages?q=nim↵to update all choco installed packages\: `choco upgrade all` - quite convenient. 😌
13:19:49FromDiscord<fbpyr> but I guess the official answer is `choosenim`↵(which funnily enough is also available via choco 😉 )
13:21:20FromDiscord<fbpyr> on a win-machine,↵● where I always want the latest I go choco -\> nim↵● if I want to be able to switch nim versions I woulg use choco -\> choosenim -\> nim
13:21:49FromDiscord<pmunch> If you first installed from choosenim then you simply run \`choosenim update stable\`
13:28:59FromDiscord<Require Support> for threading: is it still fine to use `spawn` or is there a newer/better way of doing things?
13:30:24*pro joined #nim
13:33:06*pro left #nim (#nim)
13:45:14NimEventerNew question by Andrea T.: Nim/Nimble: How to enable --threads:on only for files using it?, see https://stackoverflow.com/questions/74717623/nim-nimble-how-to-enable-threadson-only-for-files-using-it
14:09:40*anddam joined #nim
14:11:55FromDiscord<jtv> @locria I would assume the print macro from https://github.com/Yardanico/nimpylib would add in the space. Would be easy to do if not
14:17:28*derpydoo joined #nim
14:25:13FromDiscord<juelix> In reply to @fbpyr "sorry, I should have": Thanks to you and Rika for your kind and prompt replies! I was able to fix that problem!
14:25:29FromDiscord<Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hYt
14:25:43FromDiscord<Gumbercules> Not sure why you have it wrapped in one to begin with....
14:26:35FromDiscord<Gumbercules> In reply to @NimEventer "New question by Andrea": That's not how it works...
14:30:28FromDiscord<Gumbercules> The question should have been how do I build multiple binaries using nimble and only have one utilize threading.
14:31:53FromDiscord<Gumbercules> And the answer is - you probably can't unless your source resides in different directories. This is a nimble issue though....