|
|
|
|
|
by malisper
4300 days ago
|
|
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 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.