Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

it's not nearly the same. Piping in elixir is a macro; it lets you preserve the other arguments in your function call.

The IO.inspect(value, label: "label string") semantic is incredibly powerful. During debugging I often do this:

    value
    |> IO.inspect(label: "A")
    |> do_something
    |> IO.inspect(label: "B")
    |> do_something_else
    |> IO.inspect(label: "C")

    ...
This gives me full visibility over the data transformations that are happening. And removing the IO.inspect's are trivial with an IDE like atom, vscode, etc. Also the way that the BEAM handles concurrent IO means that none of those strings that I send will be interrupted by other content, which is critical to interpretable println debugging in a concurrent environment. I haven't used the debugger (or IEX.pry, whic I hear is powerful) once.


That's what it's doing, arguments are preserved:

    # don't really know what IO.inspect is doing
    # but guessing something like this?
    def IO.inspect(value, label:)
      puts "#{label}: #{value.inspect}"
      value
    end

    value.pipe do
      IO.inspect(label: "A")
      do_something
      IO.inspect(label: "B")
      do_something_else
      IO.inspect(label: "C")
    end


oh I didn't get past "Matz on Ruby"! Sorry. I do think the native pipe operator is prettier.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: