Portions of Rexx programs can be hidden from interpretation by encapsulating these as commentary text. A comment is started by a slash and asterisk, /*, without an intervening space. A comment is concluded by an asterisk and slash, */, again without an intervening space. Any characters are allowed within the comment sequence, including slashes and asterisks. However, Rexx comments can also be nested. Comments also act as source separators, which may have surprising effects.
A common type of comment is at the end of a line, for example:
say 'all is swell that ends swell' /* this is a fine comment */ |
Comments can also be present within a line, for example:
say 'all is swell' /* and more */ 'that ends swell' |
Another common type of comment is a sequence of lines that describe subsequent logic, for example:
/* here is a Rexx idiom
* which processes the words in a string * one word at a time. * * In this example, the words are listed vertically. */ words = 'all is swell that ends swell' do while words \= '' parse var words word words say word end |
It is recommended that you begin your Rexx programs with a comment ! In some environments, a leading comment is used to ascertain whether a source file is a potential program.
/* sayit.rex
* this program says it all */ interpret say arg(1) |
Comments are also used in Rexx programs to deactivate a portion of program logic, for example:
/*
say 'abracadabra' */ |
Rexx comments can be nested. When a /* character sequence is found within a Rexx comment the nesting depth is incremented. Each subsequent */ character sequence decrements the nesting depth. At a depth of two, the comment is not concluded until two */ character sequences occur. The nesting depth can exceed two levels. The following is an example of a nested comment.
/*
say 'abracadabra' /* no magic word today ! */ */ say 'and on we go' |
When two terms are separated by a comment, the values of the terms are concatenated without an intervening space.
toy = 'horse'
say toy/* expect a surprise */stuffing
Shows: horsefeathers ! Not: straw |
If there are spaces around the comment, then the values of the terms are concatenated with an intervening space.
toy = 'horse'
say toy /* normal concatenation */ stuffing
Shows: horse feathers ! |