Blue recognises two types of comments, marked by a double equals sign (==) and a double hyphen (- -). Comments always extends to the end of the line. To have several lines as a comment, every line has to be preceded by the comment symbol.
Comments starting with == are part of the class interface and part of the language definition. They are used to describe the class itself and routine semantics, and are allowed to appear only in strictly defined locations. These locations are:
Example
class Rectangle is == Author: M. Kölling
== Date: April 1995
== Version: 1.1
== Short: Graphical representation of a rectangle.
==
== Class Rectangle represents a rectangle with
== specified coordinates and colour that can be ...
== ... ... interface creation (tl: Point, br: Point) is == Create rectangle at coordinates defined by tl (top-left)
== and br (bottom-right). Default colours are: fill white,
== border black. do
...
end creation
routines move (dx: Integer, dy: Integer) is == Move rectangle by distance defined by dx, dy. do
...
end move
size -> (width: Integer, height: Integer) is == Return size of rectangle in width and height. do
...
end size invariant
... end class
The example shows interface comments for the class and for each routine. Interface comments may not appear anywhere else. They are part of the class interface and therefore displayed in interface view (see [1] for a description of the environment, including the interface view of classes). They are also used by the class browser. (By convention, some lines of the class comments begin with certain keywords which are recognised by the class browser. These lines define the author, version number, date of creation and a short description of the class. See the documentation of the browser for details.)
All other comments, starting with the symbol - - (double hyphen), are implementation comments. They may appear anywhere and are not included in the interface view. Implementation comments are ignored by the compiler.
Note that implementation comments may appear as part of the routine comment. If they do, they should describe the routine implementation and will not be displayed as part of the interface.
Example:
class WidgetManager is
...
add (new_widget: Widget) is
== Add `new_widget' to the set of managed widgets.
- - This is done by adding `new_widget' to `wl', the
- - internal widget list. Note that `wl' may be undefined
- - if this is the first widget to be added. We have to test for
- - that and possibly create the list before adding to it.
do
if wl = nil then - - test whether list exists
wl := create List <Widget>
end if
wl.add (new_widget) - - add widget to widget list
end add
...
end class
The interface of this routine is
add (new_widget: Widget)
== Add `new_widget' to the set of managed widgets.
There is no block comment in Blue (every comment is for one line only). Instead, the Blue environment provides tools to add or remove comments on every line in a block of text.