News for hackers. Stuff that matters.
Re:Pipe Operator (|>) For JavaScript by galaxyLogic on Friday January 20, 2023 @11:20AM (#34455267)
I think we should have BOTH.

Use |> for the Hack proposal

and -> for F# -style.

Re:Pipe Operator (|>) For JavaScript by hajile on Friday January 20, 2023 @11:51AM (#34455873)
I'd far rather save that for an alternative switch expression with pattern matching.

    const slowSum = (lst: {x: number}[]) =>
      switch(list) {
        [{x}, ...y]   -> x + slowSum(y) //not tail recursive
        [{x}, {x: y}] -> x + y          //alias second x to y
        [{x}]         -> x              //handle length 1
        []            -> 0              //handle length 0
      }
Re:Pipe Operator (|>) For JavaScript by tracker1 on Friday January 20, 2023 @02:16PM (#34458244)
Having been watching, and a couple times playing with Rust... would definitely like a similar pattern matching system in JS. I still feel the C# syntax for this feels a bit alien `varname switch {...}`.
Re:Pipe Operator (|>) For JavaScript by pharmakom on Friday January 20, 2023 @02:02PM (#34458024)
As an F# developer who also does some JS and Java this would confuse the hell out of me! |> is the best operator
Re:Pipe Operator (|>) For JavaScript by grumpyprole on Friday January 20, 2023 @04:10PM (#34459980)
There's no need. The % placeholder can be used for a consise lambda syntax and would work with a F# application operator.