ACEsuit / WithAlloc.jl

A simple Bumper convenience extension
MIT License
1 stars 0 forks source link

Macro to generate allocating interface #7

Open cortner opened 3 months ago

cortner commented 3 months ago

Implement a macro that does the following automatically:

function myfun!(out1, out2, args...) 
   # do some stuff
   return out1, out2
end

function whatalloc(::typeof(myfun!), args...) 
    # ... cf docs
    return alc1, alc2
end

# generate the following function with a macro: 
function myfun(args...)
     alc1, alc2 = whatalloc(myfun!, args...) 
     out1 = zeros(alc1...)
     out2 = zeros(alc2...)
     return myfun!(out1, out2, args...)
end