DefFunctions have the following syntax:
(deffunction <function-name> (<argument>*)
["optional comment"]
<statement>*)
where <function-name> must be a unique name and
<statement> = <constant>|<variable>|<function-call>
Note: Only the last value that is a statement is printed. For example with the deffunction, "(deffunction say-anything (?X) (printout t ?X) Hello 1.5)", if you call it with "(say-anything "Greetings!")", the output will be :
Greetings!
1.5
Note: Brackets ([) and (]) define optional elements of the construct. The (|) character defines an or condition. An asterisk (*) defines zero or more of the preceding element (or disjunction of elements). A plus sign (+) defines one or more of the preceding element.
Valid DefFunction Definitions
(deffunction ask-name (?myname)
(printout t "What is your name?")
(printout t "Welcome " (readline) "! My name is " ?myname ". Shall we play a game?"))
(deffunction ask-start-again ()
(printout t "Play again? (y/n) ")
(if (eq (read) y) then
(assert (phase choose-player))))
(deffunction print-moved-message (?A ?B)
"An optional comment"
(printout t ?A " moved on top of " ?B "." crlf)
)
Invalid DefFunction Definitions
(deffunction ask-name <- missing argument list
(printout t "What is your name?")
(printout t "Welcome " (readline) "! My name is " ?myname ". Shall we play a game?"))