4 ms·
This reminds me of _The Billion-Dollar Fix: Safe Modular Circular Initialisation with Placeholders and Placeholder Types_ https://dl.acm.org/doi/abs/10.1007/978
by compressedgas 10mo ago
This reminds me of _The Billion-Dollar Fix: Safe Modular Circular Initialisation with Placeholders and Placeholder Types_ https://dl.acm.org/doi/abs/10.1007/978-3-642-39038-8_9 https://dl.acm.org/doi/abs/10.1007/978-3-642-39038-8_9 https://ecs.wgtn.ac.nz/foswiki/pub/Main/TechnicalReportSeries/ECSTR12-25.pdf https://ecs.wgtn.ac.nz/foswiki/pub/Main/TechnicalReportSerie...
Apywire reports it can't handle circular dependency: https://github.com/alganet/apywire/blob/1c9a39df36a9385d8b34175959c970669faa559c/apywire/wiring.py#L414C19-L414C38 https://github.com/alganet/apywire/blob/1c9a39df36a9385d8b34...
- gaigalas 10mo agoThe code you pointed to in apywire is related to circular dependencies in constant scalar types. Like a printf that is meant to replace %s with its whole output (therefore, impossible). However, apywire also throws CircularWiringError if you make objects that have circular dependencies as well (we do not solve it). The paper seems like a worth read. I skimmed over it, and it seems like an interesting solution: proxy-like objects that only allow construction-type interaction but no method calls or property access until the container fully realizes the instance. Our overall syntax allows for that implementation in the future, and python in theory is flexible enough to allow us to go for that route. It does seem like a lot of work, but I might try to do it (for objects, for the scalars it's impossible). I was looking for a nice feature to make the project more distinct! Thanks for your feedback!
- compressedgas 10mo agoIt is around where CircularWiringError is thrown from the implementation of topological sort. If the instantiation of the objects was not lazy, the topological sort would have been applied to the entire dependency graph. As it is lazy, with objects being created when they are accessed CircularWiringError can be thrown upon access. I think this should never happen as it should be checked for in the Wiring constructor though the application of the topological sort.
- gaigalas 10mo agoYou are right, that is an overlook on my part. Throwing on the constructor makes much more sense than upon access. Thanks!
- gaigalas 10mo agoAgain, thanks for your feedback. Moving the topological sort not only yileded a better experience but actually simplified the code and thread model. I've made the changes and they'll be on the next version.