Gwydion Extensions to Dylan

Previous Page TOC Index Next Page See Page

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library


Gwydion Extensions

Copyright (c) 1994, 1995, 1996, 1997 Carnegie Mellon University All rights reserved.

1. Introduction

In the process of working with Dylan, the Gwydion Project has come up with numerous extensions to the Dylan language. Some of them form entire libraries, like the Collection-Extensions and String-Extensions libraries. Others have been added to the Dylan library, in such modules as Extensions and System.

We continue to make no claims about future support for our extensions. However, some extensions are more likely than others to make it into our future compilers. This file documents those extensions which we think will be included in our compiler’s Dylan library. Extensions which go in separate libraries are documented in their own files; extensions which are part of the Mindy Dylan library but which have a less certain future are documented in the Mindy documentation.

For the remainder of this document, we shall refer to "Gwydion compilers" as a shorthand for "Mindy and other Dylan compilers that the Gwydion Project may write." It is not meant as a guarentee that all future Gwydion releases will support these extensions.

Specific Gwydion compilers may support extensions not listed here; see their documentation for details.

2. Dylan Language Issues

Whenever possible, we have tried to keep the Dylan module pristine and unextended, prefering to add our extensions to separate modules or libraries. However, this is not always possible, particularly when it involves extending the behavior of a function or macro that is exported from the Dylan module. Currently, Gwydion compilers support these extensions to the Dylan module as described below:

          var KEYED-BY key IN collection

Var is bound to each element in collection, and key is bound to the element's key value.

          var IN collection USING protocol

protocol will be used instead of forward-iteration-protocol. protocol must be a variable name, not an expression. Using clauses may be used together with keyed-by:

          var KEYED-BY key IN collection USING protocol
          define function cube (x)

x * x * x;
end function cube;

A similar result might be had by writing

          define constant cube = method (x)

x * x * x;
end method;

or

          define method cube (x)

x * x * x;
end method cube;
          define method make

(result-class :: limited(<class>, subclass-of: <my-class>));
let x = next-method();
do-special-logging-or-something(x);
x;
end method;

3. Conditional Compilation

Gwydion compilers supports conditional compilation. The syntax is

          #if (feature-expression)

dylan-code
#elseif (feature-expression)
dylan-code
#else
dylan-code
#endif

(The #elseif and #else clauses are optional) A feature-expression is composed of features and the ~, &, and | operators, and may be parenthesiszed as usual. Features are not case sensitive. Mindy and d2c use the -D and -U command line switches to define new features. Some features currently supported include:

mindy
compiled-for-hppa
compiled-for-x86
compiled-for-sparc
compiled-for-hpux
compiled-for-win32
compiled-for-linux
compiled-for-solaris
compiled-for-unix
newlines-are-CRLF

4. Modules of the Dylan Library

In addition to containing the Dylan module, the Dylan library contains a variety of modules which provide extensions. Gwydion compilers export the following modules from the Dylan library:

Extensions
System
Introspection
Cheap-io

5. The Extensions Module

Ultimately, there will be several, more logically separate libraries that extend Dylan or provide an application framework for users. For now, we put any commonly used utilities in the Extensions module.

5.1. Generally Useful Definitions

The Extensions module exports the following generally useful functionality:

<byte-vector> [Class]

<byte-character> [Class]

assert [Function]

Arguments
Values
Description

one-of [Function]

Arguments
Values
Description
            one-of(#"foo", #"bar", #"baz")
             type-union(singleton(#"foo"), singleton(#"bar"), singleton(#"baz"))

false-or [Function]

Arguments
Values
Description
            false-or(<integer>)
            type-union(<integer>, singleton(#f))

5.2. Debugger Customizations

(A note on terminology: We use the term "debugger" here in the loose, Dylan sense of anything that handles an uncaught error. In Mindy, this debugger is indeed a full fledged debugger, but in other Gwydion compilers it may not be)

The debugger uses the function report-condition to print conditions as error messages to users; for example, this is the function that implements the %S format-string directive for conditions. The debugger also uses the format function exported from the Cheap-io module to process format strings, and it prints directly to the Unix stdout. If any library that is used itself uses the Debugger-format library, then the debugger uses format from the Format library, which is shipped with Gwydion compilers. You can extend how the debugger prints conditions, change what formatting function it uses, and direct where debugger output goes with the following:

report-condition [Generic Function]

Arguments
Values
Description

condition-format [Generic Function]

Arguments
Values
Description

condition-force-output [Generic Function]

Arguments
Values
Description

*warning-output* [Variable]

5.3. Exiting Applications

The Extensions module exports the following functionality for controlling the exiting of applications:

exit [Function]

Arguments
Description

5.4. Collections

The Extensions module exports the following <collection> functionality:

key-exists? [Generic Function]

Arguments
Values
Description

5.5. Integers

Gwydion compilers have an abstract class <general-integer> which has two concrete subclasses, <integer> and <extended-integer>. <integer>s have a limited range of values, and <integer> arithmetic uses the computer’s underlying integer facilities. <extended-integer>s can take on any value, and are similar to Common Lisp "big-nums." Expressions involving <extended-integer>s produce <extended-integer> results because <extended-integer>s are contagious. If an expression involving only <integer> values would produce a result that does not fit in an <integer>, then the Gwydion compiler will signal an overflow error. You can use the as function to convert back and forth between <integer>s and <extended-integer>s. As signals an error when converting an <extended-integer> to a <integer>, and the value does not fit in a <integer>.

The Extension module exports the following integer functionality:

<general-integer> [Abstract Class]
<extended-integer> [Class]

$maximum-integer [Constant]

$minimum-integer [Constant]

5.6. Ratios

The Extensions module exports the following:

<ratio> [Class]

ratio [Function]

Arguments
Values
Description

numerator [Function]

Arguments
Values
Description

denominator [Function]

Arguments
Values
Description

6. The System Module

The System module exports the following:

<buffer> [Class]

copy-bytes [Function]

Arguments
Values
Description

getenv [Function]

Arguments
Values
Description

get-time-of-day [Function]

Arguments
Values
Description

system [Function]

Arguments
Values
Description

7. The Introspection Module

The Introspection module exports reflective operations for examining classes, functions, and types.

7.1. Functions

Dylan provides some reflective operations for functions, such as function-specializers and instance?. With the latter, you can determine if a function is a <generic-function> or <method>, but neither Dylan nor Gwydion compilers provide exported class identifiers for other types of functions (such as block exit functions). The Subsection Types describes definitions that are also useful when inspecting methods because you can get detailed information about method specializer types.

The Introspection module exports the following functions:

function-name [Function]

Arguments
Values
Description

7.2. Classes

The Introspection module exports the following for class objects:

class-name [Function]

Arguments
Values
Description

7.3. Types

The Introspection module exports the following for inspecting types (and therefore, method specializers):

singleton-object [Function]

Arguments
Values
Description

<subclass> [Class]

subclass-of [Function]

Arguments
Values
Description

<limited-integer> [Class]

limited-integer-base-class [Function]

Arguments
Values
Description

limited-integer-minimum [Function]

limited-integer-maximum [Function]

Arguments
Values
Description

<union> [Class]

union-members [Function]

Arguments
Values
Description

7.4. Miscellaneous

The Introspection module exports the following miscellaneous functionality:

object-address [Function]

Arguments
Values
Description

8. The Cheap-io Module

The Cheap-io module exports some basic, unextendable I/O functionality. Gwydion compilers use the Cheap-io functions internally. The Gwydion Project also provides the Streams, Print, and Format libraries (see the $INSTALL/doc/libraries/ directory for documentation). It is an error to use both Cheap-IO functions and Streams/Print/Format functions on a single stream. (For example, if you are using the Streams library *standard-input*, do not also use the Cheap-io input functions) For this reason, if any library that you load into Mindy uses the Debugger-format library, the debugger will use format from the Format library.

format [Function]

Arguments
Values
Description

print [Function]

Arguments
Values
Description

9. Extensions to the Streams Library

The Piped-exec module is a Gwydion extension to the Streams library. It exports the following function:

piped-exec [Function]

Arguments
Values
Description

10. Copyright and Terms of Use

Copyright (c) 1994, 1995, 1996, 1997 Carnegie Mellon University All rights reserved.

Use and copying of this software and preparation of derivative works based on this software are permitted, including commercial use, provided that the following conditions are observed:

This software is made available as is. Neither the authors nor Carnegie Mellon University make any warranty about the software, its performance, or its conformity to any specification.

Bug reports, questions, comments, and suggestions should be sent by E-mail to the Internet address gwydion-bugs@cs.cmu.edu.

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library

Previous Page TOC Index Next Page See Page

Copyright 1994, 1995, 1996, 1997 Carnegie Mellon University. All rights reserved.

Send comments and bug reports to gwydion-bugs@cs.cmu.edu