2

Is there a (preferably easy) way to redefine one of the standard operators in Phoenix? I would like to have ">>" for example call my own (lazy) functor.

Simple use case: I might want to define a "pipeline" operator, so that:

function2(function1(arg1));

could be written in an extremely tricky fashion as

arg1 >> function1 >> function2

and then invoked as

(arg1 >> function1 >> function2)(42)
David H
  • 1,461
  • 2
  • 17
  • 37
  • I'm pretty sure `arg1 >> function1 >> function2` can only be equivalent to `function2(function1(arg1))`. [Here](http://liveworkspace.org/code/1gJygE$0) is an example. –  Feb 15 '13 at 15:17
  • 1
    @llonesmiz - thanks, that was a typo... I've edited the question to fix. Your example looks like an answer -- why not post it as such? – David H Feb 15 '13 at 16:08
  • @llonesmiz please do, I want to be able to upvote it – sehe Feb 15 '13 at 16:12
  • @sehe I can't make it work with functors and I'm pretty sure there are problems with const correctness. –  Feb 15 '13 at 16:34
  • My example above does not work in either clang 3.2 or Visual Studio 2012. –  Feb 16 '13 at 08:50
  • [New version](http://liveworkspace.org/code/D6ISr$0) that works with g++, clang and VS. The need to use `BOOST_RESULT_OF_USE_TR1` means that I'm doing something wrong with the result_of protocol, but I don't know enough to know exactly what. Something that must be very basic but I don't understand is that VS requires `&function` (much uglier) while g++ and clang accept `&function` and `function`. If someone wants to make an answer out of this, feel free. –  Feb 19 '13 at 07:43

0 Answers0