11.1.1 The underscore syntax

Unless otherwise stated, in every code example in this chapter, we assume the following macro has been defined in the preamble:

m4_define([[[_]]],[[[mbfl_datavar([[[$1]]])]]])

which means the following syntax expansion takes place:

_(SELF) → mbfl_datavar(SELF)

so to define a new class and a new instance we can use the syntax:

mbfl_default_class_declare(COLOUR)
mbfl_default_object_declare(DARK_SLATE_BLUE)

mbfl_default_class_define _(COLOUR) _(mbfl_default_object) 'colour' red green blue
colour_define _(DARK_SLATE_BLUE) 72 61 139

mbfl_declare_varref(RED)
colour_red_var _(RED) _(DARK_SLATE_BLUE)
"$RED"  ⇒ 72

Notice that GNU Bash already uses the identifier ‘_’ to implement a built–in shell variable, See Bash Variables. To avoid unwanted expansion of the underscore identifier as a macro, we must quote the uses of ‘_’ that are meant to reference the Bash variable:

[[[$_]]]

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.