turbine icon indicating copy to clipboard operation
turbine copied to clipboard

Infix vs prefix notation

Open stevekrouse opened this issue 6 years ago • 2 comments

We have Behavior#map but also filterApply, when, etc that are prefix. Uniformity is the biggest issue, but I prefer the infix notation, and would prefer it everywhere where possible.

stevekrouse avatar Dec 12 '18 12:12 stevekrouse

rxjs has this pipe operator which is pretty neat.

But I'd probably prefer being able to do .operator to any stream or behavior.

stevekrouse avatar Jan 04 '19 19:01 stevekrouse

My thinking was

  • "Core" operators are available as methods.
  • Non-"core" operators are only available as function.

But I agree that it can be confusing. To make it less confusing the (future) documentation could make it very clear which operations are core and which are not. But still, it is not idea.

The reason for not making everything methods is that functions can be tree-shaken whereas methods can't be tree-shaken which will lead to bigger bundles.

In the List library I took an approach where methods can optionally be imported with `import "list/methods". This makes methods (and the increase in bundle size) opt-in. That is also an option.

paldepind avatar Jan 11 '19 14:01 paldepind