JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
717 stars 115 forks source link

Make it possible to redefine agents #907

Closed Tortar closed 7 months ago

Tortar commented 9 months ago

Problem mentioned more than one time in #884 e,g, https://github.com/JuliaDynamics/Agents.jl/issues/884#issuecomment-1751219391

Didn't know about that but there are actually two packages for this!!

https://github.com/BeastyBlacksmith/ProtoStructs.jl and https://github.com/FedericoStra/RedefStructs.jl

Tortar commented 9 months ago

Still these packages are in early dev and they need some more work to be fully usable with the agent macro. Will try to work on that

Datseris commented 9 months ago

Just a comment: Generally speaking one should not try too hard to "hack-away" fundamental limitations of the language in used packages. The simpler the package, the better. The design of Agents.jl has always been "basic Julia structures is all you need". The @agent macro goes beyond basic Julia by providing field inheritance, but we should be careful to not go too far. This doesn't mean that we shouldn't try to make agent types redefinable, but we also should be careful. Weight the pros and cons, and departing from the core language is a con with deep impact.

Tortar commented 9 months ago

This shoudn't be done inside Agents.jl itself for sure. Talking about ProtoStructs.jl since it seems a bit better than the other: the proto macro is just a development experience improvement which should be just mentioned in the docs somewhere so that if the user wants to apply that to the agent macro when developing it is possible to do so (the macro should be deleted when the work is finished since I think it creates performance issues). But before these two issues must be resolved https://github.com/BeastyBlacksmith/ProtoStructs.jl/issues/16 and https://github.com/BeastyBlacksmith/ProtoStructs.jl/issues/15 for full compatibility.

Tortar commented 7 months ago

I thought about this a bit, and unfortunately...I guess we will leave this issue to Julia devs.

Including the proto macro in this repo could have some severe disadvantage and don't integrate too well, at least I improved this macro quite a bit in this journey :D