-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow const
syntax in the @agent
macro
#728
Comments
Hm, unfortunately this syntax is a breaking change. But maybe there is a simple way to modify Allowing the |
const
syntax in the @agent
macro
So far I asked in slack - the suggestion was to look at |
This would indeed be very nice. Also to be able to use |
I've thought about this a lot and I think I will revert the decision of |
With #831 we have a sort of solution also for this one: use something like @agent A NoSpaceAgent begin
f1::Int = 40
f2::Int
consts = :f1, :f2
end and rework a little the macro, there shouldn't be breaking changes |
Actually I think the decision requires some thoughts, we can do it with what I mentioned in the previous comment: @agent A NoSpaceAgent begin
f1::Int
f2::Int
consts = (:f1, )
end or instead we could use something like @agent A NoSpaceAgent begin
const_f1::Int # or any other special prefix instead of const_
f2::Int
end The first seems more elegant to me, but then we need to find a suitable more complex regex (or metaprogramming) than in the second case to restructure the result in the struct before interpolation (which means be more careful about edge cases): @kwdef mutable struct A
id::Int
const f1::Int
f2::Int
end thoughts @Datseris ? No solutions here allows to directly use the I would go with the first way since it seems better syntactically |
I use a variant of Agents.jl
@agent
macro in AlgebraicAgents.jl. @slwu89 recently suggested to me the following idea (issue 4, AlgebraicAgents.jl) which clearly applies also to Agents.jl:Any agent type being made from calling
@agent
is mutable, but with Julia versions >= 1.8 now we can specify particular fields as being const, which can help bring performance closer to immutable structs (see https://docs.julialang.org/en/v1/manual/types/#Mutable-Composite-Types). It would be nice to let users to specify fields as const if they like, to improve performance.To the best of my knowledge,
@agent
macro syntax is not compatible withconst field
declarations - at least I have been getting some parsing errors, as we need thestruct
wrap.As a workaround, I proposed that the syntax of
@agent
could change to the following:You may review a candidate implementation there.
Would it be possible to achieve the same functionality without the change of syntax?
The text was updated successfully, but these errors were encountered: