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
Cannot create op from signature with raw op type #220
@ctrueden thanks for raising this issue. I've thought about it a fair bit, and did a little prototyping to try and fix this issue, and I can't come up with a solution that I like - you get drawn into casting issues so easily. Here's what I've been thinking about:
public <T> TopFromSignature(finalStringsignature, finalClass<T> rawOpType)
This option is basically what you asked for above, but a little simpler without the Nil. While this is very easy to implement, it starts to reintroduce output casting in a way we tried to avoid with SciJava Ops.
// some signature for a BiFunction<Img, double, Img>varsig = ...
varimg = ...
varsigma = 5.0;
varop = env.signature(sig, BiFunction.class); // This would return a raw BiFunction// -- EITHER -- //Imgout1 = (Img) op.apply(img, sigma); // Requires cast// -- OR -- //varout2 = op.apply(img, sigma); // autocomplete only recognizes `Object` members on `out`.
Then, I figured that if we're going for simplicity, maybe we should just do this:
publicObjectopFromSignature(finalStringsignature)
But, while this look slick in a scripting environment, it'd make the casting even worse in languages where it's needed:
// some signature for a BiFunction<Img, double, Img>varsig = ...
varimg = ...
varsigma = 5.0;
varop = (BiFunction<Img, double, Img>) env.signature(sig); // This would return an Object, cast required for following lineImgout1 = op.apply(img, sigma);
Since we worked so hard on the OpEnvironment methods to remove these casts from the original ImageJ Ops code, it feels like a step back, no?
What I'd propose instead, if you really want this type of behavior, is a static function that could live...anywhere, really, although I'd prefer to put it closer to the scripts if possible (i.e. some future scijava-ops-python component down the line, that also contains the gateway?). It would look more or less like:
Activity
gselzer commentedon May 28, 2024
@ctrueden thanks for raising this issue. I've thought about it a fair bit, and did a little prototyping to try and fix this issue, and I can't come up with a solution that I like - you get drawn into casting issues so easily. Here's what I've been thinking about:
This option is basically what you asked for above, but a little simpler without the
Nil. While this is very easy to implement, it starts to reintroduce output casting in a way we tried to avoid with SciJava Ops.Then, I figured that if we're going for simplicity, maybe we should just do this:
But, while this look slick in a scripting environment, it'd make the casting even worse in languages where it's needed:
Since we worked so hard on the
OpEnvironmentmethods to remove these casts from the original ImageJ Ops code, it feels like a step back, no?What I'd propose instead, if you really want this type of behavior, is a static function that could live...anywhere, really, although I'd prefer to put it closer to the scripts if possible (i.e. some future scijava-ops-python component down the line, that also contains the gateway?). It would look more or less like:
Then, in e.g. Python you could write: