API design for functions returning multiple objects

Perhaps fixing chaining is easier than figuring out ways to signal whether you do or don’t want extras.

I.e.,

pipe(image, into=[
  (func1, {'alpha': 2},
  (func2, {'sigma': 3}),
  (func3)
])

Which is no less readable than

func3(func2(func1(image, alpha=2), sigma=3))

Except that the pipe invocation allows you to always return image, extras. We had some minor concerns that extras could, in some cases, be costly to compute, but I suspect that doesn’t happen often.

1 Like