Skip to content

Commit

Permalink
More <simple-condition> cleanups (#1615)
Browse files Browse the repository at this point in the history
* Deprecate `<format-string-condition>` and replace uses of it with
`<simple-condition>`.
* Use `<simple-error>` in some superclass lists where `(<error>,
<simple-condition>)` was used.
  • Loading branch information
cgay authored Jun 15, 2024
2 parents 7cb1d65 + 1102acb commit 173e88f
Show file tree
Hide file tree
Showing 26 changed files with 64 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,16 @@ and will assist you in analyzing values.
.. c:function:: bool dylan_simple_condition_p (D instance)
Tests whether instance is a ``<simple-condition>``.
Tests whether instance is a :class:`<simple-condition>`.
.. c:function:: D dylan_simple_condition_format_string (D instance)
Returns the format string stored in the given ``<simple-condition>``.
Returns the format string stored in the given :class:`<simple-condition>`.
.. c:function:: D dylan_simple_condition_format_args (D instance)
Returns the format string arguments stored in the given
``<simple-condition>``.
:class:`<simple-condition>`.
.. c:function:: bool dylan_class_p (D instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ Program Conditions
:open:
:abstract:

:superclasses: :const:`<format-string-condition>`
:superclasses: :class:`<simple-condition>`

:keyword compilation-stage: Defaults to the value of :var:`*current-stage*`.
:keyword program-note-creator: Defaults to the value of :var:`*current-dependent*`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ The extensions are:
- Collection model: :class:`<stretchy-sequence>`, :class:`<string-table>`,
:gf:`difference`, :func:`fill-table!`, :gf:`find-element`, :gf:`position`,
:gf:`remove-all-keys!`, :macro:`define table`, :gf:`split`, and :gf:`join`.
- Condition system: :class:`<format-string-condition>`,
:class:`<simple-condition>`, and :gf:`condition-to-string`.
- Condition system: :class:`<simple-condition>`, and :gf:`condition-to-string`.
- Control flow: :macro:`iterate` and :macro:`when`.
- Development conveniences:

Expand Down Expand Up @@ -528,25 +527,6 @@ The extensions are:
Formats a floating-point number to a string. It uses scientific
notation where necessary.

.. class:: <format-string-condition>
:sealed:
:instantiable:

The class of conditions that take a format string.

:superclasses: :drm:`<condition>`

:description:

The class of conditions that take a format string, as defined by
the DRM.

It is the superclass of Dylan's :class:`<simple-condition>`.

:seealso:

- The :doc:`Format module <../io/format>` in the :doc:`IO library <../io/index>`.

.. function:: ignore

A compiler directive that tells the compiler it must not issue a
Expand Down Expand Up @@ -783,20 +763,28 @@ The extensions are:
:sealed:
:instantiable:

The class of simple conditions.
The class of conditions that accept a format string and format arguments
with which to build a message describing the condition.

:superclasses: :class:`<format-string-condition>`
:superclasses: :class:`<condition>`

:description:

The class of simple conditions. It is the superclass of :drm:`<simple-error>`,
:drm:`<simple-warning>`, and :drm:`<simple-restart>`.
As the superclass of :drm:`<simple-error>`, :drm:`<simple-warning>`, and
:drm:`<simple-restart>`, the :class:`<simple-condition>` class provides
the ``format-string:`` and ``format-arguments:`` init keywords described
in the DRM.

:operations:

- :drm:`condition-format-string`
- :drm:`condition-format-arguments`

:seealso:

- The :doc:`format module <../io/format>` in the :doc:`IO library
<../io/index>`.

.. class:: <stretchy-sequence>
:open:
:abstract:
Expand Down
2 changes: 1 addition & 1 deletion documentation/source/library-reference/io/print.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ IO library's *print* module.
end;
With the above method, an ``<account>`` object with name "foo" will print as
``{<account> "foo" #xDEADBEEF}``.
``{<account> "foo" 123}`` where ``123`` is a unique identifier for the object.


The pprint Module
Expand Down
2 changes: 1 addition & 1 deletion documentation/source/library-reference/network/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ This section lists the socket condition classes in the Network library.
:description:

The class of socket conditions. It inherits the ``format-string:``
and ``format-arguments:`` keywords from
and ``format-arguments:`` init keywords from
:class:`<simple-condition>`.

Slots:
Expand Down
4 changes: 2 additions & 2 deletions documentation/source/library-reference/system/file-system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,10 @@ File-System module.

.. class:: <file-system-error>

Error type signaled when any other functions in the File-System
Error type signaled when any of the functions in the File-System
module signal an error.

:superclasses: :drm:`<error>`, :class:`<simple-condition>`
:superclasses: :drm:`<simple-error>`

:description:

Expand Down
6 changes: 3 additions & 3 deletions documentation/source/library-reference/system/locators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ The locators Module

All errors raised by the locator system should be instances of
this error.
:superclasses: :class:`<format-string-condition>`, :drm:`<error>`

:superclasses: :drm:`<simple-error>`


.. class:: <server-locator>
:open:
:abstract:

The abstract superclass of locators for servers.

:superclasses: :class:`<locator>`

:seealso:
Expand Down
2 changes: 1 addition & 1 deletion sources/common-dylan/format.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ define method condition-to-string
end method condition-to-string;

define method condition-to-string
(condition :: <format-string-condition>) => (string :: <string>)
(condition :: <simple-condition>) => (string :: <string>)
apply(format-to-string,
condition-format-string(condition),
condition-format-arguments(condition))
Expand Down
4 changes: 2 additions & 2 deletions sources/common-dylan/library.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ end module byte-vector;
define module common-extensions
use dylan-extensions,
export: { <bottom>,
<format-string-condition>,
<format-string-condition>, // Deprecated...
<simple-condition>, // ...use this instead.
<stack-overflow-error>,
<arithmetic-error>,
<division-by-zero-error>,
Expand All @@ -75,7 +76,6 @@ define module common-extensions
<arithmetic-underflow-error>,
<stretchy-object-vector>,
<object-deque>,
<simple-condition>,
<stretchy-sequence>,
<string-table>,
false-or,
Expand Down
4 changes: 2 additions & 2 deletions sources/common-dylan/streams-protocol.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
License: See License.txt in this distribution for details.
Warranty: Distributed WITHOUT WARRANTY OF ANY KIND

define open abstract class <stream-error> (<error>, <format-string-condition>)
define open abstract class <stream-error> (<error>, <simple-condition>)
constant slot stream-error-stream :: <stream>,
required-init-keyword: stream:;
end;
Expand All @@ -17,7 +17,7 @@ define generic stream-error-stream
// TODO: yuck. Would be nicer to just have a condition-to-string method..
// andrewa: note that then you need to update the runtime manager to
// know about the new class too, it is simpler to rely on subclassing
// <format-string-condition>.
// <simple-condition>.
define method make
(class :: subclass(<stream-error>),
#rest args,
Expand Down
55 changes: 16 additions & 39 deletions sources/common-dylan/tests/condition-test-utilities.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ define constant $condition-arguments = #(1, 2);
define method make-condition
(class :: subclass(<condition>))
=> (condition :: <condition>)
make(class)
end method;

define method make-condition
(class :: subclass(<simple-condition>))
=> (condition :: <simple-condition>)
make(class,
format-string: $condition-string,
format-arguments: $condition-arguments)
end method make-condition;
end method;


/// Condition test functions

define method test-condition (condition :: <condition>) => ()
test-output("test-condition(<condition>)\n");
do(method (function) function(condition) end,
vector(// Functions on <condition>
do-test-signal,
Expand All @@ -47,23 +52,21 @@ define method test-condition (condition :: <condition>) => ()
))
end method test-condition;

define method test-condition (condition :: <simple-error>) => ()
test-output("test-condition(<simple-error>)\n");
define method test-condition (condition :: <simple-condition>) => ()
next-method();
do(method (function) function(condition) end,
vector(// Functions on <simple-error>
vector(// Functions on <simple-condition>
do-test-condition-format-string,
do-test-condition-format-arguments
))
end method test-condition;

define method test-condition (condition :: <type-error>) => ()
next-method();
do(method (function) function(condition) end,
vector(// Functions on <type-error>
do-test-type-error-value,
do-test-type-error-expected-type
))
// The purpose of this method is to prevent next-method() from being called.
// do-test-condition-format-{string,arguments} don't work for <type-error> because
// its format string and args are computed from the value and type init args.

//next-method();
end method test-condition;

define method make-condition (class == <type-error>) => (c :: <type-error>)
Expand All @@ -72,15 +75,6 @@ define method make-condition (class == <type-error>) => (c :: <type-error>)
type: <string>)
end method;

define method test-condition (condition :: <simple-warning>) => ()
next-method();
do(method (function) function(condition) end,
vector(// Functions on <simple-warning>
do-test-condition-format-string,
do-test-condition-format-arguments
))
end method test-condition;

define method test-condition (condition :: <restart>) => ()
next-method();
do(method (function) function(condition) end,
Expand All @@ -89,15 +83,6 @@ define method test-condition (condition :: <restart>) => ()
))
end method test-condition;

define method test-condition (condition :: <simple-restart>) => ()
next-method();
do(method (function) function(condition) end,
vector(// Functions on <simple-restart>
do-test-condition-format-string,
do-test-condition-format-arguments
))
end method test-condition;

define method do-test-signal (condition :: <condition>) => ()
//---*** Fill this in...
end method;
Expand Down Expand Up @@ -131,7 +116,7 @@ define method do-test-return-description (condition :: <condition>) => ()
end method;

define method do-test-condition-format-string
(condition :: <condition>) => ()
(condition :: <simple-condition>) => ()
let name = format-to-string("%= condition-format-string matches specified format string",
condition);
check-equal(name,
Expand All @@ -140,22 +125,14 @@ define method do-test-condition-format-string
end method;

define method do-test-condition-format-arguments
(condition :: <condition>) => ()
(condition :: <simple-condition>) => ()
let name = format-to-string("%= condition-format-arguments match specified format arguments",
condition);
check-equal(name,
condition-format-arguments(condition),
$condition-arguments)
end method;

define method do-test-type-error-value (condition :: <condition>) => ()
//---*** Fill this in...
end method;

define method do-test-type-error-expected-type (condition :: <condition>) => ()
//---*** Fill this in...
end method;

define method do-test-restart-query (condition :: <condition>) => ()
//---*** Fill this in...
end method;
2 changes: 1 addition & 1 deletion sources/dfmc/conditions/hierarchy.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define function invoke-debugger (condition) end;
// best to subclass one of <program-error>, <program-note>, or
// <program-restart> instead.

define open abstract class <program-condition> (<format-string-condition>)
define open abstract class <program-condition> (<simple-condition>)

// TODO: Make this class primary.

Expand Down
4 changes: 2 additions & 2 deletions sources/dfmc/conditions/report.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ define thread variable *detail-level* :: <detail-level> = #"normal";
// specializable parameter.
//
// The default method for <program-condition>s takes advantage of the
// fact that all program conditions obey the <format-string-condition>
// (aka <simple-condition>) protocol of having a format string and its
// fact that all program conditions obey the <simple-condition>
// protocol of having a format string and its
// arguments in the condition itself. Methods for conditions outside
// the program condition hierarchy just handle the default level by
// using the %s/%= distinction in format.
Expand Down
4 changes: 2 additions & 2 deletions sources/dfmc/modeling/namespaces.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ define &module dylan-extensions

create
\last-handler-definer,
<format-string-condition>,
<simple-condition>, // HACK: COMPATIBILITY
<format-string-condition>, // Deprecated...
<simple-condition>, // ...use this instead.
<stack-overflow-error>,
<arithmetic-error>,
<division-by-zero-error>,
Expand Down
1 change: 1 addition & 0 deletions sources/dylan/condition.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ define open abstract primary class <simple-condition> (<condition>)
constant slot condition-format-arguments, init-keyword: format-arguments:, init-value: #[];
end class <simple-condition>;

// Deprecated. Use <simple-condition> instead. This will be removed in a future release.
define constant <format-string-condition> = <simple-condition>;

// debug-message and its C primitive require the arguments as a vector.
Expand Down
2 changes: 1 addition & 1 deletion sources/dylan/number.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ define generic remainder

//// CONDITIONS

define open abstract class <arithmetic-error> (<error>, <format-string-condition>)
define open abstract class <arithmetic-error> (<error>, <simple-condition>)
inherited slot condition-format-string = "Arithmetic error";
end class <arithmetic-error>;

Expand Down
2 changes: 1 addition & 1 deletion sources/environment/commands/command-line.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ define open generic parse-next-argument

/// Utilities

define class <command-line-server-error> (<format-string-condition>, <error>)
define class <command-line-server-error> (<simple-error>)
end class <command-line-server-error>;

define class <command-error> (<command-line-server-error>)
Expand Down
2 changes: 1 addition & 1 deletion sources/environment/commands/properties.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ end method show-property;

/// Errors

define class <set-property-error> (<format-string-condition>, <error>)
define class <set-property-error> (<simple-error>)
end class <set-property-error>;

define method set-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end class <class-breakpoint>;
///// <BREAKPOINT-ERROR>
// The class of all breakpoint errors

define abstract class <breakpoint-error> (<format-string-condition>, <error>)
define abstract class <breakpoint-error> (<simple-condition>, <error>)
end class <breakpoint-error>;


Expand Down
Loading

0 comments on commit 173e88f

Please sign in to comment.