Lumiera  0.pre.03
»edit your freedom«
verb-token.hpp File Reference

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>

Classes

class  VerbToken< REC, SIG >
 Action token implemented by double dispatch to a handler function, as defined in the "receiver" interface (parameter REC). More...
 
class  VerbToken< REC, RET(ARGS...)>
 

Macros

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

Namespaces

 lib
 Implementation namespace for support and library code.
 

Class Documentation

◆ lib::VerbToken

class lib::VerbToken
+ Collaboration diagram for VerbToken< REC, SIG >: