Home   Archive   Permalink



C++ Binding for Rebol and Red

In light of other announcements, I'd like to add another: the existence of a promising C++ bridge that aims to work with either Rebol or Red.
    
It is called RenCpp. Though it is not 'ready', it actually does currently interface with Rebol...and is at the point where it can be tested and critiqued. So what we are ready for is to ask for broader feedback on the design.
    
The goal is to open doors to calling Rebol/Red from C++, and vice-versa. Even threading back and forth through nested stacks, if that is expedient. It started from a question of whether C++11 features (along with something of a 'no-compromises' attitude) could give Red and Rebol a best-of-breed binding, in both notation and functionality.    
    
At the tip of the iceberg of calling the runtime from C++ is this (working) example to utilize PARSE:
    
     std::string data {'Hello [Ren C++ Binding] World!'};
    
     Word variable {'foo'};
    
     Block rule {
         'thru {[}',
         'copy', variable, 'to {]}',
         'to end'
     };
    
     auto result = Word {'parse'}(data, rule);
    
     if (result) {
         std::cout << 'Success and target was ' << variable() << '\n';
     }
     else {
         std::cout << 'PARSE failed.';
     }
    
On the other side of the fence is being able to extend the runtime with C++ code, as easily as this:
    
     auto printBlockTimes = Function::construct(
         '{Demonstration of the C++ Extension mechanism}'
         'blk [block!] {The block to print}'
         'times [integer!] {How many times to print it},
    
         REN_STD_FUNCTION,
    
         [](Block const & blk, Integer const & times) -> Logic {
             if (blk.empty())
                 return false;
    
             for (int index = 0; index< times; index++) {
                 for (auto item : blk)
                     std::cout << item;
             }
    
             return true;
         }
     );
    
     runtime('print-block-times: quote', printBlockTimes);
    
     runtime('print-block-times [1 2 3] 5');
    
I could let you use your imagination of the doors to integration opened when things become that frictionless...
    
     https://www.youtube.com/watch?v=MDAqQamN_PQ
    
But there's an exciting demo up and coming, and I'd like to bring more people in as part of the process...reviewers and more developers.
    
Ten or so people have already managed to build it, and more are encouraged to give that a shot. We're now up and running with continuous integration testing, inching the project closer to legitimacy:
    
     https://travis-ci.org/hostilefork/rencpp
    
So feel free to browse around and give it a shot. It won't build in MSVC, but clang and GCC can build it...and some instructions have been evolving:
    
     https://github.com/hostilefork/rencpp/blob/develop/doc/build.md
    
Just getting it to build on more systems and helping make the directions more clear is very helpful, and I appreciate the efforts of those who've taken the time to do it so far. Raising issues in the GitHub about what the binding currently does--or what it should do--are also welcome, even if they're just being made from skimming the tests.
    
...and maybe DocKimbel can use some of that money to bounty someone to flesh out the Red implementation. :-)

posted by:   Fork     17-Jan-2015/20:52:18-8:00



I hope this is successful Fork. We could really be helped by having more capable C and C++ developers in the community.

posted by:   Nick     19-Jan-2015/13:21:54-8:00