Dylan: Charles Grove, Philip Oliver
Download
Report
Transcript Dylan: Charles Grove, Philip Oliver
Dylan
An Object Oriented Dynamic
Language
Dylan Overview
Short for “Dynamic Langage”
General-purpose
Object-oriented
Attempts to combine functionality of:
Lisp
Smalltalk
C++
Why Dylan?
Apple's Advanced Technology Group
Different people using Lisp, SmallTalk, and
C++
Wanted a language to appease all three
groups
History and Downfall
Considered for use with the Apple Newton (the protoPDA)
Kept as general purpose Mac programming language
Much work on compilers and IDEs while Dylan still in
development.
For Mac by Apple
For Windows by Harlequin
“d2c” compiler for UNIX by CMU
Development scrapped in mid-1990s due to budget cuts.
Java became popular instead.
Dylan: Language Concepts
All objects are classes and functions.
All objects are “typed”.
Garbage Collection
Class Definition
define class <rock> (<object>)
slot initial-position :: <float>,
required-init-keyword: position:;
slot initial-velocity :: <float>,
required-init-keyword: velocity:;
end class;
Find Position Function
define function find-position-and-velocity (rock ::
<rock>, time :: <float>)
(position :: <float>, velocity :: <float>) values(-4.9
* time * time
+ rock.initial-velocity * time
+ rock.initial-position,
-9.8 * time + rock.initial-velocity);
end function;
Print Function
define function print-position-and-velocity (rock ::
<rock>, time :: <float>)
()
let (p, v) = find-position-and-velocity(rock, time);
format-out("Position: %=m, Velocity: %=m/s\n",
p, v);
end function;
Use of Class and Functions
define variable *rock* =
make(<rock>, position: 10.0, velocity: 0.0);
print-position-and-velocity(*rock*, 1.0);
*rock*.position := “5.0”;
position(*rock*) := “5.0";
position-setter(“5.0", *rock*);
Dylan vs C++
Dylan as a number of features that distinguish it
from C++ including:
automatic memory management
clean, consistent syntax
fully and consistently object-oriented model
dynamic as well as static type checking
support for incremental compilation
first-class functions and classes
Dylan vs Java
Dylan already has solutions to the Javas problems:
multiple implementation inheritance
multiple argument method dispatch
pure object types
no casting required
extensible syntax
good iteration/collection integration