Skip to content

make splitdef use a mutable struct #29

@rfourquet

Description

@rfourquet

Basically the same as FluxML/MacroTools.jl#116.
The motivation is not at all speed, but

  1. def.name instead of def[:name] would be nicer (make splitdef return a NamedTuple FluxML/MacroTools.jl#116 (comment))
  2. the keys order can be controlled:
 julia> splitdef(:(function f(x::T; y) where T end))
Dict{Symbol, Any} with 6 entries:
  :args        => Any[:(x::T)]
  :body        => quote…
  :kwargs      => Any[:y]
  :head        => :function
  :whereparams => Any[:T]
  :name        => :f

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions