Post 9vwezzvAK9To9rupyy by aeonofdiscord@icosahedron.website
(DIR) More posts by aeonofdiscord@icosahedron.website
(DIR) Post #9vwezzvAK9To9rupyy by aeonofdiscord@icosahedron.website
2020-06-10T16:14:50Z
0 likes, 1 repeats
is there a way to automatically detect/prevent list modification during iteration? no joke answers ta
(DIR) Post #9vwf95fOKbysaGsChM by gid@cybre.space
2020-06-10T16:15:54Z
0 likes, 0 repeats
@aeonofdiscord in general or in a particular language?
(DIR) Post #9vwf95q1h4UJ7FqhH6 by aeonofdiscord@icosahedron.website
2020-06-10T16:16:21Z
0 likes, 1 repeats
@gid currently C++ but I've had some form of this problem in basically everything
(DIR) Post #9vwfCMZ1xoVnrKSUT2 by aeonofdiscord@icosahedron.website
2020-06-10T16:17:04Z
0 likes, 1 repeats
@gid usually I have to manually copy lists and stuff but it's easy to forget
(DIR) Post #9vwfOtMppNR74VjDpg by impiaaa@octodon.social
2020-06-10T16:18:40Z
0 likes, 0 repeats
@aeonofdiscord it must be possible, since java does it. I would assume either it holds a lock during iteration that it checks in any mutator, or maybe hold a version cookie that's checked on the get-next method
(DIR) Post #9vwfOtYX7snHenCZ4C by aeonofdiscord@icosahedron.website
2020-06-10T16:19:11Z
0 likes, 1 repeats
@impiaaa huh, I was sure I'd had this problem in java as well tbh
(DIR) Post #9vwfUXYdpOqPATwapM by aeonofdiscord@icosahedron.website
2020-06-10T16:20:20Z
0 likes, 1 repeats
@impiaaa oh wait, I mean like...detecting it earlier than that, I think. like yeah I can detect it at runtime but I want to avoid it happening entirely
(DIR) Post #9vwfqN5NRXxV3ofLCC by cpsdqs@icosahedron.website
2020-06-10T16:24:16Z
0 likes, 1 repeats
@aeonofdiscord i dunno if this is about a specific language but e.g. rust creates an immutable reference to the source list and borrow chk then disallows mutable referencesi guess at runtime you could have some sort of RwLock?
(DIR) Post #9vwgCkSjD5lhvtG4em by impiaaa@octodon.social
2020-06-10T16:26:53Z
0 likes, 0 repeats
@aeonofdiscord oh, detecting that statically sounds difficult without language support (I'm sure rust does it…). Maybe a macro that invalidates mutators (somehow???)? Maybe simulate borrow checking with RAII and keep iteration and mutation in mutually exclusive proxies?
(DIR) Post #9vwgCkiKH6FGiGYWy8 by aeonofdiscord@icosahedron.website
2020-06-10T16:28:15Z
0 likes, 1 repeats
@impiaaa yeah, I guess I'm just looking for some way to, idk, wrap the container so it's super-obvious if I'm about to do this. the proxy thing sounds potentially workable
(DIR) Post #9vwgf4ftedgcjEvNya by aeonofdiscord@icosahedron.website
2020-06-10T16:33:27Z
0 likes, 1 repeats
@impiaaa ahhhh yeah I actually think I have an interface for this now, too late for this project without breaking everything but I'll prob use it in the future. cheers
(DIR) Post #9vwibheP07NkMOkIUa by halcy@icosahedron.website
2020-06-10T16:55:04Z
0 likes, 1 repeats
@aeonofdiscord other than making a deep copy?
(DIR) Post #9vwidAKhqWhJbfELvU by aeonofdiscord@icosahedron.website
2020-06-10T16:55:28Z
0 likes, 1 repeats
@halcy I'd want a shallow copy in this case, which is fine, it's just sometimes I forget to do it
(DIR) Post #9vwijC7s5oeguA6NqS by aeonofdiscord@icosahedron.website
2020-06-10T16:56:30Z
0 likes, 1 repeats
@halcy (or I change some behaviour later on which introduces an uncommon case that ends up modifying the list during iteration deep in some call stack)
(DIR) Post #9vwikSEdgWPn9jrtDs by halcy@icosahedron.website
2020-06-10T16:56:45Z
0 likes, 1 repeats
@aeonofdiscord well, I got nothing. Good luck!
(DIR) Post #9vwioypASe0PO77128 by aeonofdiscord@icosahedron.website
2020-06-10T16:57:32Z
0 likes, 1 repeats
@halcy I think I have a solution for this that involves automatically making copies in certain situations but I'm gonna have to mess around with it