Any ideas on what infix functions can be useful in...
# stdlib
a
Any ideas on what infix functions can be useful in a rest api? Looking for ideas to codify
c
I feel that infix functions should only be present in a DSL, like test assertions or rule engine, etc.
1
a
So like don’t use it in regular code?
c
Well, that's my take on it, some would probably disagree.
r
In some cases infix functions are more readable than factory methods. For example, I'm using these:
Copy code
val point1 = Point(1, 3)
val point2 = Point(7, 8)
val size: Size(2, 2)
// ...
val rect1 = point1 rectTo point2
val rect2 = point1 rectOfSize size
val rect3 = point2 centeredRectOfSize size
c
Yup - as I've said - DSL 😉
r
Well, I'm not entirely sure I'd call that DSL, but I see your point 🙂
c
yeah, definitions are quite blurry 🙂 there is at least one infix function I'm using all the time in "normal" code:
to
My main point is, code is code, don't try to make it into something else just for the sake of it. Sometimes it is warranted, but often - it is not.
👍 2