[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What?




----- Original Message -----
From: "mw" <nsp4@mac.com>
To: <info-dylan@ai.mit.edu>
Sent: Sunday, August 11, 2002 2:45 AM
Subject: What?


> What is this language? I have never heard of it before.

One reductionist breakdown might be:

Dylan = Scheme + CLOS + Smalltalk + Pascal

Scheme for basic semantics.
Common Lisp Object System (CLOS) for the object system, and exception
handling.
Smalltalk for "objects all the way down".
Pascal for syntax (ish).

An oversimplied historical view is that Dylan was Apple's Java. It was an
attempt to bring some of the power of the Lisp family of languages to
mainstream programming, by:

    - rationalizing some historical baggage
    - dropping some of the more complex/advanced/tangled features
    - making application/component delivery and deployment easier
    - adding some syntatic sugar

> What platforms does it cover?

It varies by compiler.

// Example: summing a stream of integers

define method sum-stream ( stream )
  let sum = 0;
  let n = #f;
  while ( n := read-line( stream, on-end-of-stream: #f ) )
    sum := sum + string-to-integer( n );
  end;
  sum
end;

// Example 2: with more type constaints and optional syntax

define method sum-stream ( stream :: <stream> ) => ( s :: <integer> )
  let sum :: <integer> = 0;
  let n :: false-or( <string> ) = #f;
  while ( n := read-line( stream, on-end-of-stream: #f ) )
    sum := sum + string-to-integer( n );
  end;
  sum
end method sum-stream;

// Example 3: more functional

define method read-lines ( stream )
  let collection = make( <stretchy-vector> );
  let line = #f;
  while ( line := read-line( stream, on-end-of-stream: #f ) )
    add!( collection, line );
  end;
  collection
end;

define method sum-stream ( stream )
  reduce( \+, map( string-to-integer, read-lines( stream ) ) )
end;

__Jason