Hacker News new | ask | show | jobs
by pfultz2 4299 days ago
I disagree. It makes it very simple to make a pipable function, you just wrap the function object in pipable. There's nothing complicated about using it.

Futhermore, doing it by hand is not as simple, but still not very complicated. This just helps alleviate the boilerplate in defining pipable functions.

1 comments

There's nothing complicated about using it.

I'm not talking about using the pipe operator, I'm talking about implementing it. The C++ version is ridiculously complicated.

Let's compare your code with an analogous implementation in Common Lisp.

  (defun pipe (val &rest fns)
    (reduce (lambda (acc f)
              (funcall f acc))
            fns :initial-value val))
Just this allows for some pretty similar code:

  (pipe 99 #'1+ #'sqrt #'1-) which evaluates to 9.0
It is possible to implement it in C++, but the implementation winds up being ridiculously complicated. I just implemented something very similar in Common Lisp and it wound up being incredibly simple. Why doesn't C++ allow for a definition nearly as nice as the Common Lisp one?
> It is possible to implement it in C++, but the implementation winds up being ridiculously complicated.

It may be more verbose in C++, but its not more complicated, and its definitely not "ridiculously" complicated.

> I just implemented something very similar in Common Lisp and it wound up being incredibly simple.

Maybe for you as a lisp programmer, but for me I find the lisp code incomprehensible.