The description command in Darwin provides a means of documenting a procedure.
> SetAverage := proc(s : set) > local total; > description 'This procedure takes a set as an argument and > calculates the average value in the set'; > total := 0: > for i from 1 to length(s) do > total := total + s[i]; > od; > print('The average is ', total/length(s)); > end:If we type
> print(SetAverage);the text surrounded by the single quote symbols (
') following the description command is echoed to the terminal.
SetAverage: Usage: SetAverage( s:set ) This procedure takes a set as an argument and calculates the average value in the set
The description command must follow any local or global declarations and any option commands.
> example := proc( ... ) > local x, y, z; > global a, b, c,; > option polymorphic; > description 'The following text is displayed by the print command'; . . . >end:
Computer science wisdom says that writing clear meaningful comments in your routines makes for easier to understand and debug code. However, the description command is optional.