Nemocas / AbstractAlgebra.jl

Generic abstract algebra functionality in pure Julia (no C dependencies)
https://nemocas.github.io/AbstractAlgebra.jl/dev/index.html
Other
172 stars 63 forks source link

Better introspection for `@attr` methods #1787

Open fingolfin opened 2 months ago

fingolfin commented 2 months ago

It would be nice if there was a way to reach the "inner" function for a method declared with @attr.

So e.g. if we have

@attr Any function bla(x::Int)
   X
   Y
   Z
end

then it would be nice if there was a way to call the code X ; Y; Z in the definition of bla, while bypassing the attribute based caching of the return value.

This is useful so that one can run e.g. @code_warntype on it, or generally invoke it while bypassing the caching logic which @attr inserts around it.

lgoettgens commented 2 months ago

There is of course __compute_bla__(x::Int) that does the internal computation of the @attr macro there. We could add something like this to the @attr docstring, and maybe add a note that this construction may change between different AA versions, so people don't use it in normal code.