FluxML / FluxML/MacroTools.jl

Canonicalize function expression

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
320
Forks
84
PR merge metrics
No merged PRs in 30d

Description

When I write macros acting on function expressions I often write a lot of code such that the macro works for different types of declarations. E.g:

```
@some_macro a(x)=1
@some_macro function a(x)
1
end

# or
@some_macro function a{T <: Float64}(x::T)
1
end
@some_macro function a(x) where T <: Float64
1
end
```

Since this leads to a lot of unnecessary macro code it would be nice if there was some sort of canonical form in which an expression could be converted to. MacroTools already has a function `longdef` that does part of what is needed, but does not rewrite `where` expressions. Do we want a function `canonicaldef` or something similar that rewrites functions with `where` syntax into the regular `fn_name{targs...}(args...)` syntax? If that is the case is another proposals for the naming beside `canonicaldef`? I would be happy to contribute that function in a pull request.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.