JuliaDynamics / Agents.jl

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

Update to v0.2 of MixedStructTypes #972

Closed Tortar closed 5 months ago

Tortar commented 5 months ago

Fixes #968 Fixes #967

I slightly changed the syntax in that package, and also solved some issues with the macros

Tortar commented 5 months ago

If I can kindly ask you George, can you give me your opinion on the syntax of https://github.com/JuliaDynamics/MixedStructTypes.jl? Do you think it is okay? :-)

Tortar commented 5 months ago

mmh actually again an instance of https://github.com/JuliaDynamics/Agents.jl/issues/963

Datseris commented 5 months ago

Hi @Tortar I am available today. I Can review. But this still seems to be WIP, right? What would you like me to review from MixedStructTypes.jl?

Tortar commented 5 months ago

It should be ready for review now actually

Tortar commented 5 months ago

nevermind for MixedStructTypes.jl, it seems okay to me

Datseris commented 5 months ago

right, so what's the status now? what's the syntax, if it changed?

Tortar commented 5 months ago

No I mean no changes still to the syntax, will do that in a separate PR, I meant to say that the syntax changed in MixedStructTypes.jl and so I adjusted the macro to the new one

Datseris commented 5 months ago

Right. but what is the syntax change? It is not obvious to me by just looking at the readme.

Tortar commented 5 months ago

From e.g. :

@sum_struct_type @kwdef A{X} <: AbstractA{X} begin
           mutable struct B{X}
               a::Tuple{X, X} = (1,1)
               b::Tuple{Float64, Float64} = (1.0, 1.0)
           end
           mutable struct C
               a::Tuple{Int, Int} = (2,2)
               d::Int32 = Int32(2)
           end
           mutable struct D
               a::Tuple{Int, Int} = (3,3)
               const c::Symbol = :s
           end
           struct E{X}
               a::Tuple{X, X} = (3,3)
           end
       end

to:

@sum_structs A{X} <: AbstractA{X} begin
           @kwdef mutable struct B{X}
               a::Tuple{X, X} = (1,1)
               b::Tuple{Float64, Float64} = (1.0, 1.0)
           end
           @kwdef mutable struct C
               a::Tuple{Int, Int} = (2,2)
               d::Int32 = Int32(2)
           end
           @kwdef mutable struct D
               a::Tuple{Int, Int} = (3,3)
               const c::Symbol = :s
           end
           @kwdef struct E{X}
               a::Tuple{X, X} = (3,3)
           end
       end

In practice a shorter name for the macro and a finer control on kwdef (you can apply it to just some structs if you want)

This makes the macros even more similar to just write the structs and apply the macro afterwards

Datseris commented 5 months ago

right, but how is its application Agents.jl? do the subagents start with @subagent or not anymore? I guess its better if they don't? (I also find odd the usage of @kwdef . can you remove it?) I guess @kwdef is not in the Agents.jl version.

Tortar commented 5 months ago

No changes to the Agents.jl syntax were made, I haven't applied the new syntax @subagent, etc..., I will do it in another PR, so I think this PR is good to go as it is