00:06:45 | FromDiscord | <user2m> Is there an easy way to schedule a proc to execute at a later date and time? |
00:10:38 | FromDiscord | <polylokh_39446> if you're using async, there's addTimer that you could call with a calculated timeout |
00:11:41 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=UrNwtzpEZQdQ |
00:13:49 | * | def- quit (Quit: -) |
00:25:05 | FromDiscord | <leorize> it's all atomic and you can't turn that off↵(@bosinski2023) |
00:28:30 | * | gst quit (Ping timeout: 250 seconds) |
00:33:36 | * | def- joined #nim |
00:50:33 | FromDiscord | <threefour> In reply to @user2m "Is there an easy": Make it a server and have cron make a request to it? Or a standalone binary that is executed by cron. Unless you specifically want it contained within a single Nim program. |
00:54:17 | * | def- quit (Quit: -) |
00:54:44 | * | def- joined #nim |
00:59:32 | * | def- quit (Client Quit) |
01:00:22 | * | def- joined #nim |
01:07:40 | * | def- quit (Quit: -) |
01:25:16 | * | def- joined #nim |
01:44:16 | * | def- quit (Quit: -) |
01:44:59 | * | def- joined #nim |
02:02:18 | NimEventer | New Nimble package! nimsrvstat - A nim wrapper around mcsrvstat, see https://github.com/Minejerik/nimsrvstat |
02:06:36 | FromDiscord | <sharpcdf> what nim extension should i use for vscode? the nim-lang.org one doesnt show autocomplete for anything that isnt builtin even though i have the language server installed |
02:45:57 | FromDiscord | <_nenc> I think this one https://marketplace.visualstudio.com/items?itemName=NimLang.nimlang |
02:46:01 | FromDiscord | <_nenc> by nimsaem |
02:47:29 | FromDiscord | <_nenc> @sharpcdf |
02:50:23 | FromDiscord | <Elegantbeef> It's suggested to use the official one now |
03:08:24 | FromDiscord | <zumi.dxy> the tons of false "cannot evaluate at compile time" errors in my IDE make me sad |
03:16:17 | * | def- quit (Quit: -) |
03:16:48 | * | def- joined #nim |
03:28:26 | * | SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev) |
03:28:48 | * | SchweinDeBurg joined #nim |
03:30:09 | * | cnx quit (*.net *.split) |
03:30:10 | * | deadmarshal_ quit (*.net *.split) |
03:30:10 | * | Jjp137 quit (*.net *.split) |
03:35:32 | * | deadmarshal_ joined #nim |
04:37:01 | FromDiscord | <nikolay_a_k> sent a long message, see https://pasty.ee/jkVWHbgZaJwM |
04:39:43 | FromDiscord | <polylokh_39446> neat. I've got llama.cpp built, but didn't know there was such a simple API for it. |
04:51:42 | * | cnx joined #nim |
04:51:48 | * | Jjp137 joined #nim |
04:55:00 | * | def- quit (Quit: -) |
05:12:59 | * | def- joined #nim |
05:14:23 | FromDiscord | <Phil> Aaaaaand I'll have to implement async in rex simply because otherwise I can't implement the take operator |
05:15:41 | FromDiscord | <Phil> In reply to @nikolay_a_k "I managed to create": Cool to see! I'm still rather prone to declarative approaches, but this works nicely as well |
05:17:24 | * | def- quit (Client Quit) |
05:18:08 | * | def- joined #nim |
05:49:09 | * | def- quit (Quit: -) |
05:49:27 | * | def- joined #nim |
05:57:32 | FromDiscord | <odexine> In reply to @isofruit "Aaaaaand I'll have to": Well that was a requirement in the first place |
05:57:36 | FromDiscord | <odexine> Also I saw your ping yes |
06:05:16 | FromDiscord | <nocturn9x> okay so |
06:05:28 | FromDiscord | <nocturn9x> since my threading issues are related to sharing references across threads |
06:06:02 | FromDiscord | <nocturn9x> is there any way I could set an `Atomic[bool]` in one thread from the main thread without sharing references |
06:06:20 | FromDiscord | <nocturn9x> or, more generally, is there a safe way I can tell the other thread to stop |
06:06:24 | FromDiscord | <nocturn9x> channels, maybe? |
06:06:49 | FromDiscord | <nocturn9x> that still needs me sharing a reference though, doesn't it? Where else would I store the channel object |
06:08:05 | FromDiscord | <nocturn9x> ah, nim by example shows they're usually global variables |
06:08:53 | FromDiscord | <Elegantbeef> Pass in a `ptr bool` and just do `while myBool` 😄 |
06:09:17 | FromDiscord | <Elegantbeef> You can pass a `SharedPtr[Atomic[bool]]` if you want to go crazy |
06:09:25 | FromDiscord | <nocturn9x> that doesn't solve the problem |
06:09:32 | FromDiscord | <nocturn9x> because I still have a shared reference |
06:09:37 | FromDiscord | <Elegantbeef> No |
06:09:41 | FromDiscord | <nocturn9x> `SearchManager` |
06:09:48 | FromDiscord | <nocturn9x> unless I don't assign it in my thread function |
06:09:57 | FromDiscord | <nocturn9x> and just pass it the stop flag |
06:10:08 | FromDiscord | <Elegantbeef> Cause `ptr` is not managed |
06:13:08 | FromDiscord | <odexine> Reference is a very specific thing in Nim |
06:13:18 | FromDiscord | <odexine> Pointers don’t count as a reference |
06:13:21 | FromDiscord | <nocturn9x> I also have another shared ref but that can also be turned into a shared ptr |
06:13:34 | FromDiscord | <odexine> You shouldn’t turn references into pointers |
06:13:41 | FromDiscord | <nocturn9x> no, well |
06:13:45 | FromDiscord | <nocturn9x> I'll make it an object |
06:13:54 | FromDiscord | <nocturn9x> then allocate it on the heap as a shared ptr |
06:13:56 | FromDiscord | <nocturn9x> that was my point |
06:16:53 | FromDiscord | <morgan> can a template that takes in varargs of untyped pass all them to a proc that it also took in? |
06:17:34 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=gllGXsFxMbWx |
06:18:01 | FromDiscord | <morgan> hm wait actually the thing im thinking of wouldn't replace all instances of the pattern, so i might not bother |
06:21:42 | FromDiscord | <nocturn9x> In reply to @polylokh_39446 "what's the problem with": nothing, actually |
06:22:19 | FromDiscord | <polylokh_39446> seems like it has data races unfortunately, <https://github.com/nim-lang/Nim/issues/23174> |
06:22:26 | FromDiscord | <nocturn9x> lol rip |
06:22:40 | FromDiscord | <nocturn9x> do send/recv contain races |
06:22:52 | FromDiscord | <nocturn9x> ah nvm I can't use them cuz they block |
06:22:54 | FromDiscord | <nocturn9x> welp too bad |
06:23:01 | FromDiscord | <Elegantbeef> They have a `trySend` variation |
06:23:14 | FromDiscord | <Elegantbeef> The data race iirc was due to a "optimisation" attempting to early exit |
06:23:17 | FromDiscord | <polylokh_39446> if you're only waiting for a stop signal you can peek for it and then recv |
06:23:44 | FromDiscord | <nocturn9x> I'll try with using `SharedPtr` first |
06:23:59 | FromDiscord | <nocturn9x> since channels have to be global or passed via `ptr` anyway |
06:24:09 | FromDiscord | <polylokh_39446> In reply to @polylokh_39446 "if you're only waiting": provided the channels are unique to the peeking threads |
06:26:34 | FromDiscord | <nocturn9x> question |
06:26:43 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=WpgcuieGGjvd |
06:26:52 | FromDiscord | <nocturn9x> is that the correct way of initializing a shared ptr to the atomic |
06:26:58 | FromDiscord | <nocturn9x> will it outlive the constructor? |
06:27:02 | FromDiscord | <Elegantbeef> You don't need the `isolate` |
06:27:10 | FromDiscord | <nocturn9x> oke |
06:27:16 | FromDiscord | <Elegantbeef> isolate is purely for Nim's `ref` |
06:27:32 | FromDiscord | <Elegantbeef> `SharedPtr` uses destructors to do the same thing but with an atomic ref counter |
06:27:39 | FromDiscord | <nocturn9x> the question I have is |
06:27:46 | FromDiscord | <nocturn9x> since `searchFlag` is a local variable |
06:27:52 | FromDiscord | <nocturn9x> will the shared ptr keep it alive or nah |
06:28:09 | FromDiscord | <Elegantbeef> `newSharedPtr` manages it's own resources |
06:28:28 | FromDiscord | <Elegantbeef> It does not take an address to the data |
06:28:42 | FromDiscord | <nocturn9x> oh so it allocates a new thing |
06:29:00 | FromDiscord | <nocturn9x> oh it needs a type lol whatever then |
06:29:09 | FromDiscord | <nocturn9x> just `result.searching = newSharedPtr(Atomic[bool])` |
06:30:53 | FromDiscord | <Elegantbeef> `SearchManager(board: board, bestMoveRoot: nullMove(), ....)` is the nicer way of doing what you have there if you care |
06:32:21 | FromDiscord | <nocturn9x> hm okay |
06:40:53 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=edvqPcQAqCAF |
06:40:54 | FromDiscord | <nocturn9x> hmm |
06:41:07 | FromDiscord | <nocturn9x> the offending line is `session.transpositionTable[] = newTranspositionTable(session.hashTableSize 1024 1024)` |
06:41:20 | FromDiscord | <nocturn9x> it's just a warning, but still concerning |
06:43:45 | FromDiscord | <Phil> Okay async is kinda difficult given I can't assume an event-loop |
06:43:58 | * | def- quit (Quit: -) |
06:44:08 | FromDiscord | <Phil> (edit) "event-loop" => "async-loop" |
06:45:05 | FromDiscord | <nocturn9x> the way most Python async libraries do it |
06:45:10 | FromDiscord | <nocturn9x> is with a thread-local variable |
06:45:17 | FromDiscord | <nocturn9x> I believe it's also what asyncdispatch does |
06:45:24 | * | def- joined #nim |
06:45:27 | FromDiscord | <Phil> Oh I'm not implementing async |
06:45:38 | FromDiscord | <Phil> As in, fundamental async. I'm swapping procs to be async |
06:45:46 | FromDiscord | <nocturn9x> oh oke |
06:45:48 | FromDiscord | <Phil> For a reactive lib |
06:45:55 | FromDiscord | <nocturn9x> keep in mind async can byte ya |
06:45:58 | FromDiscord | <nocturn9x> (edit) "byte" => "bite" |
06:46:16 | FromDiscord | <nocturn9x> whenever you `await`, be ready for state to be potentially rearranged under your feet |
06:46:25 | FromDiscord | <Phil> You're telling that to somebody that wrote an async event-loop to be used by an actor thread, I am aware |
06:46:42 | FromDiscord | <nocturn9x> I wrote several event loops and it took me a while to get the SC design right |
06:46:55 | FromDiscord | <Phil> It is painful beyond belief, in this case though it's mostly a case of juggling who is async and who returns a subscription and how |
06:46:57 | FromDiscord | <nocturn9x> despite having trio as a reference |
06:47:50 | FromDiscord | <Phil> Like, rxjs gets away with not returning a promise/future and the like on the basis of an event loop always doing async work in the background |
06:48:07 | FromDiscord | <Phil> So you don't have to emit promises/futures that the user can await |
06:48:14 | FromDiscord | <Phil> I don't have that luxury |
06:48:34 | FromDiscord | <nocturn9x> In reply to @isofruit "Like, rxjs gets away": hmm |
06:48:49 | FromDiscord | <nocturn9x> How do you manage async units of work without some sort of awaitable or promise |
06:50:47 | FromDiscord | <odexine> observables are an extension of promises |
06:54:53 | * | GreaseMonkey quit (Remote host closed the connection) |
06:55:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=WdFAeNcXZzng |
06:55:55 | FromDiscord | <Phil> While waiting chronos will work through whatever async work it has in the dispatcher, which includes calling callbacks after promises complete etc. |
06:55:57 | FromDiscord | <nnsee> In reply to @nocturn9x "whenever you `await`, be": hey man, don't make promises you can't keep |
06:56:26 | FromDiscord | <nocturn9x> In reply to @nnsee "hey man, don't make": mfw `promise.cancel()` |
06:56:27 | FromDiscord | <odexine> lol |
06:56:46 | FromDiscord | <odexine> asyncdispatch actually doesnt have cancellable futures |
06:56:49 | * | greaser|q joined #nim |
06:56:54 | FromDiscord | <nocturn9x> laaame |
06:57:00 | FromDiscord | <odexine> chronos does tho |
06:57:04 | FromDiscord | <nocturn9x> async without cancelation is useless |
06:57:04 | FromDiscord | <odexine> therefore |
06:57:43 | FromDiscord | <Phil> But I can't really conceptualize what parts in this thing to put in promises |
06:57:49 | FromDiscord | <Phil> That's my biggest issue atm |
06:57:58 | FromDiscord | <odexine> ?>\ |
06:58:00 | FromDiscord | <odexine> wdym |
06:59:21 | * | ntat joined #nim |
06:59:30 | FromDiscord | <Phil> What part of the observable is a Future, which procs return futures, how do I set things up if I e.g. want to emit both a future and a non-future value (like subscribe - You might want an "unsubscribe" proc as well as a future to `waitFor` |
06:59:50 | FromDiscord | <Phil> (edit) "What part of the observable is a Future, which procs return futures, how do I set things up if I e.g. want to emit both a future and a non-future value (like subscribe - You might want an "unsubscribe" proc as well as a future to `waitFor` ... " added "to execute operations that should be happening when you subscribe" |
07:00:45 | FromDiscord | <nocturn9x> more segfaults |
07:00:51 | FromDiscord | <nocturn9x> _fucking hell_ |
07:01:01 | * | def- quit (Quit: -) |
07:01:08 | FromDiscord | <odexine> In reply to @isofruit "What part of the": maybe its because i just woke up but im not following |
07:01:30 | * | def- joined #nim |
07:02:20 | FromDiscord | <odexine> the observable itself is "like a future" |
07:02:28 | FromDiscord | <odexine> "which procs return futures"? |
07:02:41 | FromDiscord | <odexine> "how do I set things up if I e.g. want to emit both a future and a non-future value (like subscribe - You might want an "unsubscribe" proc as well as a future to waitFor to execute operations that should be happening when you subscribe" ????? |
07:02:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=AtEYStxwJsdY |
07:03:30 | FromDiscord | <Phil> If you want to make this async, well not `subscribeProc` needs to be async because your subscribeProc might include some timeout stuff, like sending a value after 3seconds |
07:03:52 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=ppYEpGZTtbEO |
07:03:57 | FromDiscord | <odexine> stop there |
07:04:12 | FromDiscord | <Phil> (edit) "not" => "now" |
07:05:05 | FromDiscord | <odexine> this is kinda why its complicated, since you're mixing asyncdispatch and your reactive library; i can't exactly quote any other libraries but if you had control over the evloop it would probably be simpler to implement |
07:05:28 | FromDiscord | <odexine> i'm saying observables are akin to futures, not that you can shoehorn in futures inside an observable |
07:05:29 | FromDiscord | <Phil> Not just probably, it would definitely be easier to implement because the user wouldn't need to get Futures |
07:05:31 | FromDiscord | <odexine> i dont know how that would work |
07:05:46 | FromDiscord | <Phil> They could just do their shit and the event-loop would run eventually |
07:05:53 | FromDiscord | <Phil> And I wouldn't need to take care of anything |
07:06:36 | FromDiscord | <Phil> But somebody, somewhere needs to waitFor futures |
07:06:50 | FromDiscord | <odexine> what |
07:08:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=aDArgLNKOFTf |
07:08:28 | FromDiscord | <Phil> And so far I didn't plan on that somebody being me |
07:09:03 | FromDiscord | <odexine> stop using the proc names as a standin for what you're intending |
07:09:14 | FromDiscord | <odexine> you mean that somewhere, the evloop has to be running |
07:09:56 | FromDiscord | <odexine> yes, that is true; rxjs obviously doesnt have this problem as it is inherent to js that an evloop is running |
07:10:54 | FromDiscord | <Phil> Only to a degree. It is not required to have a full blown event-loop, you can manually wait for async-work to be done if the package exposes the Futures to you that arise from your actions, like next returning e.g. a Future[void] that you can waitFor in order to trigger the changes. |
07:11:16 | FromDiscord | <Phil> That's why I'm talking about waitFor because that is the only technical necessity, not that you have a while-loop somewhere |
07:11:30 | FromDiscord | <Phil> (edit) "That's why I'm talking about waitFor because that is the only technical necessity, not that you have a while-loop somewhere ... " added "that regularly polls for async work" |
07:11:33 | FromDiscord | <odexine> now think of hot observable |
07:11:35 | FromDiscord | <odexine> (edit) "observable" => "observables" |
07:12:01 | FromDiscord | <Phil> I have, next would return also Future[void] as stated |
07:12:06 | FromDiscord | <Phil> Or would have to |
07:13:01 | FromDiscord | <odexine> what? |
07:13:02 | FromDiscord | <odexine> why? |
07:13:24 | FromDiscord | <Phil> Because your observers aren't required either to be sync |
07:13:34 | FromDiscord | <Phil> (edit) "Because your observers ... aren't" added "`next` callbacks" |
07:15:36 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=MxHRpKSiUvhq |
07:16:46 | FromDiscord | <Phil> Thus it must return a future that, when you `waitFor` it, triggers completing all the work in your callbacks |
07:18:27 | FromDiscord | <odexine> i see |
07:23:00 | * | def- quit (Quit: -) |
07:23:22 | * | def- joined #nim |
07:24:28 | NimEventer | New thread by pablocael: Passing seq or array to cpp function that takes iterators., see https://forum.nim-lang.org/t/11543 |
07:36:07 | * | KhazAkar quit (Remote host closed the connection) |
07:36:57 | * | KhazAkar joined #nim |
07:46:27 | FromDiscord | <nocturn9x> you know what pisses me off |
07:46:32 | FromDiscord | <nocturn9x> when I try to debug an issue |
07:46:35 | FromDiscord | <nocturn9x> and the issue disappears |
07:46:56 | FromDiscord | <nocturn9x> why is the code not segfaulting now that I enabled `--stackTrace --lineTrace`? |
07:46:59 | FromDiscord | <nocturn9x> WHO KNOWS |
07:46:59 | FromDiscord | <Elegantbeef> Hisenbugs for all! |
07:49:03 | FromDiscord | <nnsee> probably missed a load bearing comment somewhere |
07:50:16 | * | def- quit (Quit: -) |
07:50:20 | FromDiscord | <morgan> ok so im running into an issue with the big template i have for library entrypoint and related code, where it doesn;t seem to like one of the inputs `cannot use symbol of kind 'let' as a 'field'` |
07:50:39 | FromDiscord | <morgan> and i tried the dirty pragma |
07:50:48 | FromDiscord | <morgan> but it didn't change anything |
07:50:49 | FromDiscord | <Elegantbeef> You're using a template parameter for a let statement |
07:51:19 | * | def- joined #nim |
07:51:36 | * | KhazAkar quit (Ping timeout: 268 seconds) |
07:52:53 | FromDiscord | <morgan> i get `cannot use symbol of kind 'var' as a 'field'` when i switch the `let` in and the `let` out of it to `var` |
07:53:10 | FromDiscord | <nnsee> post cood |
07:53:14 | FromDiscord | <nnsee> code |
07:54:20 | FromDiscord | <morgan> <https://www.github.com/morganholly/nim-clap> nimplugin.nim, last section of code |
07:54:39 | FromDiscord | <morgan> also i switched all the lets i could find and still nothing |
07:55:38 | * | KhazAkar joined #nim |
07:56:37 | FromDiscord | <morgan> the error i get from the compiler is `nimplugin.nim(1127, 23) Error: undeclared field: 'mapping='`, which is extra confusing. the line is `plugin.id_map = id_map`, and mapping is the variable in the other file that is passed to the id_map input in the template, but im just very confused |
07:57:17 | FromDiscord | <Elegantbeef> The issue isn't the `let`s |
07:57:22 | FromDiscord | <Elegantbeef> The issue is using a field for a `let` name |
07:58:21 | FromDiscord | <morgan> yet i had the same issue with all var |
07:58:26 | FromDiscord | <morgan> tho i think there was a const |
07:58:59 | FromDiscord | <morgan> i'm considering seeing if i can convert it into AST and then paste it in with a macro |
07:59:14 | FromDiscord | <Elegantbeef> Oh jesus you're using a template for module instantitions |
07:59:27 | FromDiscord | <Elegantbeef> Why? |
07:59:44 | FromDiscord | <Elegantbeef> Just use generics |
07:59:51 | FromDiscord | <morgan> because i don't want the user to have to write that code |
08:00:05 | FromDiscord | <Elegantbeef> If you use generics they do not |
08:00:13 | * | def- quit (Quit: -) |
08:01:00 | FromDiscord | <morgan> i am confused |
08:02:09 | FromDiscord | <Elegantbeef> ` proc convert_plugin_descriptor(desc: PluginDesc): ClapPluginDescriptor =` is an issue cause `desc` is bound to whatever you pass in as `desc` to the template |
08:02:23 | FromDiscord | <Elegantbeef> Same with `.params` |
08:02:39 | FromDiscord | <Elegantbeef> same with all your `desc.`s |
08:02:53 | FromDiscord | <Elegantbeef> Just use generics for this instead, your life will be better |
08:03:03 | FromDiscord | <Elegantbeef> I helped ayy do the same with their project |
08:03:05 | FromDiscord | <morgan> how do i do this with generics |
08:03:40 | FromDiscord | <morgan> how do i get user callbacks and other data into this library code |
08:04:32 | FromDiscord | <Elegantbeef> `Typedesc.myProcCb` is one way |
08:05:03 | FromDiscord | <nocturn9x> this fucking language keeps segfaulting on me |
08:05:06 | FromDiscord | <nocturn9x> fuck ARC |
08:05:13 | FromDiscord | <nocturn9x> literally |
08:06:03 | FromDiscord | <Elegantbeef> @morgan https://github.com/Alkamist/clap/blob/main/clap/plugin.nim |
08:06:29 | FromDiscord | <Elegantbeef> Look at all the `pluginInit[T]` and friends |
08:07:25 | FromDiscord | <Elegantbeef> You use your own generic procedures which call the underlying type that you instantiated the plugin with |
08:07:47 | FromDiscord | <Elegantbeef> This gives you a cleaner approach and does not deal with having to futz around with pointer procs and making sure you pass the arguments in the right order |
08:08:37 | FromDiscord | <Elegantbeef> https://github.com/Alkamist/clap/blob/main/clap/types.nim#L76 the entry type is here |
08:08:51 | FromDiscord | <Elegantbeef> You then just do `AudioPlugin[MyPluginobject]` iirc |
08:09:43 | FromDiscord | <Elegantbeef> But i'm going to go so I hope that explains enough |
08:16:30 | * | greaser|q quit (Changing host) |
08:16:30 | * | greaser|q joined #nim |
08:16:33 | * | greaser|q is now known as GreaseMonkey |
08:17:01 | * | KhazAkar quit (Ping timeout: 256 seconds) |
08:17:10 | FromDiscord | <Phil> errr question, how do I check if a given proc is an async proc at compiletime? |
08:20:03 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=ZxVjidzMpefr |
08:20:26 | FromDiscord | <Phil> So I want to allow users to define sync procs and just convert them to async procs on-the-fly to store them in an object that definitely only holds async procs |
08:21:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=KRkdbNrqHNSi |
08:22:15 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#pasty=UXswcplJosqu" => "https://play.nim-lang.org/#pasty=WDGUvxdpiZhw" |
08:23:29 | FromDiscord | <morgan> In reply to @Elegantbeef "But i'm going to": i’m also headed off, but what’s relevant is their code in public.nim. they’re using a proc that contains the entry point, which i’m guessing gets returned from it. i’ll have to read more in the morning if i remember |
08:32:03 | FromDiscord | <nocturn9x> I think `--stackTrace` is just making the code slow enough so that race conditions don't happen |
08:32:25 | FromDiscord | <nocturn9x> since now I'm not sharing references across threads, I suppose I'll just use `refc` |
08:35:56 | NimEventer | New thread by Isofruit: Can I check if a proc is async at compileTime without a macro?, see https://forum.nim-lang.org/t/11544 |
08:40:22 | * | KhazAkar joined #nim |
08:40:56 | * | def- joined #nim |
08:46:47 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=vBruiLpHNRbL |
08:47:01 | FromDiscord | <nocturn9x> can ANY of nim's memory management strategies not fucking segfault the instant they're used with threads? |
08:47:21 | FromDiscord | <nocturn9x> (edit) "instant" => "_instant_" |
08:48:07 | FromDiscord | <nnsee> i had random segfaults when i did https://pasty.ee, due to segfaults |
08:48:17 | FromDiscord | <nnsee> turns out pretty much all of them were my fault |
08:48:26 | FromDiscord | <nnsee> derp, due to threads |
08:48:35 | FromDiscord | <nocturn9x> yeah well how do I debug this crap |
08:50:27 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=KQWmXoZlWpdC |
08:50:38 | FromDiscord | <nocturn9x> `startUCISession` is definitely _not_ inside `threadimpl.nim` |
08:50:56 | FromDiscord | <nocturn9x> nor does it contain line 71 |
08:51:18 | * | def- quit (Quit: -) |
09:01:23 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=pHgzEAwGtylB |
09:01:30 | FromDiscord | <nocturn9x> it's just segfaulting at random places in the allocato |
09:01:31 | FromDiscord | <nocturn9x> (edit) "allocato" => "allocator" |
09:01:38 | FromDiscord | <nocturn9x> and I'm using mimalloc, mind you |
09:08:24 | * | KhazAkar quit (Remote host closed the connection) |
09:08:50 | * | def- joined #nim |
09:09:10 | * | KhazAkar joined #nim |
09:12:17 | * | KhazAkar quit (Remote host closed the connection) |
09:12:48 | * | KhazAkar joined #nim |
09:16:51 | FromDiscord | <nocturn9x> how is `atomicArc` faster than `arc`? lol |
09:17:19 | * | deadmarshal_ quit (Remote host closed the connection) |
09:26:20 | * | KhazAkar quit (Remote host closed the connection) |
09:27:16 | * | KhazAkar joined #nim |
09:31:30 | * | KhazAkar quit (Ping timeout: 255 seconds) |
09:32:26 | * | KhazAkar joined #nim |
09:34:08 | * | KhazAkar quit (Remote host closed the connection) |
09:34:47 | * | KhazAkar joined #nim |
09:41:49 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=MrkyunZccEit |
09:45:27 | * | KhazAkar quit (Ping timeout: 255 seconds) |
09:46:40 | * | KhazAkar joined #nim |
09:46:41 | * | KhazAkar quit (Remote host closed the connection) |
09:47:10 | * | KhazAkar joined #nim |
09:49:00 | * | def- quit (Quit: -) |
09:49:11 | * | def- joined #nim |
10:07:01 | * | KhazAkar quit (Remote host closed the connection) |
10:07:30 | * | KhazAkar joined #nim |
10:13:16 | * | KhazAkar quit (Ping timeout: 246 seconds) |
10:13:25 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=IesnvzAqmpbp |
10:14:34 | * | KhazAkar joined #nim |
10:16:47 | FromDiscord | <Phil> More like I'm not investing an hour into troubleshooting something that difficult |
10:21:28 | FromDiscord | <nocturn9x> fair enough ig |
10:23:15 | * | KhazAkar quit (Ping timeout: 256 seconds) |
10:24:43 | * | KhazAkar joined #nim |
10:28:20 | * | deadmarshal_ joined #nim |
10:33:20 | * | KhazAkar quit (Remote host closed the connection) |
10:34:02 | FromDiscord | <fosster> hi nim community, I'm back coding in nim! I was looking for a good tui library in nim, any suggestion? |
10:34:10 | * | KhazAkar joined #nim |
10:34:14 | FromDiscord | <fosster> hi nim community, I'm back coding in nim! I was looking for a good tui library for nim, any suggestion? |
10:37:15 | FromDiscord | <Phil> I know nothing, but this could be a useful resource:↵https://github.com/ringabout/awesome-nim?tab=readme-ov-file#terminal |
10:37:28 | * | KhazAkar quit (Remote host closed the connection) |
10:38:20 | * | KhazAkar joined #nim |
10:43:32 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "errr question, how do": Have you tried `compiles(waitFor next(default(T)))`? |
10:44:43 | FromDiscord | <Robyn [She/Her]> I use a similar method of checking if a proc is async in my code here: https://github.com/Nimberite-Development/Trigger-Nim/blob/main/src/trigger.nim#L79 |
10:54:14 | FromDiscord | <fosster> [Phil (he/him)](https://matrix.to/#/%40isofruit%3Amatrix.org) thank you |
10:57:02 | FromDiscord | <Phil> In reply to @chronos.vitaqua "Have you tried `compiles(waitFor": All I want at this point is not to have to define 8 versions of newObserver, I got 2-3 Approaches for how to figure out async now, but I can't figure out for the life of me how to make a proc generic in the sense that it accepts 2 types of procs and converts one to the other |
10:57:35 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=RQexwSitEGMo |
10:58:00 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=NBNEnIQDjFUw |
10:59:36 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=fjnvDTbxoRrb |
10:59:37 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#pasty=SfNXmQHvEHus" => "https://play.nim-lang.org/#pasty=AjMFAAzTqpuo" |
11:07:28 | * | KhazAkar quit (Remote host closed the connection) |
11:07:59 | * | KhazAkar joined #nim |
11:08:57 | * | gst joined #nim |
11:14:21 | * | KhazAkar quit (Ping timeout: 252 seconds) |
11:15:02 | * | KhazAkar joined #nim |
11:22:23 | * | KhazAkar quit (Ping timeout: 272 seconds) |
11:22:49 | * | KhazAkar joined #nim |
11:39:47 | * | KhazAkar quit (Remote host closed the connection) |
11:40:34 | * | KhazAkar joined #nim |
11:57:46 | * | beholders_eye joined #nim |
12:09:50 | * | KhazAkar quit (Remote host closed the connection) |
12:10:18 | * | KhazAkar joined #nim |
12:14:53 | * | beholders_eye quit (Ping timeout: 240 seconds) |
12:17:21 | * | beholders_eye joined #nim |
12:30:40 | FromDiscord | <basilajith> sent a code paste, see https://play.nim-lang.org/#pasty=bfVkRdkFlHva |
12:31:42 | FromDiscord | <Phil> In reply to @basilajith "Can I: 1.": Yes you can, however you typically do not define e.g. constructor procs as part of the type definition |
12:31:54 | * | beholders_eye quit (Ping timeout: 252 seconds) |
12:31:54 | FromDiscord | <Phil> Also Table is a generic type whose types you need to specify |
12:31:59 | FromDiscord | <Phil> Let me whip up a code example |
12:33:42 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=MJeazEyuBIPI |
12:35:10 | FromDiscord | <Phil> This will however mean that `record`can only hold strings.↵If you want to store multiple different types in there, you'll need to either look into object variants (which can hold entirely different types based on a field counting as a flag at runtime) or inheritance (which you should only look into if you don't want to use generic methods as those are deprecated) |
12:39:24 | FromDiscord | <basilajith> 👍🏼↵↵Thanks @Phil! |
12:52:04 | FromDiscord | <basilajith> I'm just wondering whether some of the members of the `object` type can have some default values. |
12:53:29 | FromDiscord | <basilajith> Aah, slip of thinking. Taking this 👆🏼 back. |
12:53:58 | FromDiscord | <Phil> In reply to @basilajith "I'm just wondering whether": You can in fact assign default values in the type itself |
12:54:10 | FromDiscord | <Phil> `count: int = 5` for example in the Something type |
12:54:28 | FromDiscord | <basilajith> Oh, okay. |
12:54:40 | FromDiscord | <Phil> Note that those values must be static compile-time values, so you can't read in a config file or the like to set a default value |
12:57:09 | FromDiscord | <basilajith> But, they are not immutable, right? 😬 |
12:58:04 | FromDiscord | <nnsee> no |
12:58:10 | FromDiscord | <Phil> If you just mean changing them after initialization - then yeah, they are not immutable |
12:58:16 | FromDiscord | <nnsee> but your object must be initialized via `var`, not `let` |
12:58:22 | FromDiscord | <nnsee> as per standard mutability rules |
12:58:49 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=GwGaaPRYniKm |
12:59:29 | FromDiscord | <Phil> Note that the `var` here means that x is mutable. Had I used let then the assignment to counter would've been blocked at compiletime |
13:04:51 | FromDiscord | <Phil> Hmmmmmmm |
13:06:20 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=pOLsnhaHjOnv |
13:06:55 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=BwuOWzfdyEep |
13:07:16 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#pasty=fZbQAKIsekjy" => "https://play.nim-lang.org/#pasty=veDjaCjfIZzd" |
13:08:40 | FromDiscord | <.lisuwu_> In reply to @isofruit "Anyone understand how this": i feel like doing it as simply just `Future` is wrong as Future is generic, my only guess, idk how to explain the error though |
13:09:10 | FromDiscord | <.lisuwu_> that could be just me not knowing what typeOf is |
13:09:11 | FromDiscord | <Phil> In reply to @.lisuwu_ "i feel like doing": Nah, that is not the issue. That'll work without a problem really |
13:09:36 | FromDiscord | <Phil> Gets you the type of something, in this case we're "pseudo"-executing `nextProc` and looking at its return-type |
13:09:48 | FromDiscord | <Phil> Which might be what's blowing up since that is "void" in one case |
13:10:02 | FromDiscord | <Phil> Uggggghhhh seriously, this type system is my bane sometimes |
13:13:42 | FromDiscord | <.lisuwu_> In reply to @isofruit "Anyone understand how this": one idea: cant you just overload isAsync, so you can always return true for AsyncNextProc, false for SyncNextProc? |
13:14:31 | FromDiscord | <.lisuwu_> (edit) "idea:" => "suggestion:" |
13:15:44 | FromDiscord | <Phil> If the type system weren't busy daggering me sure |
13:15:47 | FromDiscord | <Phil> However, even that won't work |
13:16:08 | FromDiscord | <.lisuwu_> poor phil |
13:16:14 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=BItDKNgPhHTX |
13:16:19 | * | def- quit (Quit: -) |
13:16:47 | FromDiscord | <Phil> This is the kind of shit that makes me aggro sometimes, this should not be this hard to express. It works perfectly fine for normal types, but once you pick out procs its a house of cards |
13:17:03 | * | def- joined #nim |
13:18:58 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=UjAMvDXxEbbU |
13:19:03 | FromDiscord | <Phil> It drives me up the wall |
13:20:34 | FromDiscord | <Phil> Like, I enjoy dealing with implementing reactivex in nim because its an interesting problem.↵Working my way past compiler bugs or what have you is not interesting, its boring as hell |
13:20:39 | FromDiscord | <.lisuwu_> cursed |
13:31:35 | * | beholders_eye joined #nim |
13:33:04 | FromDiscord | <demotomohiro> It seems `async` is a macro transform , not calling convention.↵Does `asnyc` works like calling convention in the Nim's type system? |
13:33:49 | FromDiscord | <demotomohiro> async is a macro transform a proc to a closure iterator. |
13:35:51 | FromDiscord | <Phil> I mean, even if I remove the async macro and replace it with just having a return-type `Future[void]` instead that isn't going to change the problem |
13:36:19 | FromDiscord | <Phil> Nim just can't cope with a type-union of 2 geneneric proc-types |
14:16:50 | NimEventer | New thread by ninovanhooff: Can I use std/json to serialize objects in a Table?, see https://forum.nim-lang.org/t/11548 |
14:19:22 | * | def- quit (Quit: -) |
14:20:43 | * | def- joined #nim |
15:45:55 | FromDiscord | <.lisuwu_> How can I have nim call my procedure for every unhandled exception? |
15:46:03 | FromDiscord | <.lisuwu_> (edit) "my" => "a specific" |
15:46:25 | FromDiscord | <.lisuwu_> Setting `unhandledExceptionHook` doesn't work |
15:46:30 | FromDiscord | <.lisuwu_> (edit) "exception?" => "exception on `--os:any`?" |
15:55:26 | Amun-Ra | .lisuwu_: works for me: https://play.nim-lang.org/#pasty=hjRSqeGOdfpE |
15:56:57 | * | def- quit (Quit: -) |
15:57:10 | FromDiscord | <.lisuwu_> In reply to @Amun-Ra ".lisuwu_: works for me:": yeah but it doesn't in `--os:Any` |
15:57:11 | FromDiscord | <.lisuwu_> (edit) "`--os:Any`" => "`--os:any`" |
15:57:19 | * | def- joined #nim |
15:58:25 | Amun-Ra | these edits are not as clear on irc as they're on discord |
15:58:37 | Amun-Ra | .lisuwu_: https://github.com/nim-lang/Nim/issues/15627 |
15:58:43 | Amun-Ra | still open |
15:59:19 | FromDiscord | <.lisuwu_> In reply to @Amun-Ra "these edits are not": oh, my bad |
15:59:29 | FromDiscord | <.lisuwu_> In reply to @Amun-Ra "still open": oh :( |
15:59:42 | FromDiscord | <.lisuwu_> alright thanks either way |
15:59:53 | Amun-Ra | no, I should've replied after reading all the lines :> |
16:00:59 | FromDiscord | <.lisuwu_> In reply to @Amun-Ra "no, I should've replied": hey, it's fine, i do have same thing |
16:01:04 | FromDiscord | <.lisuwu_> we all do mistakes |
16:03:21 | Amun-Ra | yeah, that's a non-issue really :> |
16:03:45 | Amun-Ra | until this day I wasn't aware this hook even existed |
16:04:00 | FromDiscord | <.lisuwu_> me neither, i only found about it when i was trying to code OS kernel |
16:04:10 | FromDiscord | <.lisuwu_> and i needed proper exception handling mechanism after switching to `--os:any` |
16:04:41 | Amun-Ra | can you use "global" try/except? |
16:16:48 | FromDiscord | <.lisuwu_> In reply to @Amun-Ra "can you use "global"": yeah, but really it would be better if i didnt have to do that |
16:17:07 | FromDiscord | <.lisuwu_> but i guess i have to roll with this system |
16:17:56 | FromDiscord | <.lisuwu_> thanks for suggestion either way |
16:18:02 | FromDiscord | <.lisuwu_> better than nothing |
16:18:34 | Amun-Ra | right |
17:26:54 | FromDiscord | <Phil> Maybe I found the one scenario where converters are legitimate |
17:27:04 | FromDiscord | <Phil> Let's see if that works |
17:28:54 | FromDiscord | <Phil> Nope, converters also die |
17:31:14 | FromDiscord | <morgan> ok so im trying to use a proc instead of template (i also tried macro with genast) for my entry and setup code |
17:31:34 | FromDiscord | <morgan> i'm getting illegal capture because of calling convention cdecl |
17:32:11 | FromDiscord | <morgan> i changed that variable to be declared outside, and even made it passed in as a pointer (i only need the address inside the section of code) |
17:33:48 | FromDiscord | <morgan> it has to define procs which are then stored in objects, maybe a few layers of that, and then ends with the struct that is the entry point |
17:34:19 | * | om3ga joined #nim |
17:39:06 | FromDiscord | <morgan> i just need to get some user data into these initial functions which do not have a way to provide it via the inputs |
17:39:44 | FromDiscord | <morgan> since it needs to conform to the plugin api |
17:43:30 | FromDiscord | <Phil> I did it, I finally tricked the system |
17:44:23 | FromDiscord | <morgan> i want to have some macro/template/whatever which just drops the code into the user's file with a few variables filled in with either an object, a proc, or nil. i don't know why it's so hard to do that |
17:45:51 | FromDiscord | <Phil> I don't fully understand what you're trying to do I'll be honest.↵So you're generating code-text that you want to write into a user's file based on their input? |
17:46:57 | FromDiscord | <nnsee> In reply to @isofruit "*I did it, I": https://tenor.com/view/thematrixreloaded-matrix-reloaded-neo-keanureeves-gif-3449253871426083114 |
17:47:07 | FromDiscord | <nnsee> wow, gifs are not appreciated om this channel |
17:47:12 | FromDiscord | <nnsee> (edit) "om" => "in" |
17:47:20 | FromDiscord | <Phil> Basically, 2 converters and I'm just eating it that I have to do an overload for the generic bits |
17:47:40 | FromDiscord | <Phil> Which is fine, 2 I can live with, even if I have to do that twice, 8 twice over is too much |
17:47:56 | FromDiscord | <Phil> (edit) "bits" => "bits, which means 2 procs" |
17:48:12 | FromDiscord | <morgan> In reply to @isofruit "I don't fully understand": the entry point code should be handled by the library, but the defs of some procs need to take in user data and afaict cannot be rewritten to do so via inputs |
17:48:57 | FromDiscord | <morgan> so undoing to when i had it as a macro with genast, the errors start with some nil proc inputs and after a nil pointer. i wonder if that is causing the error https://media.discordapp.net/attachments/371759389889003532/1236374019046117446/image.png?ex=6637c688&is=66367508&hm=1e2df81e907cdc410a2ed3ab96bc63fdc44edecf28270c14e409da2cd8c9552d& |
17:48:58 | FromDiscord | <Phil> You are still speaking in tongues, do you want users to write code as text and you run that code or sth? |
17:49:29 | FromDiscord | <morgan> the users provide one or more procs, a table, a seq of objects, and an object |
17:49:33 | FromDiscord | <Phil> And what input are we talking about, a CLI/GUI input field? |
17:49:40 | FromDiscord | <morgan> no at compile time |
17:49:47 | FromDiscord | <Phil> Okay, so "user" here is develoepr |
17:49:50 | FromDiscord | <morgan> yes |
17:49:53 | FromDiscord | <morgan> user of the library |
17:50:03 | FromDiscord | <morgan> sorry that was probably a bit confusing |
17:50:47 | FromDiscord | <Phil> So you want some state in procs that they can't receive via inputs? |
17:50:56 | FromDiscord | <Phil> (edit) "inputs?" => "the proc-params?" |
17:50:56 | FromDiscord | <morgan> yes |
17:50:59 | FromDiscord | <Phil> Closures? |
17:51:13 | FromDiscord | <Phil> I know I sound like a broken record by now when it comes to those |
17:51:27 | FromDiscord | <Phil> You should be able to capture any variable in a closure as long as it isn't `var` |
17:51:36 | FromDiscord | <Phil> If it must be mutable, make it a ref-type |
17:52:31 | FromDiscord | <morgan> can i do that with cdecl calling convention? |
17:52:52 | FromDiscord | <Phil> I would assume so, but haven't tried |
17:53:04 | FromDiscord | <jaar23> In reply to @fosster "hi nim community, I'm": @nocturn9x I'm working on a tui lib based on illwill. You are welcome to check it out. https://github.com/jaar23/tui_widget |
17:53:30 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=SRTAMIxtcGWe |
17:53:53 | FromDiscord | <nocturn9x> In reply to @jaar23 "<@523555920265871380> I'm working on": think you tagged the wrong person :) |
17:54:11 | FromDiscord | <polylokh_39446> you'd need to smuggle the user data into the function through a global variable, which are capturable despite calling convention because their location is static |
17:54:53 | FromDiscord | <jaar23> (edit) "@nocturn9x" => "@fosster" |
17:54:59 | FromDiscord | <morgan> yeah and then i need to declare a global in the user file which is read in the library file |
17:55:05 | FromDiscord | <morgan> which afaik isnt possible |
17:55:28 | FromDiscord | <jaar23> In reply to @nocturn9x "think you tagged the": Lol, I think so, he didn't allow me tagging him, end up I mistakenly tag you... |
17:55:38 | FromDiscord | <morgan> forward declarations would be really nice to have |
17:55:53 | FromDiscord | <Phil> ?↵Forward declarations, at least for procs, exist |
17:56:05 | FromDiscord | <morgan> oh huh |
17:56:15 | FromDiscord | <morgan> ill have to look into that then |
17:56:20 | FromDiscord | <Phil> Like, I've used them before and toyed around using them as pseudo interfaces |
17:56:39 | FromDiscord | <morgan> i guess it was just types where i ran into that not existing |
17:56:44 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=WClaJdgZVLQb |
17:57:08 | FromDiscord | <Phil> As an example where Owlkettle makes use of those |
17:57:47 | FromDiscord | <Phil> Yeah for types and constants etc. there are no forward declarations |
17:58:09 | FromDiscord | <Phil> however you can work around the "no forward declaration for constants" by having them decine a callback that returns the value you want |
17:58:15 | FromDiscord | <Phil> For types though you're sol |
17:58:22 | FromDiscord | <morgan> yeah i was gonna say that |
17:58:48 | FromDiscord | <morgan> a proc which returns the inputs in a tuple or something |
17:58:51 | FromDiscord | <Phil> What do you need the type for? Why do you care specifically? What information do you need? |
17:59:28 | FromDiscord | <Phil> In reply to @morganalyssa "a proc which returns": `proc[A, B](x: A, y: B): [(A, B)] = (x, y)`↵? |
17:59:35 | FromDiscord | <Phil> (edit) "`proc[A," => "`proc toTuple[A," |
17:59:50 | FromDiscord | <Phil> (edit) "[(A, B)]" => "(A, B)" |
18:01:57 | FromDiscord | <morgan> sent a long message, see https://pasty.ee/kQRIDmHpcuFc |
18:02:05 | FromDiscord | <morgan> that's a small part of it |
18:02:38 | FromDiscord | <polylokh_39446> `user_data` is where inputs typically go |
18:02:44 | FromDiscord | <morgan> and elsewhere in the setup, i have some callbacks inserted |
18:03:05 | FromDiscord | <Phil> In reply to @morganalyssa "first 4 are required,": Make a file called "interface.nim" or sth with forward declarations, tell users to include those |
18:03:22 | FromDiscord | <Phil> for the 4 required procs |
18:03:26 | FromDiscord | <morgan> rather than forward declarations in the main file? |
18:03:35 | FromDiscord | <morgan> main library file |
18:03:40 | FromDiscord | <Phil> Also a possibility, I like to do this kind of pattern separately |
18:03:50 | FromDiscord | <Phil> But that doesn't have to be your style, whatever you find convenient |
18:14:23 | FromDiscord | <morgan> is there a way to gracefully handle them not being defined? are they nil before then? |
18:14:46 | FromDiscord | <morgan> im setting it up as procs which take nothing and return something |
18:19:51 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=SXapDDIwOeQC |
18:56:54 | FromDiscord | <Phil> Lul, I have now managed through the combination of async with observable to have a try-catch statement that catches `CatchableError` but is unable to catch a ValueError |
18:57:36 | FromDiscord | <Phil> In fact, it won't even catch Exception |
18:58:05 | FromDiscord | <Phil> Is there something stronger than try-except that I can use to force catching an exception under all circumstances? |
19:02:06 | FromDiscord | <Elegantbeef> Try except does capture all exceeptions |
19:04:02 | FromDiscord | <Phil> Given that awaiting a future of a proc that throws exceptions whose exceptions should be caught by the calling proc whose future is being awaited - I struggle believing that |
19:04:36 | FromDiscord | <Elegantbeef> Futures throw exceptions in the dispatch loop if you're not awaiting them |
19:04:41 | FromDiscord | <Elegantbeef> Otherwise they raise at the place |
19:08:20 | * | beholders_eye quit (Ping timeout: 260 seconds) |
19:11:19 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=ukSeWJfAuazg |
19:12:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=QqkymhHmmxkB |
19:13:26 | FromDiscord | <Phil> So.... I must make subscribeProc async and await here? Is that the only way? |
19:13:53 | FromDiscord | <Elegantbeef> Wrapping what consumes the `fut` with a try except should work |
19:14:23 | FromDiscord | <Phil> In this case that should be `doWork` |
19:14:31 | FromDiscord | <Phil> Since that waitfor's the future |
19:15:08 | FromDiscord | <Phil> Yep, that catches it... but I don't want to catch it there dangit |
19:15:15 | FromDiscord | <Elegantbeef> Tangentially related this is what it takes to make async work with owlkettle and to gracefully handle exceptions https://github.com/beef331/dodger/blob/master/dodger/dodger.nim#L22-L31 |
19:15:39 | FromDiscord | <Elegantbeef> You have to except around whatever gets the exception off dispatcher |
19:16:48 | FromDiscord | <Elegantbeef> Unless the exception is ran before the first `await` in a async proc invoking an async proc will not raise at the callsite |
19:17:09 | FromDiscord | <Elegantbeef> Which sadly is not knowledge you can use here |
19:18:31 | * | def- quit (Quit: -) |
19:19:27 | FromDiscord | <Phil> So not even await saves me here |
19:19:35 | FromDiscord | <Elegantbeef> No it does |
19:19:39 | FromDiscord | <Phil> FML |
19:20:01 | FromDiscord | <Elegantbeef> if you can await the subscription where it's invoked you get the exception there |
19:21:02 | * | def- joined #nim |
19:21:30 | FromDiscord | <Phil> That's not what I quite want is the problem.↵I want a subscription to be async work. So upon subscribing I want to give the user the option to determine when that work is being done because I can't make assumptions about event loops |
19:21:35 | FromDiscord | <Phil> That means handing them the future |
19:21:47 | FromDiscord | <Phil> But apparently that also means that I can't do the error handling for them then |
19:22:06 | FromDiscord | <Elegantbeef> Should you even be doing the error handling for them? |
19:22:16 | FromDiscord | <Phil> Yes, in a sense |
19:22:27 | FromDiscord | <Phil> You give me 3 callbacks:↵next, error and complete |
19:22:46 | FromDiscord | <Phil> If anyone, anywhere throws an exception during an execution of subscribe or the like, I call next |
19:22:59 | FromDiscord | <Phil> (edit) "next" => "error" |
19:23:04 | FromDiscord | <Phil> If there is no error, nothing happens |
19:23:11 | FromDiscord | <Phil> (edit) "error," => "error-callback," |
19:23:26 | FromDiscord | <Elegantbeef> does subscription capture the observer? |
19:23:28 | FromDiscord | <Phil> You get to decide wheether you care about any exceptions/errors by providing an error-callback |
19:24:17 | FromDiscord | <Phil> It does not atm, just contains a closure which captures observer. It could have access to it though... oh I'm not going to like this |
19:24:33 | FromDiscord | <Phil> That's such a "this is technically necessary, not logically" piece of code |
19:24:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=zMfEGJeBBHyV |
19:25:27 | FromDiscord | <Phil> I'm going to fetch explicitly the errorcallback since nothing else should be necessary |
19:25:50 | FromDiscord | <Phil> capturing observer would just introduce a generic parameter into subscription that I'm really not feeling |
19:26:30 | FromDiscord | <Elegantbeef> Just define a `ObservableBase` that has errorhandler 😛 |
19:27:18 | FromDiscord | <Phil> Subscriptions don't inherit from Observable, they're independent from that |
19:27:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=JFhiLViksmLG |
19:27:48 | FromDiscord | <Elegantbeef> Right but you could capture an `Observer` without having a generic parameter if you use a little inheritance |
19:27:51 | FromDiscord | <odexine> Having fun yet? |
19:28:00 | * | def- quit (Quit: -) |
19:28:15 | FromDiscord | <Phil> 50% fun, 50% aggravation of nim's type system |
19:28:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=MDUzlERYBBWz |
19:28:33 | FromDiscord | <Elegantbeef> Hey it's mostly just static typing keeping you down |
19:28:46 | * | def- joined #nim |
19:28:53 | FromDiscord | <Elegantbeef> Make everything weakly dynamically typed! |
19:29:05 | FromDiscord | <odexine> Weak typing is another thing |
19:33:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=NADYWiZrvMMJ |
19:33:28 | FromDiscord | <Elegantbeef> Ew `return` for an expression |
19:33:45 | FromDiscord | <Elegantbeef> I'm booking a flight to Germany and bringing a hockey stick |
19:33:56 | FromDiscord | <.lisuwu_> why the hate on explicit returns 😭 |
19:34:01 | FromDiscord | <Phil> Says the person that just wanted me to introduce a second level of inheritance to add a proc in a field that only one type actually needs |
19:34:02 | FromDiscord | <Elegantbeef> They're pointless |
19:34:17 | FromDiscord | <Elegantbeef> I was just saying that you did not need the generic parameter |
19:34:36 | FromDiscord | <Elegantbeef> I can only suggest things Phil I do not know what madness you have |
19:36:07 | FromDiscord | <Phil> It leads to odd inheritance chains either way 😛↵↵Observable does not inherit from Observer btw, those are separate in general.↵It would be more that only Observer inherits from Observerbase and subscription could store "Observerbase" |
19:36:17 | FromDiscord | <Phil> At which point I could just as well just store the error-callback directly 😄 |
19:36:44 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=olLKkZQGIoMO |
19:37:37 | FromDiscord | <Phil> almost 60% of just my observable tests are running again though, so that's nice |
19:37:52 | FromDiscord | <polylokh_39446> although, it still doesn't warn about that function without them. |
19:38:19 | FromDiscord | <Phil> Errrrrrrr |
19:39:21 | FromDiscord | <odexine> In reply to @polylokh_39446 "although, it still doesn't": ? |
19:42:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=uONHMuJvwnDR |
19:42:12 | FromDiscord | <polylokh_39446> In reply to @odexine "?": if you're asking what the problem is, it's that `result` is returned in the last case.↵if you're asking why it doesn't warn even without the explicit returns, it's that the `assert(false)` makes it think the second case isn't an expression to begin with (so an implicit return would result in an error) |
19:42:15 | FromDiscord | <Elegantbeef> Right but I do not know what you code needs↵(@Phil) |
19:42:20 | NimEventer | New thread by planetis: Malebolgia threads deadlock when trying to synchronize them., see https://forum.nim-lang.org/t/11549 |
19:42:56 | FromDiscord | <Phil> I know I can just go "msg.contains("Some error") but that seems rather unspecific now |
19:42:59 | FromDiscord | <Elegantbeef> @polylokh_39446 not to mention that expressions have to return values |
19:43:08 | FromDiscord | <Phil> It's not a big deal per se but would be preferred |
19:44:32 | FromDiscord | <Elegantbeef> Odd in my experience `e.msg` only had a the exception message |
19:45:37 | FromDiscord | <Phil> I'm booking that msg change under "async is weird" |
19:46:01 | FromDiscord | <Phil> I've moved to ` check receivedErrors2[0].msg.contains("Some error")` but I liked the prior syntax more and the exception message change is odd |
19:46:12 | FromDiscord | <Phil> Anyway, 100% of my tests work! |
19:46:29 | FromDiscord | <Phil> As in, my observable tests, the other 80% of my test-suite I'll still need to fix up |
19:49:46 | FromDiscord | <odexine> In reply to @polylokh_39446 "if you're asking what": I more of don’t see how the problem is a problem, what is it supposed to be for you? |
19:50:47 | FromDiscord | <Phil> Sidednote, beef:↵if I were in an eventloop, then I wouldn't have to call `doWork` right?↵The event-loop would magically - whenever the loop reaches its "do async work"-phase, - trigger all the code for me... maybe? |
19:51:21 | FromDiscord | <polylokh_39446> The problem is that if you, by error, fail to provide a return value, then the function will compile without complaint and return something anyway. This is a reduced example of a real case where there are a bunch of explicit returns and then very confusing behavior for the control path that's missing its explicit return. |
19:52:21 | FromDiscord | <Phil> Because all `doWork` does is await a bunch of `Future[void]` , which just stands for more procs that should be called after an await |
19:52:51 | FromDiscord | <odexine> from what i remember, the analysis from the compiler is not aware of anything within other when branches |
19:53:21 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#pasty=jpzLkLdoNZtE |
19:54:59 | FromDiscord | <polylokh_39446> Yes, there's an explanation for the behavior. Explaining a thing doesn't change it. My perspective is still an unpleasant surprise after troubleshooting why I'm getting bounds errors because I somehow have an empty seq in my code. |
19:56:07 | FromDiscord | <odexine> idk, then it's best saved for an issue in such case no? |
19:56:28 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=TEDJDMXMJMcy |
19:56:51 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=xTMRrGspbebp |
19:56:53 | FromDiscord | <odexine> neither `result` nor `return` iirc will save you from this |
19:57:02 | FromDiscord | <polylokh_39446> (edit) "https://play.nim-lang.org/#pasty=GtmIREaPcusm" => "https://play.nim-lang.org/#pasty=OAOCiBVTnjAq" |
19:57:14 | FromDiscord | <polylokh_39446> what would is using implicit returns |
19:57:24 | FromDiscord | <odexine> the only possible way, yes |
19:57:42 | FromDiscord | <odexine> maybe there should be a warning yes |
19:57:56 | FromDiscord | <odexine> perhaps there already is, i'd have assumed so as well |
19:58:05 | FromDiscord | <polylokh_39446> and although assign `result` doesn't save you from not assigning it, you're at least much less likely to make that mistake because you're focused on that value |
20:25:20 | FromDiscord | <Elegantbeef> @Phil "event loop"? |
20:25:58 | FromDiscord | <Phil> Basically if you can assume that your code runs inside a while-loop that polls if there is work to be done |
20:26:19 | FromDiscord | <Elegantbeef> `poll` raises the exception then |
20:26:42 | FromDiscord | <Phil> Like a runforever type situation |
20:27:40 | FromDiscord | <Phil> That was not the point. The point was that a sanity check on the assumption that you can get away without doing `waitFor` on the Futures that get created if there is some surrounding context that calls poll for you when appropriate and without blowing up |
20:27:44 | FromDiscord | <Elegantbeef> Right |
20:27:48 | FromDiscord | <Phil> (edit) "that" => "asking for" |
20:28:04 | FromDiscord | <Elegantbeef> Futures add themselves to the eventpool and are completed by giving up the cpu |
20:28:24 | FromDiscord | <Elegantbeef> So a `poll`, `drain` or `runForever` completes them |
20:36:56 | * | ntat quit (Quit: Leaving) |
20:56:23 | * | def- quit (Quit: -) |
20:57:33 | * | def- joined #nim |
21:35:24 | FromDiscord | <morgan> sent a code paste, see https://play.nim-lang.org/#pasty=bDZEOoziiGIh |
22:03:29 | * | def- quit (Quit: -) |
22:21:53 | * | def- joined #nim |
22:33:29 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=UjCFQXIMMJDT |
22:35:40 | FromDiscord | <zidsal> whats the server code look like? |
22:39:19 | FromDiscord | <amarevite> sent a long message, see https://pasty.ee/gHFWovYFdjTU |
22:44:06 | FromDiscord | <zidsal> and from your phone did you also just the data "test" or did you send a osc framing protocol |
22:45:48 | FromDiscord | <amarevite> from my phone, the app is sending actual osc data in the proper format↵"test" is just dummy text for the minimal code example to show that i would send data after connecting↵i built an osc data constructor so that i can send correct osc data, but i cant test it because i cant even connect |
22:47:00 | FromDiscord | <amarevite> (edit) removed "from my phone," | "the ... app" added "phone" |
22:47:05 | FromDiscord | <zidsal> what os are you on, I'm wondering if its worth sending some socket data via telnet or whatever from the same pc you're running nim so we can rule out everything else, because looking at the docs that code looks fine |
22:48:15 | FromDiscord | <amarevite> Windows 10 Pro 22H2 (kernel version 10.0.19045.4291) |
22:48:19 | FromDiscord | <amarevite> (edit) "10.0.19045.4291)" => "`10.0.19045.4291`)" |
22:49:26 | FromDiscord | <zidsal> what happens if you run telnet localhost 3033 |
22:49:40 | FromDiscord | <amarevite> if i swap out the address and port for `google.com` and `80` i dont get an error |
22:49:59 | FromDiscord | <amarevite> localhost causes the same error |
22:50:23 | FromDiscord | <zidsal> can you run tcp dump while you run the nim program and send me the file |
22:50:30 | FromDiscord | <amarevite> how would i do that |
22:50:40 | FromDiscord | <zidsal> please hold |
22:54:17 | FromDiscord | <zidsal> ok 1. run command prompt as an admin↵2. windows comes built in with a program called pktmon which can do the same stuff as tcpdump↵3. run the command pktmon filter add -p 3033↵4. start capturing packets by pktmon start --etw -p 0 |
22:54:48 | FromDiscord | <zidsal> run your program then run pktmon stop to finish. You should then have a file called pktmon.etl |
22:55:38 | FromDiscord | <amarevite> `Failed to add filter: The system cannot find the file specified.` |
22:55:55 | FromDiscord | <amarevite> im looking at the microsoft docs and this looks correct to me so i dont know why thats happening |
22:56:28 | FromDiscord | <zidsal> is the command prompt you're running an admin 1 or a regular 1 |
22:56:51 | FromDiscord | <amarevite> regular |
22:56:56 | FromDiscord | <amarevite> i just ran as sudo and that fixed it |
22:57:15 | FromDiscord | <amarevite> not actual sudo it's a powershell script i think↵very useful to run single commands as admin |
22:59:37 | FromDiscord | <amarevite> i started a new terminal as admin to rule out any problems and set 4 gets me the following error:↵`Error: '0' is not a valid event provider Id.` |
22:59:42 | FromDiscord | <amarevite> (edit) "set" => "step" |
23:00:26 | FromDiscord | <zidsal> try pktmon start --etw --pkt-size 0 |
23:03:17 | FromDiscord | <amarevite> i have the etl file↵before i send it, what kind of data does it contain |
23:03:43 | FromDiscord | <zidsal> it will be all reaw packets sent over port 3033 |
23:03:47 | FromDiscord | <zidsal> (edit) "reaw" => "raw" |
23:03:57 | FromDiscord | <zidsal> (edit) "packets" => "tcp data" |
23:05:42 | FromDiscord | <amarevite> i figured that↵i took a look at the file and saw a memory section↵does it have any data outside of raw tcp data on port 3033 and basic diagnostic info↵i dont want to accidentally send identifying information or a memory dump or anything like that |
23:06:14 | FromDiscord | <zidsal> only if you've added in additionals filters via `pktmon filter add -p` |
23:07:04 | FromDiscord | <zidsal> as to if there is any personal identifying information, that entirley depends on whats been sent on port 3033! |
23:07:34 | FromDiscord | <amarevite> alright then heres the file https://media.discordapp.net/attachments/371759389889003532/1236454198720331818/PktMon.etl?ex=66381135&is=6636bfb5&hm=079ddf8826b6af2ad3fdaa78934655780280f9073d7ae1e51959f56ba079fe3b& |
23:08:30 | FromDiscord | <zidsal> ~~muhahaha all you're bases now belong to us~~ I've got the file give me a few mins |
23:15:47 | FromDiscord | <zidsal> ok thats given nothing useful |
23:21:19 | FromDiscord | <zidsal> given that you making a connection to port 80 was working and the code looks fine I'm starting to think thisn't isn't an issue with the socket. If I had to guess the data you're sending isn't in the right format as it needs a SLIP_END at the start/end of the frame |
23:22:38 | FromDiscord | <zidsal> to prove that, my advise would be to try and connect via a different way either telnet or by writing a quick socket in another language like python and see if the same thing happens |
23:25:38 | * | def- quit (Quit: -) |
23:26:40 | * | def- joined #nim |
23:28:49 | FromDiscord | <amarevite> [this client example](<https://pypi.org/project/python-osc/>) works from python just fine |
23:28:53 | FromDiscord | <amarevite> (edit) "example](<https://pypi.org/project/python-osc/>)" => "example](https://pypi.org/project/python-osc/)" |
23:29:00 | FromDiscord | <amarevite> (edit) "example](https://pypi.org/project/python-osc/)" => "example code](https://pypi.org/project/python-osc/)" |
23:49:41 | FromDiscord | <amarevite> well |
23:49:44 | FromDiscord | <amarevite> instead of using tcp |
23:49:48 | FromDiscord | <amarevite> udp works |
23:51:34 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=zfaDRHlDyPIZ |
23:51:37 | FromDiscord | <amarevite> thank you for the help |
23:52:42 | * | def- quit (Quit: -) |