ExprTools.jl
ExprTools.jl copied to clipboard
Light-weight expression manipulation tools
Basically the same as https://github.com/FluxML/MacroTools.jl/issues/116. The motivation is not at all speed, but 1) `def.name` instead of `def[:name]` would be nicer (https://github.com/FluxML/MacroTools.jl/issues/116#issuecomment-511929773) 2) the keys order can be controlled: ```...
```julia julia> signature(methods(read)[12]) # read(filename::AbstractString, args...) in Base at io.jl:460 ERROR: DomainError with (Vararg{Any}, Core.TypeofVararg): not a valid type-param Stacktrace: [1] name_of_type @ C:\Users\nicho\.julia\packages\ExprTools\4kw5E\src\method.jl:146 [inlined] [2] (::ExprTools.var"#13#14")(name::Symbol, type::Core.TypeofVararg) @ ExprTools...
However, `signature(type_tuple)` works. ``` julia> @generated foo(x) = :(1+1) foo (generic function with 1 method) julia> signature(only(methods(foo)).sig) Dict{Symbol, Any} with 2 entries: :name => :(op::typeof(foo)) :args => Expr[:(x1::Any)] julia> signature(only(methods(foo)))...
Given the dict returned by `splitdef` it would be useful to have a function the generate a `Expr(:call,...` to the function that is defined. e.g. ```julia julia> k = splitdef(:(f(x::Int)...
I happened to build two macros that uses `splitdef` and `combinedef` functions. When I tried to use them together, `splitdef` gives an error. Looks like it doesn't expand the inner...
Follow up to #1 Right now the tests on structs are disabled because 1) Structs can't be declared in testsets, and that makes it kind of unreadable. 2) I am...
Follow up for once #1 is merged. Adding keyword support. It is just really fiddly. The information is there but its not in a very easy to acess form: ```julia...
This is a follow up for once #1 is complete. At least of of now it never generates the return type. But it could, it would requires some inspecting of...