What is Nostr?
unclebobmartin /
npub19mu…jnft
2023-05-24 13:59:26
in reply to nevent1q…c673

unclebobmartin on Nostr: If I encountered an API that forced me to pass a handler for no reason other than to ...

If I encountered an API that forced me to pass a handler for no reason other than to force me handle a result, I'd be miffed. The handler is inconvenient to say the least. For example, handlers prevent the simple composition of functions.

I cannot say f(g(x)) if g returns its value through a handler.

Instead I have to do something horrible like this:

interface H {handle(x)};
class H_imp : H {x get(); handle(x) {this.x = x;}};

H h = new H_imp;
g(h, x);
f(h.get);


From: (benc) at 05/24/23 08:44:34 on wss://nos.lol
CC: unclebobmartin (npub19mu…jnft)
>---------------
>The real life scenario that inspired this quest dealt with life cycle. The value returned was supposed to be used to allow a caller to manage the result.
>
>We found instances where consumers where simply ignoring the result leaving things in a bad state.
>
>The handler forces the consume to provide _something_ to manage the result. I think this fits the Tell Don’t Ask idea.
Author Public Key
npub19mun7qwdyjf7qs3456u8kyxncjn5u2n7klpu4utgy68k4aenzj6synjnft