Thread
#stdlib
    asad.awadia

    asad.awadia

    3 years ago
    Any ideas on what infix functions can be useful in a rest api? Looking for ideas to codify
    Czar

    Czar

    3 years ago
    I feel that infix functions should only be present in a DSL, like test assertions or rule engine, etc.
    asad.awadia

    asad.awadia

    3 years ago
    So like don’t use it in regular code?
    Czar

    Czar

    3 years ago
    Well, that's my take on it, some would probably disagree.
    r

    r4zzz4k

    3 years ago
    In some cases infix functions are more readable than factory methods. For example, I'm using these:
    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
    Czar

    Czar

    3 years ago
    Yup - as I've said - DSL 😉
    r

    r4zzz4k

    3 years ago
    Well, I'm not entirely sure I'd call that DSL, but I see your point 🙂
    Czar

    Czar

    3 years ago
    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.