00:00:46 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=EISVsVHzFNLR |
00:06:04 | FromDiscord | <Elegantbeef> Overloads |
00:06:22 | FromDiscord | <Robyn [She/Her]> ~~Converters 👀~~ |
00:06:47 | FromDiscord | <Robyn [She/Her]> (edit) "~~Converters 👀~~ ... " added "(jk, converters are bad ideas)" |
00:07:01 | FromDiscord | <Robyn [She/Her]> (edit) "~~Converters 👀~~ (jk, converters are ... badidea)" added "a" | "ideas)" => "idea)" |
00:07:05 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=nXEFKvjLbYbP |
00:07:36 | FromDiscord | <Elegantbeef> Using a converter for `some` is the most cancerous converter ever, I love it! |
00:07:56 | FromDiscord | <Elegantbeef> `10.get()` completely valid and not unhinged whatsoever |
00:11:01 | FromDiscord | <Robyn [She/Her]> Totally sane |
00:18:30 | * | KhazAkar quit (Ping timeout: 252 seconds) |
00:18:55 | * | KhazAkar joined #nim |
00:54:10 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=QVXhNemoIVcX |
00:54:55 | FromDiscord | <Elegantbeef> lame aint the word for it |
00:55:55 | * | def- quit (Quit: -) |
00:57:39 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=JSZACBSzfCdu |
00:57:46 | FromDiscord | <Robyn [She/Her]> Time to break out concepts lmao |
00:58:07 | * | def- joined #nim |
00:59:31 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=srIaXtqFTdEw |
01:00:00 | FromDiscord | <Elegantbeef> The issue is that any type that has `.get` will fire that |
01:00:33 | FromDiscord | <polylokh_39446> yep, I still don't know of a non-lame way to restrict this to `Option[T]` |
01:01:03 | * | def- quit (Client Quit) |
01:01:11 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=YoriZylleRxb |
01:01:37 | FromDiscord | <Elegantbeef> Or `typ[0].eqIdent "Option"` |
01:02:50 | FromDiscord | <polylokh_39446> awesome, ty. |
01:03:16 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=bmQKUbSWFHMO |
01:05:33 | FromDiscord | <polylokh_39446> but to the original question, you probably want something like the builder pattern, and boring use of optionals |
01:07:54 | FromDiscord | <Elegantbeef> Or just use overloads if more applicable |
01:13:33 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=DxIAnaDWjPkR |
01:16:33 | FromDiscord | <polylokh_39446> jumping to macros is the easiest way to do that. |
01:17:58 | FromDiscord | <amarevite> in that case can you give me a minimal example of iterating a proc's input variables from inside the proc |
01:18:04 | FromDiscord | <polylokh_39446> with the builder pattern - i.e., instead of having all these parameters, have them as fields of an object, and work with the object - you could use fieldPairs to iterate over them |
01:18:05 | FromDiscord | <amarevite> (edit) "in that case can you give me a minimal example of iterating ... a" added "over" |
01:18:07 | FromDiscord | <Elegantbeef> You don't need macros |
01:18:25 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=NHneNvULPgDu |
01:37:23 | * | def- joined #nim |
01:45:25 | FromDiscord | <amarevite> if the proc has a return type, `locals().fields` includes that as the last item↵which means i get a segfault (i assume because im trying echo a variable that doesnt exist yet)↵i tried appending `[0..^2]` but thats not working |
01:45:41 | FromDiscord | <amarevite> (edit) "if the proc has a return type, `locals().fields` includes that as the last item↵which means i get a segfault (i assume because im trying ... echo" added "to" |
01:46:05 | FromDiscord | <Elegantbeef> `for name, field in locals().fieldPairs: when name != "result": ....` |
01:47:56 | FromDiscord | <Elegantbeef> Tuples cannot be sliced which is why `[0..^2]` did not work |
01:49:15 | FromDiscord | <new_librarian> where should i put the mingw64 |
01:49:15 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=AFmPCiyNatUb |
01:51:07 | FromDiscord | <Elegantbeef> Why not `when field is Option`? |
01:53:08 | FromDiscord | <polylokh_39446> no reason except that I didn't know that worked |
01:54:38 | * | def- quit (Quit: -) |
01:55:10 | * | def- joined #nim |
02:00:57 | * | KhazAkar quit (Read error: Connection reset by peer) |
02:02:24 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=ArUKjToaTuIV |
02:02:58 | * | def- quit (Quit: -) |
02:04:01 | * | def- joined #nim |
02:11:46 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=IedyEiXBrUGH |
02:13:09 | FromDiscord | <amarevite> im trying implement the BoolorNothing idea from (this forum comment)[<https://forum.nim-lang.org/t/3124#:~:text=And%20a%20more%20Nim%2Dspecific%20way%2C%20with%20generics%20and%20static%20branching%2C%20no%20run%2Dtime%20overhead%20exc.%20file%20size%3A>] |
02:13:26 | FromDiscord | <amarevite> oh i swapped the parenthese and brackets my bad |
02:13:33 | FromDiscord | <amarevite> (edit) "(this" => "[this" | "comment)[<https://forum.nim-lang.org/t/3124#:~:text=And%20a%20more%20Nim%2Dspecific%20way%2C%20with%20generics%20and%20static%20branching%2C%20no%20run%2Dtime%20overhead%20exc.%20file%20size%3A>]" => "comment](<https://forum.nim-lang.org/t/3124#:~:text=And%20a%20more%20Nim%2Dspecific%20way%2C%20with%20generics%20and%20static%20branching%2C%20no%20run%2Dtime%20overhead%20exc.%20file%20size%3A>)" |
02:16:29 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=UIOPZUMkRyMq |
02:17:12 | FromDiscord | <polylokh_39446> (edit) "https://play.nim-lang.org/#pasty=FsbccIJFAAYT" => "https://play.nim-lang.org/#pasty=ObPULyDqcaOq" |
02:18:30 | FromDiscord | <polylokh_39446> you need that workaround, if you want it to be possible for the 'or' to resolve differently for different arguments |
02:19:20 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=qjLrZInhCVcP |
02:20:18 | FromDiscord | <amarevite> i dont recognize the syntax youre using with that proc↵what are the backets before the parentheses doing?↵what is that even called so i can look at the docs and learn about it? |
02:20:52 | FromDiscord | <polylokh_39446> 'or' makes the proc implicitly generic. The brackets make it explciitly generic and name what it's generic over. With that syntax, it's generic over A and B, which are both BoolOrNothing |
02:21:43 | FromDiscord | <polylokh_39446> it's introduced early in <https://nim-lang.org/docs/manual.html#generics> |
02:22:42 | FromDiscord | <polylokh_39446> the implicit 'or' generics have the limitation that BoolOrNothing can't resolve to bool for one param and EmptyType for another |
02:23:46 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=NqHnkjyFgqfe |
02:30:35 | FromDiscord | <polylokh_39446> it's still a compiler bug that that fails the way it does |
02:40:03 | * | def- quit (Quit: -) |
02:40:59 | * | def- joined #nim |
02:44:07 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=rNplOcEIlBqK |
02:44:40 | * | def- quit (Client Quit) |
02:45:36 | FromDiscord | <amarevite> i would like to be able to turn that `paramsBuilder` `locals().fieldPairs` thing into a proc I can call so I can reuse it more easily, but i struggled with getting that to work |
02:47:11 | * | def- joined #nim |
02:50:11 | * | def- quit (Client Quit) |
02:50:54 | * | def- joined #nim |
02:57:21 | FromDiscord | <Elegantbeef> Or you just do `distinct BoolOrNothing` |
02:59:47 | FromDiscord | <Elegantbeef> \Which is why distinct TypeClass\` exists |
03:00:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=CQXgmRNfdSbv |
03:02:09 | FromDiscord | <Elegantbeef> `paramBuilder.buildShiz(locales())` |
03:02:20 | FromDiscord | <Elegantbeef> where `proc buildShiz(buffer: string, data: tuple)` |
03:03:07 | FromDiscord | <Elegantbeef> `var string`\ |
03:07:16 | FromDiscord | <Elegantbeef> Can also just turn it into a template |
03:45:50 | * | SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev) |
03:46:16 | * | SchweinDeBurg joined #nim |
03:50:15 | * | def- quit (Quit: -) |
03:50:34 | * | def- joined #nim |
03:55:18 | FromDiscord | <amarevite> sent a code paste, see https://play.nim-lang.org/#pasty=VhBwRsRSCNOQ |
03:56:13 | FromDiscord | <Elegantbeef> `result.add name & "=" & $field` |
03:56:23 | FromDiscord | <Elegantbeef> Using format for simple formatting is silliness |
03:57:40 | FromDiscord | <Elegantbeef> PS there is `?` inside `std/uri` that takes in `(string, string)` and appends it to your code |
03:58:06 | FromDiscord | <Elegantbeef> so it'd be like `parseUri(serverAddress & "/Users).query(locals().paramsBuilder())` |
03:58:17 | FromDiscord | <Elegantbeef> Whoops |
03:58:29 | FromDiscord | <Elegantbeef> `parseUri(serverAddress & "/Users) ? locals().paramsBuilder()` |
03:58:34 | FromDiscord | <Elegantbeef> My brain filled the gap |
03:59:57 | FromDiscord | <amarevite> using `fmt()` was more of a consistency/readability thing but that works, thank you↵and i didnt know about `?` ill give that a try |
04:03:12 | FromDiscord | <amarevite> it's not working and i dont care enough to figure out what syntax im getting wrong but i might end up using that in the future, thank you |
04:03:30 | FromDiscord | <Elegantbeef> you need to emit `seq[(string, string)]` and import `uri` |
04:09:01 | FromDiscord | <amarevite> alright if `paramsBuilder()` returns a `(string, string)` tuple, `let endpoint:string = $(serverAddress.parseUri / "Users" ? locals().paramsBuilder)` works |
04:11:36 | FromDiscord | <amarevite> i dont have a stray `?` at the end of the url when there are no optional parameters set, but i find it much harder to read |
04:35:24 | * | def- quit (Quit: -) |
04:36:32 | * | def- joined #nim |
04:40:42 | * | def- quit (Client Quit) |
04:42:34 | * | def- joined #nim |
05:49:32 | * | coldfeet joined #nim |
05:51:16 | * | ntat joined #nim |
05:57:56 | * | def- quit (Quit: -) |
05:58:33 | * | def- joined #nim |
07:00:39 | * | lucerne quit (Ping timeout: 260 seconds) |
07:04:55 | FromDiscord | <xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=ibUZlDeWkYcS |
07:06:35 | FromDiscord | <xkonti> In other words I want all implementations of the abstractions (separate libraries) to execute those tests on themselves. Implementations could be OsFs, InMemoryFs, SftpFs, S3Fs, etc. |
07:08:02 | FromDiscord | <Elegantbeef> You want an external library to depend on your test architecture? |
07:08:45 | FromDiscord | <Elegantbeef> In the case of Nimble that means you want to have a `testAparatus` file then just have a template or proc that you call from an external library |
07:11:22 | FromDiscord | <xkonti> Yes. Think of it in a way of a set of tests that ensure that the implementation of the abstraction is correct. Library author doesn't need to write it themselves, they just use what's provided in the library they already depend on. |
07:11:40 | FromDiscord | <Elegantbeef> Make a proc or template that takes a `FileSystem` |
07:11:55 | FromDiscord | <Elegantbeef> Put it inside your `src` file |
07:11:55 | FromDiscord | <Elegantbeef> folder\ |
07:12:29 | FromDiscord | <Elegantbeef> then someone can do `tests/tosfs.nim` in their project and do `import filesystems/testaparatus; test(newOsFs())` |
07:16:41 | FromDiscord | <xkonti> That's awesome! For some reason I thought that test suites won't be valid if I won't "include" but simply "import". Thank you again @ElegantBeef , you seem to never sleep! |
07:17:00 | FromDiscord | <Elegantbeef> No I just don't have a life |
07:17:44 | * | om3ga joined #nim |
07:24:19 | * | def- quit (Quit: -) |
07:24:53 | * | def- joined #nim |
07:33:40 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/kBUJyESVzDpQ |
07:34:14 | FromDiscord | <Phil> (edit) "https://pasty.ee/iwxBwfWoiSNB" => "https://pasty.ee/IPNvNEKuHhxQ" |
07:35:25 | FromDiscord | <Phil> The problem is that Cold Observable shouldn't really contain a value. It should contain a callback function that gets executed for a given observer when it subscribes. |
07:35:53 | FromDiscord | <Phil> (edit) "subscribes." => "subscribes and emits values captured in the callback function to that observer." |
07:37:08 | * | lucerne joined #nim |
07:41:34 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/saNFaiQriCUX |
07:41:43 | FromDiscord | <Phil> (edit) "https://pasty.ee/QkpLQkktvaRm" => "https://pasty.ee/wWmermoBVFqr" |
07:42:22 | FromDiscord | <Phil> (edit) "https://pasty.ee/ufSwsuDNuHfM" => "https://pasty.ee/hSexzEQKFYAE" |
07:45:17 | * | redj_ quit (Ping timeout: 240 seconds) |
07:46:02 | * | redj joined #nim |
08:08:15 | FromDiscord | <Elegantbeef> @Phil have you written out a small demo with what was working to showcase the issue? |
08:08:35 | FromDiscord | <Elegantbeef> I read your words but given my lack of knowledge with RX I just scratch my head and go balder |
08:14:19 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=tkShdpIbFXtx |
08:15:26 | FromDiscord | <Elegantbeef> The expected output is what? |
08:16:08 | * | def- quit (Quit: -) |
08:16:58 | * | def- joined #nim |
08:17:45 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=VYGGAcWfDUVK |
08:19:03 | FromDiscord | <Elegantbeef> Huh |
08:19:32 | FromDiscord | <Phil> And there are ways around that I think, but they seem ugly as hell |
08:19:54 | FromDiscord | <Phil> Like implementing 2 "forward" procs or some shit and storing weird amounts of observers left and right |
08:20:20 | FromDiscord | <Elegantbeef> I'm so lost at how this works 😄 |
08:21:07 | FromDiscord | <Phil> Its "push" mechanisms as opposed to "pull".↵That's why reactive programming is a fairly different paradigm and breaks your brain a bit when you wrap your head around it. |
08:21:16 | FromDiscord | <Phil> (edit) "Its "push" mechanisms as opposed to "pull".↵That's why reactive programming is a fairly different paradigm and breaks your brain a bit when you ... wrap" added "first" |
08:21:21 | * | def- quit (Client Quit) |
08:21:59 | FromDiscord | <Elegantbeef> Well afaict it's just a stack of procedures |
08:22:04 | FromDiscord | <Phil> Its not "I need X, so I fetch from data", it is "data changes, so it informs everybody that it is and calls their callbacks that they registered with the individual piece of data, keeping them automatically in sync" |
08:22:34 | FromDiscord | <Elegantbeef> You add a procedure in the stack then all children get an event when a value changes |
08:22:36 | FromDiscord | <Phil> Yes but also more than that.↵Because you sometimes want to call the entire stack of procedures and sometimes you don't. |
08:23:03 | * | def- joined #nim |
08:23:33 | FromDiscord | <Phil> And there's 2 stacks: The stack of Observers and their callbacks (e.g. Observer1 and the observer that MapObservable will have registered with cold Observable), and the stack of procs that manipulate the piece of data (in this case that's just the map proc from MapObservable) |
08:23:44 | FromDiscord | <Phil> (edit) "and" => "with" |
08:24:38 | * | redj quit (Quit: No Ping reply in 180 seconds.) |
08:25:11 | FromDiscord | <Elegantbeef> So in the above example you push a value into cold or map? |
08:25:25 | FromDiscord | <Phil> In reply to @Elegantbeef "You add a procedure": Yes, that is true but only for Subjects where the value can actually change (Hot observable).↵In a cold observable the data that can be sent kind of already is known ahead of time. |
08:25:46 | FromDiscord | <Elegantbeef> Like in above the subscription causes a call to be made down the chain |
08:26:02 | FromDiscord | <Phil> In reply to @Elegantbeef "So in the above": The data exists in cold observable and it is the only source of data.↵Even when somebody subscribes to map observable, it itself does not hold data. It fetches data from the cold observable, transforms it and forwards that to the subscriber/observer |
08:26:09 | FromDiscord | <Elegantbeef> So it turns into `echo "Observable": map(map(map(5)))` |
08:26:10 | * | redj joined #nim |
08:27:13 | FromDiscord | <Phil> More: "Observer1: 5"↵"Observer2: anonymousMapProc(5)"↵"Observer3: anonymousMapProc(5)" |
08:27:40 | FromDiscord | <Phil> The "problem" with cold observables is just that they emit all their values on subscribes, which hot observables don't do because they don't contain data that way |
08:27:59 | FromDiscord | <Phil> But the subscribe should trigger only value emission to the one thing that subscribed and to nobody else |
08:28:32 | FromDiscord | <Phil> So if Observer3 subscribes, the process should be that only it receives transformed values from cold observable, nobody else does because they already subscribed and got their values |
08:28:46 | * | def- quit (Quit: -) |
08:29:22 | * | def- joined #nim |
08:30:31 | FromDiscord | <Elegantbeef> So in the case the of `next` it pushes `1` to what? |
08:30:46 | FromDiscord | <Elegantbeef> You omitted all of the plumbing |
08:41:12 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=KFsujoxMusoc |
08:41:48 | FromDiscord | <Phil> The problem is that this behaviour for hot observables is undesired for cold observables.↵Where I want the same behaviour but only for one single observer |
08:43:58 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/WbmsCxpXkXvu |
08:44:32 | FromDiscord | <Phil> (edit) "sent" => "Meanwhile the above (which is the Observer for the mapObservable onto the cold observable) will trigger everything always for all observers:↵- `onSourceCompletion` triggers the complete callback on all observers of the map observable↵- `onSourceError` already makes it visible that it forwards errors from source to all observers on the map-observable↵- `mapSubscription` uses the `forward` proc which forwards the value |
08:46:45 | FromDiscord | <Phil> I guess the solution would be that on subscribe of an observer to mapObservable, mapObservable creates on-the-fly a new "mapObserver" that is only there to forward values to the first observer |
08:47:00 | FromDiscord | <Elegantbeef> I was more saying that you left out the how the first example related to the second 😛 |
08:47:05 | FromDiscord | <Phil> The entire hot vs cold observable dichotomy is murdering me |
08:52:37 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=wSJIpCLNmEEE |
08:53:01 | FromDiscord | <Phil> Or rather you need to tell your parent observable "give me the values"; which in turn needs to tell its parent "Give me the values" etc. until you hit the cold root observable |
08:53:26 | FromDiscord | <Phil> And then only emit the values back to that one specific child that asked for values |
08:53:34 | FromDiscord | <Elegantbeef> Lol you still missed my point |
08:53:48 | FromDiscord | <Elegantbeef> Write the desired code using example A and B |
08:53:58 | FromDiscord | <Phil> Not really, it's just really fucking hard to explain |
08:54:03 | FromDiscord | <Elegantbeef> Plumb A into B |
08:54:08 | FromDiscord | <Elegantbeef> I don't want you to explain |
08:54:13 | FromDiscord | <Elegantbeef> I want to see the desired code |
08:55:13 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=lqgkewaXwDmT |
08:55:34 | FromDiscord | <Elegantbeef> Thank you 😄 |
08:57:39 | FromDiscord | <Elegantbeef> Much clearer how it's working |
08:58:01 | FromDiscord | <Elegantbeef> Or rather how it's supposed to work |
09:09:04 | * | def- quit (Quit: -) |
09:09:59 | * | def- joined #nim |
09:14:20 | FromDiscord | <nocturn9x> In reply to @juancarlospaco "looks like a realloc": well yeah but |
09:14:23 | FromDiscord | <nocturn9x> it's internal nim stuff |
09:14:28 | FromDiscord | <nocturn9x> how am I supposed to fix that lol |
09:15:34 | * | def- quit (Quit: -) |
09:15:55 | * | def- joined #nim |
09:17:42 | FromDiscord | <nocturn9x> I've tried several options |
09:17:54 | FromDiscord | <nocturn9x> `--mm:atomicArc` as well as `-d:useMalloc`ù |
09:17:56 | FromDiscord | <nocturn9x> (edit) "`-d:useMalloc`ù" => "`-d:useMalloc`" |
09:18:00 | FromDiscord | <nocturn9x> nothing seems to fix it |
09:18:10 | FromDiscord | <nocturn9x> it seems like a bug related to passing refs to another thread |
09:20:09 | FromDiscord | <nocturn9x> I'm trying to see if `--mm:boehm` works better |
09:27:48 | FromDiscord | <nocturn9x> that seems to have fixed it |
09:30:41 | FromDiscord | <ieltan> In reply to @nocturn9x "it seems like a": I think you can't pass refs to another threads unless you use something like `isolate` iirc |
09:32:35 | FromDiscord | <ieltan> But I've heard it's a pretty limited mechanism. Gotta go C++ style and use raw pointers or `SmartPtr[T]` |
09:33:49 | FromDiscord | <Phil> Hmmmm constructing single-use observers on the fly for that one occurrence at the end of the observable might be the way to go |
09:34:01 | FromDiscord | <Phil> At least I can vaguely imagine that approach |
09:35:31 | NimEventer | New thread by take1234: Unicode operators / Arrays, which size is know at run time, see https://forum.nim-lang.org/t/11526 |
09:36:30 | FromDiscord | <nocturn9x> In reply to @ieltan "I think you can't": huh |
09:41:08 | FromDiscord | <ieltan> the issue with threading in Nim is that it has been finally "nailed down" just very recently and there isnt many uptodate ressources on what you can do and cannot do with them right now |
09:41:19 | FromDiscord | <nocturn9x> yeah anyway it crashed again |
09:41:25 | FromDiscord | <nocturn9x> this is _so_ annoying |
09:41:43 | FromDiscord | <nocturn9x> it makes me kinda regret I learned nim :P |
09:42:37 | FromDiscord | <ieltan> fwiw, those are the "official" libraries to use for threads ↵https://github.com/nim-lang/threading↵https://github.com/Araq/malebolgia |
09:42:51 | FromDiscord | <nocturn9x> malebolgia is borked lol |
09:43:10 | FromDiscord | <ieltan> rip lol |
09:43:25 | FromDiscord | <nocturn9x> and the documentation for threading is just the API reference |
09:43:38 | FromDiscord | <ieltan> In reply to @nocturn9x "it makes me kinda": well this certaintly doesn't bode well for me as i'll need to use thread soon in my library |
09:44:09 | FromDiscord | <nocturn9x> can someone provide a simple example of sending off a function to a worker thread with shared references |
09:44:22 | FromDiscord | <nocturn9x> an example that works and isn't outdated and doesn't randomly crash for no reason |
09:44:50 | FromDiscord | <nocturn9x> the whole damn point of threads is to have shared state, otherwise I'd be spawning a process. The very idea of a thread-local heap is so stupid |
09:45:57 | FromDiscord | <nocturn9x> also afaik malebolgia implements SC, but I don't _need_ SC |
09:46:09 | FromDiscord | <nocturn9x> I need a separate worker thread that does something, prints to stdout and then exits |
09:46:30 | FromDiscord | <nocturn9x> I don't even care about the result or if it crashes. If it crashes, it crashed, too bad |
09:57:54 | FromDiscord | <odexine> what have you tried so far |
09:58:08 | FromDiscord | <odexine> iirc you will have to use sharedptr (threading/smartptrs) |
09:58:36 | FromDiscord | <nocturn9x> how do I make one? |
09:58:49 | FromDiscord | <nocturn9x> I have tried several things |
09:59:21 | FromDiscord | <nocturn9x> sent a long message, see https://pasty.ee/XMgITnSHAhMT |
10:02:14 | FromDiscord | <odexine> when you create the shared data, you first `isolate` it (std/isolation), then directly pass that isolated data into `newSharedPtr` (std/threading/smartptrs), i think |
10:02:59 | FromDiscord | <odexine> this data would be the non-ref version of what you want to share, so the direct data and not a ref |
10:03:24 | FromDiscord | <odexine> i dont have threading experience so im not too sure |
10:18:28 | * | xet7 quit (Ping timeout: 246 seconds) |
10:18:34 | FromDiscord | <nocturn9x> I need both the main thread and the worker thread to access the reference though |
10:19:00 | FromDiscord | <nocturn9x> there is a boolean variable and an `Atomic[bool]` object that needs to be shared |
10:24:10 | FromDiscord | <odexine> In reply to @nocturn9x "I need both the": they would share this access via the same sharedptr |
10:26:45 | FromDiscord | <nocturn9x> so |
10:27:25 | FromDiscord | <odexine> i dont know the behaviour of this mechanism with atomics |
10:28:06 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=cqCEsSFLfoRB |
10:28:14 | FromDiscord | <nocturn9x> or should I initialize it as a shared ptr to begin with |
10:29:40 | FromDiscord | <odexine> i would say to begin with |
10:30:20 | * | deadmarshal_ quit (Ping timeout: 268 seconds) |
10:34:19 | FromDiscord | <nocturn9x> okay |
10:34:33 | FromDiscord | <nocturn9x> so I won't need to wrap the `SearchManager` in an `Atomic[T]`? |
10:35:15 | FromDiscord | <odexine> im sorry i really dont know the behaviour of this with atomics |
10:35:53 | FromDiscord | <nocturn9x> where do I import `SharedPtr` from? |
10:35:59 | FromDiscord | <nocturn9x> `std/threading` doesn't seem to exist |
10:36:03 | FromDiscord | <nocturn9x> In reply to @odexine "im sorry i really": no problem |
10:36:54 | FromDiscord | <nocturn9x> https://github.com/henryas/nptr? |
10:41:22 | FromDiscord | <odexine> In reply to @nocturn9x "`std/threading` doesn't seem to": hm i think this is something to be installed first |
10:41:30 | FromDiscord | <odexine> so not std/threading but just threading/ |
10:41:42 | FromDiscord | <odexine> my bad i forgot |
10:41:58 | FromDiscord | <odexine> basically install this as a package in nimble https://github.com/nim-lang/threading |
10:42:59 | FromDiscord | <nocturn9x> so I should turn my entire `UCISession` into a shared ptr |
10:43:09 | FromDiscord | <nocturn9x> should `UCISession` be a value type instead of a ref then? |
10:43:50 | FromDiscord | <nocturn9x> I don't undertand how `Isolated` fits into this |
10:43:52 | FromDiscord | <odexine> if youre making it a shared ptr, i guess it should? maybe smth like UCISessionObj = object... then UCISession = SharedPtr[UCISessionObj[ |
10:43:54 | FromDiscord | <odexine> (edit) "SharedPtr[UCISessionObj[" => "SharedPtr[UCISessionObj]" |
10:43:56 | FromDiscord | <nocturn9x> how do I get the value out? |
10:44:23 | FromDiscord | <odexine> deref the ptr `[]` |
10:44:40 | FromDiscord | <odexine> you can get a mut/immut version |
10:44:51 | FromDiscord | <odexine> mutable VIEW |
10:45:09 | FromDiscord | <nocturn9x> so `session: SharedPtr[Isolated[UCISession]]`? |
10:45:13 | FromDiscord | <odexine> no |
10:45:16 | FromDiscord | <odexine> remove the isolated |
10:45:22 | FromDiscord | <nocturn9x> oke |
10:45:23 | FromDiscord | <odexine> the isolated part is only needed to construct the sharedptr |
10:45:29 | FromDiscord | <odexine> its not part of the type |
10:45:49 | * | FromDiscord quit (Remote host closed the connection) |
10:46:03 | * | FromDiscord joined #nim |
10:46:17 | FromDiscord | <nocturn9x> gotcha |
10:48:13 | FromDiscord | <nocturn9x> how do I initialize it tho |
10:48:34 | FromDiscord | <nocturn9x> do I just construct the value type, then isolate it and pass it to newSharedPtr? |
10:48:56 | * | def- quit (Quit: -) |
10:49:21 | FromDiscord | <odexine> yes |
10:49:28 | FromDiscord | <odexine> i believe so yes |
10:49:31 | * | def- joined #nim |
10:50:00 | FromDiscord | <nocturn9x> but `isolate` wants a `sink T` |
10:50:02 | FromDiscord | <nocturn9x> whatever that means |
10:50:30 | FromDiscord | <odexine> means you should not use that value type again after isolating |
10:51:27 | FromDiscord | <nocturn9x> okay, how do I make something into a `sink T` then |
10:51:50 | FromDiscord | <ieltan> it's supposed to be automatic |
10:51:52 | FromDiscord | <odexine> simply dont use it again after |
10:51:53 | FromDiscord | <odexine> yes |
10:52:05 | FromDiscord | <nocturn9x> `expression cannot be isolated` |
10:52:29 | FromDiscord | <odexine> does your data type have references |
10:52:34 | FromDiscord | <nocturn9x> yes, many |
10:52:40 | FromDiscord | <nocturn9x> that's kind of the point |
10:53:14 | FromDiscord | <ieltan> Remember what I said about isolated being limited lol |
10:53:24 | FromDiscord | <odexine> you cannot have references when youre isolating data |
10:53:29 | FromDiscord | <odexine> at all |
10:53:33 | FromDiscord | <odexine> anywhere |
10:53:40 | FromDiscord | <nocturn9x> it would be nice if the language implemented something that works instead of something that is only theoretical |
10:53:54 | FromDiscord | <odexine> "works" depends on the person |
10:54:02 | FromDiscord | <nocturn9x> no, "works" is a universal definition |
10:54:11 | FromDiscord | <odexine> i dont think so |
10:54:16 | FromDiscord | <nocturn9x> you do what all the other sane languages do and it works |
10:54:24 | FromDiscord | <nocturn9x> if it doesn't, your solution _does not work_ |
10:54:31 | FromDiscord | <odexine> sane is again dependent on the person |
10:55:00 | FromDiscord | <nocturn9x> we can talk about type safety and data race prevention all day |
10:55:04 | FromDiscord | <nocturn9x> but people don't write code in a lab |
10:55:07 | FromDiscord | <nocturn9x> they do so in the real world |
10:55:11 | FromDiscord | <nocturn9x> and the real world is sometimes dirty |
10:55:17 | FromDiscord | <nocturn9x> so not supporting that means being broken |
10:55:19 | FromDiscord | <nocturn9x> by definition |
10:55:30 | FromDiscord | <nocturn9x> languages are tools that are supposed to adapt to the users, not the other way around. |
10:55:34 | FromDiscord | <odexine> please provide such definition's source |
10:55:47 | FromDiscord | <nocturn9x> check out this thing called common sense |
10:55:50 | FromDiscord | <nocturn9x> it might amaze you |
10:55:50 | FromDiscord | <nocturn9x> lol |
10:55:52 | FromDiscord | <solitudesf> In reply to @nocturn9x "languages are tools that": adapt it then |
10:55:57 | FromDiscord | <odexine> In reply to @nocturn9x "check out this thing": common sense is clearly not found where you are |
10:56:04 | FromDiscord | <nocturn9x> In reply to @solitudesf "adapt it then": why do you think I'm working on my own language rofl |
10:56:23 | FromDiscord | <odexine> please tell us when you solve your threading problem in such language |
10:56:57 | FromDiscord | <nocturn9x> will do lol |
10:56:59 | FromDiscord | <ieltan> sent a code paste, see https://play.nim-lang.org/#pasty=YTqQpdKwCMre |
10:57:11 | FromDiscord | <nocturn9x> that isn't the problem |
10:57:20 | FromDiscord | <nocturn9x> the problem is that `YourDataType` has refs |
10:57:23 | FromDiscord | <nocturn9x> inside |
10:57:28 | FromDiscord | <nocturn9x> so it cannot be isolated, apparently |
10:58:05 | FromDiscord | <ieltan> welp rip pepperoni |
10:58:06 | FromDiscord | <nocturn9x> I tried that and it still fails to compile |
10:58:12 | FromDiscord | <nocturn9x> so 🤷 |
10:58:33 | FromDiscord | <odexine> nim supports message passing better versus the shared memory model |
10:58:50 | FromDiscord | <odexine> different languages have differing approaches to ideas |
10:58:52 | FromDiscord | <nocturn9x> I need shared ownership |
10:59:21 | FromDiscord | <nocturn9x> I don't make the rules, the UCI spec does, and to implement the `stop` command I need some way of telling my search to stop, which means it has to go in another thread |
10:59:41 | FromDiscord | <nocturn9x> the fact nim doesn't support the literal most basic use case of that is astonishing |
10:59:57 | FromDiscord | <odexine> ...i would say this can be easily implemented with message passing |
11:01:32 | FromDiscord | <nocturn9x> yes of course let me refactor my code because nim is opinionated about how threads should work (except they don't) |
11:01:54 | FromDiscord | <nocturn9x> building abstraction is one thing, but let me do "unsafe" things if I want to without breaking things |
11:02:03 | FromDiscord | <nocturn9x> but nope, apparently nim is too good for that, lol |
11:02:05 | FromDiscord | <odexine> if you want |
11:02:13 | FromDiscord | <odexine> i believe you can create a more raw shared pointer |
11:02:25 | FromDiscord | <nocturn9x> I've tried several things |
11:02:27 | FromDiscord | <odexine> https://nim-lang.org/docs/system.html#createShared%2Ctypedesc |
11:02:34 | FromDiscord | <nocturn9x> let's see if this works |
11:03:05 | FromDiscord | <odexine> chuck the type in, set the val with `varname[] = value`, deref is `[]` as is before |
11:03:53 | FromDiscord | <odexine> basically `var myptr = createShared(MyType); myptr[] = myvaluetype #[type == MyType]#` |
11:04:03 | FromDiscord | <odexine> this needs to be freed like in C |
11:04:20 | FromDiscord | <odexine> no isolated shit whatnot |
11:05:24 | FromDiscord | <nocturn9x> that looks like what I need |
11:05:51 | FromDiscord | <nocturn9x> can `MyType` hold `ref`s? |
11:05:55 | FromDiscord | <odexine> congrats, hope this is good enough, sorry about the common sense comment |
11:05:58 | FromDiscord | <odexine> In reply to @nocturn9x "can `MyType` hold `ref`s?": literally anything |
11:06:02 | FromDiscord | <nocturn9x> good |
11:06:02 | FromDiscord | <odexine> no restrictions at all |
11:06:14 | FromDiscord | <nocturn9x> In reply to @odexine "congrats, hope this is": it's okay, I'm a bit frustrated |
11:06:34 | FromDiscord | <nocturn9x> it's annoying enough to fight with a problem, but when the tooling you're using gets in the way it becomes extra annoying |
11:06:43 | FromDiscord | <odexine> any segfaults and null derefs at this point would prolly be your error since the compiler doesnt analyse anything |
11:06:58 | FromDiscord | <ieltan> I guess though accessing the refs from other thread will still subject you to some issues |
11:07:10 | FromDiscord | <odexine> In reply to @ieltan "I guess though accessing": i think this might be a problem too yes |
11:07:20 | FromDiscord | <odexine> the refs inside the type would still be local |
11:07:31 | FromDiscord | <nocturn9x> _pain_ |
11:07:33 | FromDiscord | <odexine> so i think all refs need to be ptrised |
11:07:36 | FromDiscord | <ieltan> Yeh |
11:07:58 | FromDiscord | <odexine> in which case why not just use the isolated thing? SharedPtrs are isolated compatible |
11:07:59 | FromDiscord | <ieltan> I was gonna say you'll drop the ref altogether for ptr |
11:08:10 | FromDiscord | <ieltan> So you'll be refactoring anyways |
11:08:17 | FromDiscord | <odexine> i dont think this is too big of a refactor |
11:08:22 | FromDiscord | <odexine> compared to message passing anyways |
11:08:30 | FromDiscord | <ieltan> True |
11:08:37 | FromDiscord | <nocturn9x> I suppose if it's gonna be a refactoring either way |
11:08:42 | FromDiscord | <nocturn9x> might as well use the higher level abstraction |
11:09:04 | FromDiscord | <nocturn9x> so I should just use `SharedPtr` everywhere instead of `ref`? |
11:09:22 | FromDiscord | <odexine> i think so, yes |
11:09:46 | FromDiscord | <nocturn9x> I can probably do away with another thing actually |
11:09:55 | FromDiscord | <nocturn9x> if I keep all the refs local to one thread |
11:10:00 | FromDiscord | <nocturn9x> that could work |
11:10:03 | FromDiscord | <nocturn9x> the main thread doesn't need them anyway |
11:10:35 | * | def- quit (Quit: -) |
11:12:09 | * | def- joined #nim |
11:28:08 | * | beholders_eye joined #nim |
11:29:39 | * | def- quit (Quit: -) |
11:29:58 | * | def- joined #nim |
11:37:21 | * | deadmarshal_ joined #nim |
11:49:01 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=KhfAsScPefaX |
11:51:36 | FromDiscord | <ezquerra> In reply to @mratsim "are you using the": @mratsim, I am looking at speeding up the convolve proc in arraymancer and I remember this old reply of yours. Can you share an example of how to enable `omp simd` when using `omp_parallel_blocks`? I couldn't find any examples on the arraymancer codebase. Probably I did not search for the right thing... |
11:54:11 | * | nyeaa49284230101 quit (Quit: The Lounge - https://thelounge.chat) |
11:56:17 | * | nyeaa49284230101 joined #nim |
12:01:07 | FromDiscord | <nocturn9x> In reply to @nocturn9x "the main thread doesn't": jk it does |
12:01:14 | FromDiscord | <nocturn9x> ugh this is so freaking annoying |
12:51:15 | * | def- quit (Quit: -) |
13:10:11 | * | def- joined #nim |
13:43:58 | * | beholders_eye quit (Ping timeout: 268 seconds) |
14:03:02 | FromDiscord | <Phil> @ElegantBeef I just did it. It screwed me up a little bit, but my entire test-suite still runs and the new tests do as well |
14:03:31 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=pAmOdZzkpcKj |
14:09:52 | * | gst joined #nim |
14:12:31 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=WPglZjsoQroC |
14:15:24 | gst | is there a way to unordered enum? |
14:34:43 | FromDiscord | <Phil> I am not familiar with the term I'll admit. You can do hole-y enums, you can define the number values explicitly |
14:34:54 | FromDiscord | <Phil> (edit) "I am not familiar with the term I'll admit. You can do hole-y enums, you can define the number values ... explicitly" added "for a given enum-value" |
14:35:12 | * | lucasta joined #nim |
14:39:31 | FromDiscord | <odexine> enums are always ordinal |
14:39:49 | FromDiscord | <odexine> not sure what you mean by unordered, i dont understand the benefits to having one be unordered |
14:40:04 | gst | hole enums are supported yes and I am using them, my problem is that currently nim requires that the values are ordered incrementally |
14:40:22 | gst | unordered I mean for example, x = 1, then y = 0 |
14:41:37 | gst | my usecase is protocol implementation, it is much nicer to keep the names in the order of the documentation regardless of the values |
14:42:28 | FromDiscord | <odexine> i dont think so |
14:42:40 | FromDiscord | <odexine> i think nim should allow it for when all values are specified but it doesnt so |
14:43:40 | gst | https://play.nim-lang.org/#pasty=NsXVDYjOvkjz |
14:45:38 | gst | odexine, I agree, I think it should be possible as, when all values are specified, the order requirement is useless and changes nothing to the result. but currently it fails. |
14:46:08 | FromDiscord | <odexine> should check if there is an issue filed, see any discussion |
14:46:09 | gst | I was wondering if there is a pragma or some trick around this. |
14:47:03 | gst | this is the closest I found, https://github.com/nim-lang/Nim/issues/1043, it was not fixed. |
14:50:37 | FromDiscord | <odexine> same, when i searched |
14:50:45 | FromDiscord | <odexine> seems like no one has raised another issue |
15:05:19 | * | def- quit (Quit: -) |
15:05:41 | * | def- joined #nim |
15:19:25 | FromDiscord | <z3ntl3> abc |
15:19:57 | FromDiscord | <z3ntl3> 🫡 |
16:51:04 | * | def- quit (Quit: -) |
16:52:21 | * | coldfeet quit (Remote host closed the connection) |
16:53:40 | * | def- joined #nim |
16:56:42 | * | def- quit (Client Quit) |
16:58:43 | * | def- joined #nim |
17:16:36 | * | krux02 joined #nim |
17:20:58 | * | progranner joined #nim |
17:28:06 | * | xet7 joined #nim |
18:04:56 | * | KhazAkar joined #nim |
18:26:50 | * | def- quit (Quit: -) |
18:27:35 | * | def- joined #nim |
18:31:18 | * | def- quit (Client Quit) |
18:33:29 | FromDiscord | <nocturn9x> are `Atomic`s references? |
18:33:50 | FromDiscord | <nocturn9x> still trying to debug the issue with ARC and threads |
18:33:52 | FromDiscord | <nocturn9x> to no avail |
18:34:27 | * | def- joined #nim |
18:37:58 | FromDiscord | <nocturn9x> the question I have is why is it segfaulting in danger/release mode and not in debug mode? |
18:39:06 | FromDiscord | <Phil> In reply to @nocturn9x "are `Atomic`s references?": I don't think they are, at least from my time staring at the threading package and making it free of data-races I don't recall that being a requirement |