We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Like for #153 there is a generic frule for default constructors. It relies on the arguments being the same as the fields so would have to detect that.
Its basically:
function frule(::Type{P}, args..., _, dargs...) where P y = P(args...) dy = Composite{P}(; zip(fieldnames(P, dargs)...) end
the more serious implementation might be:
function frule(::Type{P}, all_args...) where P nargs = fieldcount(P) length(all_args) == 2nargs + 1 || return nothing args = @inbounds all_args[1:nargs] all(typeof.(args) .== fieldtypes(P)) || return nothing dargs = @inbounds all_args[end-nargs : end] # skip dself as constructors never functors y = P(args...) dy = Composite{P}(; zip(fieldnames(P, dargs)...) end
But this may well need to be written as a generated function if it doesn't constant fold good.
The text was updated successfully, but these errors were encountered:
Related:
Sorry, something went wrong.
convert
Array
No branches or pull requests
Like for #153
there is a generic frule for default constructors.
It relies on the arguments being the same as the fields so would have to detect that.
Its basically:
the more serious implementation might be:
But this may well need to be written as a generated function if it doesn't constant fold good.
The text was updated successfully, but these errors were encountered: