Skip to content
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

Re-factor expression handling #230

Closed
pdeffebach opened this issue Mar 7, 2021 · 2 comments
Closed

Re-factor expression handling #230

pdeffebach opened this issue Mar 7, 2021 · 2 comments
Milestone

Comments

@pdeffebach
Copy link
Collaborator

Some of the expression handling code is very old and kind of confusing.

It may also be less performant. This stuff:

onearg(e, f) = e.head == :call && length(e.args) == 2 && e.args[1] == f

mapexpr(f, e) = Expr(e.head, map(f, e.args)...)

replace_syms!(x, membernames) = x
replace_syms!(q::QuoteNode, membernames) =
    replace_syms!(Meta.quot(q.value), membernames)
replace_syms!(e::Expr, membernames) =
    if onearg(e, :^) # TODO: Delete this branch after deprecation period
        @warn "^() for escaping `Symbol`s is deprecated, use syms() instead"
        e.args[2]
    elseif onearg(e, :syms)
        e.args[2]
    elseif onearg(e, :_I_) # TODO: Delete this branch after deprecation period
        @warn "_I_() for escaping variables is deprecated, use cols() instead"
        addkey!(membernames, :($(e.args[2])))
    elseif onearg(e, :cols)
        addkey!(membernames, :($(e.args[2])))
    elseif e.head == :quote
        addkey!(membernames, Meta.quot(e.args[1]) )
    elseif e.head == :.
        replace_dotted!(e, membernames)
    else
        mapexpr(x -> replace_syms!(x, membernames), e)
    end

Should we use a more contemporary package to deal with expressions? Like MacroTools?

Or if it isn't broken, should we not fix it? I don't know very much about MacroTools but I'm sure I could learn.

@pdeffebach pdeffebach added this to the Decision 1.0 milestone Mar 7, 2021
@pdeffebach
Copy link
Collaborator Author

I propose I re-factor the expression handling in preparation for #291 . After I have re-factored to use MacroTools.postwalk, I can implement an @astable macro better.

@pdeffebach
Copy link
Collaborator Author

Closed via #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant