Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
verb-token.hpp File Reference

Building blocks for a simple DSL using double dispatch to a handler function. More...

Go to the source code of this file.

Description

Building blocks for a simple DSL using double dispatch to a handler function.

Actually this is a specialised variation of the visitor pattern, where the "verb tokens" of the language are the domain objects accepting a "receiver" (visitor) to provide the concrete implementation function for each "verb".

The intended usage is to set up a language comprised of several abstract actions ("verbs"), but to defer the concrete implementation to a specific set of handler functions, which is provided late, at application time. This way, we can send a sequence of verbs towards an unknown receiver, which supplies the actual meaning within the target context. In the end, there is a double-dispatch based both on the individual verb given and the concrete receiver, which needs to implement the interface used in the definition of the verb tokens. The handler functions defined within this interface may take additional arguments, which are passed through on application to the concrete receiver, e.g. VERB_doit (receiver, arg1, arg2) results in the invocation of receiver.doit(arg1,arg2)

See also
prominent usage: the Diff system
VerbFunctionDispatch_test

Definition in file verb-token.hpp.

#include "lib/symbol.hpp"
#include "lib/util.hpp"
#include <utility>
#include <string>

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 

Macros

#define VERB(RECEIVER, FUN)   VERB_##FUN (&RECEIVER::FUN, STRINGIFY(FUN))
 

Classes

class  VerbToken< REC, RET(ARGS...)>
 

Macro Definition Documentation

◆ VERB

#define VERB (   RECEIVER,
  FUN 
)    VERB_##FUN (&RECEIVER::FUN, STRINGIFY(FUN))

Definition at line 119 of file verb-token.hpp.