[Next] [Previous] [Up] [Top] [Contents] [Index]

7 Conditions

Condition Messages

Some condition classes provide a message to communicate the meaning of the condition to the program user.

Condition messages are constructed using format strings. A format string is a string template into which values can be inserted to construct a message. The two-character format directives %d, %b, %o, %x, %c, %s, and %= are replaced by the corresponding element of the associated sequence of format arguments. Upper and lower case letters are equivalent in these format directives. The inserted value is formatted according to the following table:[4]

Format Directives
Directive Argument TypeTextual Format
%d <integer>decimal number
%b <integer>binary number
%o <integer>octal number
%x <integer>hexadecimal number
%c <character>character (with no quotes)
%s <string>string (with no quotes)
%s <condition>condition message (with no quotes)
%= <object>unspecified, but works with any object
%% noneliteral %

The text printed by the %= format directive for any given object is implementation-defined. The behavior when a format argument is not of the type specified in the table above is implementation-defined. The behavior when too many or too few format arguments are supplied is implementation-defined.

The two-character sequence %% does not consume a format argument, but inserts a % character.

All other uses of the % character in a format string are implementation-defined.

There is no standard way to get the message from a condition (although it can be inserted into another message). Debuggers get the message using implementation-dependent mechanisms. A streams library or other implementation-dependent feature might include a function to get the message from a condition. However, in some implementations, the message might only exist in the debugger, not in the program runtime.

There is no standard way for a user-defined condition class to supply a message. Individual implementations and libraries can specify such a mechanism that is appropriate to their needs.


[4] These format directives are designed for compatibility with C's printf, with some ommisions and with the addition of %=.
Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker