Airport Example for Gwydion Dylan

-> Home page -> Favourite staff -> flag

book
In order to compile the code using d2c from Gwydion Dylan, I had to make a few corrections/modifications to the code. I have used the code from the printed version of the book by Feinberg, Keene, Mathews, and Withington. I have found some of the modifications in the version of the book available here. I do not know whether my solution is the best one or not. But it works for me.

Here is a list of these corrections:

file: airport-library.dylan

Gwydion Dylan does not provide transcendentals module as a part of transcendentals library but as a part of common-dylan library.
Should be
use common-dylan, import: {transcendentals};

file: airport-test-library.dylan

definitions library and definitions module are not imported.

file: airport-test.dylan

Values in *aircraft-distances* are not typed as <single-float>. As a consequence, en error "expected na instance of {the class <single-float>}, but got an instance of {the class <double-float>}" is displayed. It is enough to modify
distance: aircraft-distance,
in build-simple-aircraft method onto the form
distance: as(<single-float>,aircraft-distance),

file: airport-test.lid

It is necessary to define executable: keyword, for example
executable: airport-example

file: angle-library.dylan

The definition of angle module does not create <relative-angle>.

file: angle.dylan

direction and direction-setter are not defined as open generic functions.
Enough to add:
define open generic direction (object) => (object);
define open generic direction-setter (object, obj) => (obj);

file: definitions.dylan

Gwydion Dylan does not accept false-or method.
It is possible not to define it at all and import the method (GD provides it as a built-in method) or to define it as a macro:
define macro false-or
{ false-or(?other-type:name) }
=> { type-union(singleton(#f),?other-type) }
end macro;

file: position.dylan

angle slot of the <relative-position> class is typed as <angle>, but the <angle> class is abstract. Probably, <relative-angle> is the right choice.

file: schedule.dylan

The method available?(vehicle :: <aircraft>, container :: <runway>, direction :: <symbol>) defines its return value as <boolean> but the call to find-available-connection(container,class,vehicle) returns another type.
Solution can be to modify it, for example into the form:
find-available-connection(container,class,vehicle) ~== #f

file: sixty-unit-library.dylan

The last line of the definition of sixty-unit-implementation module is end module sixty-unit.
Should be end module sixty-unit-implementation, end module, or end.

file: sorted-sequence.dylan

Since <sorted-sequence> is a subclass of <sequence>, the definition of pop method is not congruent to generic function pop. On the other hand, the pop method is not used in the example (and can be safely commented out).

The definition of the remove! method is wrong. If there are more elements with the same value stored in the sorted sequence, only every second is deleted.
To correct it, it is enough to add

deletion-point := deletion-point -1;
right after the line
if(count) count := count - 1 end;

The string submitted to error (within forward-iteration-protocol) is split into two lines. Should be the whole on one line.

file: time.dylan

Definitions of \= and \> methods are not congruent with generic functions \= and \>, resulting into core dump. It is enough to add
=> (result :: <boolean>)
into the definitions of those methods.

file: vehicle-dynamics.dylan

$feet-per-mile is not typed as <single-float>. As a consequence, en error "expected na instance of {the class <single-float>}, but got an instance of {the class <double-float>}" is displayed. For instance, it could be
define constant $feet-per-mile = as(<single-float>,5280.0);

Copyright © MM
Last updated 18.4.2004