You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Ops class assessible from sub-ops classes (i.e. MathOps) #147
I'm writing some Kotlin extension functions, which if you aren't familiar with them, take this as an argument like python's self but hide it. Essentially adding a function to MathOps or one of the other ops classes, like this:
However, if you look at the above snippet, there's a problem: there is no constant in scope, it's in Ops and not accessible from MathOps. This happens whenever you want to use ops from other holder classes. I would like to make Ops accessible from the sub-ops classes, probably just by passing it as a parameter to the constructor (which is package private and only called from Ops). You could pass it instead of the Scope and get the scope from it if you make Ops' scope package private. I most likely won't be the only person creating extension functions that want to use other ops.
Maybe a solution that would involve less changes overall would be add an accessor to the parent Ops from child ops classes like MathOps?
You might endup having cyclic dependency issues if you replace Scope by Ops in the signature of the ops factories, because Ops is generated later by scanning these factories by annotation processing.
Sorry @rnett , I've reread your proposal and I've misinterpreted it, what you are suggesting is actually pretty much the same as I did, so yes please go ahead!
Activity
karllessard commentedon Nov 14, 2020
Maybe a solution that would involve less changes overall would be add an accessor to the parentOpsfrom child ops classes likeMathOps?You might endup having cyclic dependency issues if you replaceScopebyOpsin the signature of the ops factories, becauseOpsis generated later by scanning these factories by annotation processing.karllessard commentedon Nov 14, 2020
Sorry @rnett , I've reread your proposal and I've misinterpreted it, what you are suggesting is actually pretty much the same as I did, so yes please go ahead!