nomennescio
nomennescio
OK, my intention was not to make all errors into an `ERROR:`, but I guess such a thing could be done. Maybe the confusion is in the Factor docs already:...
Yes, true, that's how I implement my current work-around: ``` M: tuple dup class-of error-class? [ handle-error-case ] [ handle-tuple-case ] if ; ``` which is clumsy, ugly, and not...
(Maybe the same case could be made for e.g. `SINGLETON:`. I wonder how it would help to avoid boilerplate code as can be seen in e.g. the prettyprinter)
> But your version can’t handle a non ERROR: thrown? I assume it uses “is an error” to differentiate from “normal” test result. Are you talking about my proposal, or...
> Anything thrown (whether an error-class instance or string or array) is by definition an error. So if in your recover block you wrap the “error” with your tuple instance,...
Such an "error tuple" class could also be a simple predicate: ``` PREDICATE: user-error < tuple class-of error-class? ; ```
See also https://github.com/factor/factor/issues/2570
I just discovered `PAIR-GENERIC:` which is without documentation, but has "Order-insensitive double dispatch generics", which might be similar to `ENDOGENERIC:`?
The test code shows that this is not the same, but it's solving a harder problem: ``` TUPLE: foom < thang ; TUPLE: barm < foom ; PAIR-M: barm thang...
My proposal would essentially be to `GENERIC:`-dispatch on the shared superclass of two objects. Something like `: shared ( class1 class2 -- shared ) [ class-of ] bi@ 2array smallest-class...