News for hackers. Stuff that matters.
Re:Wren is a small, fast, class-based concurrent scripting l... by still_grokking on Sunday August 28, 2022 @08:55PM (#32633746)
Scala solves this with a syntactic twist: If the (in this case usually symbolic) method name ends in a colon (like say `+:`) it's right associative.

So the following code¹ shows a method call (`prepend`) on the right operand:

  val someList = List(2, 3, 4)
  
  val extendedList = 1 +: someList
  // As the later is just syntax for a regular method call
  // `extendedList` could be also defined with the same result as:
  //  someList.+:(1)
  
  val otherExtendedList = someList.+:(1)
  
  @main def entryPoint =
    println(extendedList)
    println(otherExtendedList)
___

¹ https://scastie.scala-lang.org/y55n254oSVOFmw2CjmckjA

Re:Wren is a small, fast, class-based concurrent scripting l... by eru on Sunday August 28, 2022 @10:48PM (#32634294)
In Haskell, you can just declare which way your operators are supposed to associate (if any). That doesn't seem to cause any problems in practice. (Though it helps that Haskell is statically typed, so the compiler can yell at you when you guess the direction of associativity for eg your extend-a-list operator wrong.