Skip to content

eventual refactoring of macros using MacroTools.jl #1433

Closed
@ExpandingMan

Description

@ExpandingMan

As I've worked on the 0.18 update for 1.0 I became somewhat familiar with the JuMP macro code (both in 0.18 and in master). JuMP probably has some of the most complicated macro code of anyexisting Julia package. This is only natural as JuMP is essentially a domain specific language. As more macro features are added this code will get more and more difficult to manage. Perhaps it's just me but I find macro code to be far more difficult to develop than non-metaprogramming related code, not least because stack traces tend to be of somewhat inferior quality and special tools such as @macroexpand are needed even for simple things like determining what code actually executed.

I'd like to suggest that in the future JuMP move toward using MacroTools.jl. This package drastically simplifies metaprogramming. I have argued many times that this package desperately needs to be in stdlib, but unfortunately that hasn't happened yet. Another advantage of using MacroTools is that it moves most of the dependency on Julia's AST out of JuMP itself and into that package.

Obviously since JuMP has a large amount of complicated macro code it would be a daunting task to just sit down and rewrite it all at once. I'd like to suggest that MacroTools first be introduced to some of the "leaf" functions such as _localvar or extract_kwargs (likely some of these functions can ultimately be eliminated completely). My hope is that gradually over time as macros.jl becomes shorter it will become more apparent how to refactor the workhorse parts of the existing code.

I'd like to make a PR at some point to get this process going, but of course before I spend time working on it I'd like to see whether there is any receptiveness to this idea, and to hear suggestions others may have about how it might be best to simplify the macro code (if indeed you guys are open to that idea).

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions