-
Notifications
You must be signed in to change notification settings - Fork 11
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
make splitdef
use a mutable struct
#29
Comments
splitdef
use a mutabe struct
splitdef
use a mutable struct
I can get behind this but there are a couple of things to call out:
|
I had roughly the same ideas for your first two points, but it depends if you implied |
While working through this, I see a design choice to make that I would like to discuss before continuing. I made a struct like this: Base.@kwdef mutable struct SplitDef <: AbstractDict{Symbol, Any}
head::Symbol = :function
name::Union{Symbol, Nothing} = nothing
params::Union{Vector, Nothing} = nothing
args::Union{Vector, Nothing} = nothing
kwargs::Union{Vector, Nothing} = nothing
rtype::Any = nothing
whereparams::Union{Vector, Nothing} = nothing
body::Any = nothing
end where
I currently much prefer 2). Setting an empty vector instead of Do you see alternatives? |
Approaching this from the perspective of the user of I would suggestion with the |
Basically the same as FluxML/MacroTools.jl#116.
The motivation is not at all speed, but
def.name
instead ofdef[:name]
would be nicer (makesplitdef
return aNamedTuple
FluxML/MacroTools.jl#116 (comment))Here it would be nicer to have
:head
and:name
first, then:args
and:kwargs
.A
mutable struct
is nicer than a named tuple because named tuples don't print on multiple lines, and anyway it's nicer to be able to mutate the object.For backward compatibility, such a
SplitDef
object could be made<: AbstractDict
.I volunteer to implement this if there is support.
The text was updated successfully, but these errors were encountered: