Skip to content
brett hartshorn edited this page Jul 23, 2015 · 4 revisions

Macro functions are defined inline with special with M as "...": blocks. They allow you to write more compact and clear code in places where you would like to reuse a small one-liner macro, and inline code directly in the backend syntax.

JavaScript Backend

class Channel():
    def send(self,ob):
        print 'sending:' + ob
        return ob

chan = Channel()
with mymacro as "chan.send(JSON.stringify(%s))":
    mymacro( s3 )

C++ Backend

Below C++ template syntax is used, and assigned to the macro function T. This allows you to workaround using external C++ libraries that require C++ namespace syntax and template syntax.

with T as "std::vector<int>":
   v = new( T(1,2,3) )

https://github.com/rusthon/Rusthon/blob/master/examples/macro_templates.md

old-school c++ macros

The C++ backend has an extra builtin function called macro, this allows you to inline a raw C++ macro string. This is sometimes required when working external libraries that rely on C++ pre-processor macro syntax.

macro("FOOBAR()")

Sidebar

Clone this wiki locally