Contents | Index | < Browse | Browse >

3.5.  Run-Time Macros

     Normally when the parser gets its input from  the	line
buffer of the current Actor, the words are what	they seem to
be:  simple words.  ADL	has a facility whereby	these  words
may  be	 transformed before the	parser sees them.  Each	word
is looked up in	a table	(the "macro table").  If found it is
replaced  by  the  expansion  for  the macro (which may	be a
string containing more than one	word) and  re-inserted	into
the line buffer	whereupon the input process continues.

     One use of	this facility is to "rename"  objects.	 For
example,  it  may be desired that the player be	able to	type
something like "Name the box 'bob'.  Take bob."	(notice	that
the  second usage of bob has no	quotes).  This can be accom-
plished	by the call ($define  "bob"  "box")  which  says  to
expand "bob" to	"box" whenever it is encountered in the	line
buffer.	 The built-in routine $undef may be used  to  "unde-
fine"  a  macro	if it outlives its usefulness -- for example
($undef	"bob") removes "bob" from the macro table.  More  is
said  about  macros  in	 Section  7.10 under the entries for
$define	and $undef.