Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /pages/trunk/sml.html
ViewVC logotype

Annotation of /pages/trunk/sml.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 953 - (view) (download) (as text)

1 : macqueen 953 <HTML>
2 :     <TITLE>Standard ML</TITLE>
3 :     <BODY BGCOLOR="ffffff">
4 :    
5 :     <h1>Standard ML</h1>
6 :     <HR>
7 :     <p>
8 :     <blockquote>
9 :     Standard ML is a safe, modular, strict, functional, polymorphic
10 :     programming language with compile-time type checking
11 :     and type inference,
12 :     garbage collection, exception handling,
13 :     immutable data types and updatable references,
14 :     abstract data types, and parametric modules.
15 :     It has efficient implementations and a formal definition
16 :     with a proof of soundness.
17 :    
18 :     <dl>
19 :     <dt><strong>Safe</strong><dd>
20 :     ML is safe, in that a program that passes the type-checker
21 :     cannot dump core, access private fields of abstract data types,
22 :     mistake integers for pointers, or otherwise "go wrong."
23 :    
24 :     <dt><strong>Modular</strong><dd>
25 :     The Standard ML module system supports modules (called <i>structures</i>)
26 :     and interfaces (called <i>signatures</i>); the signature of a module
27 :     determines what components and types from the module are visible
28 :     from outside. There is a flexible system for matching structures
29 :     to signatures: there can be several different views (signatures)
30 :     of the same structure, and there can be several different
31 :     implementations (structures) matching the same signature.
32 :    
33 :     <dt><strong>Functional</strong><dd>
34 :     ML has higher-order functions: functions can be passed
35 :     as arguments, stored in data structures, and returned as results
36 :     of function calls. Functions can be statically nested within
37 :     other functions; this lexical scoping mechanism gives the ability
38 :     to create "new" functions at run time.
39 :    
40 :     <dt><strong>Strict</strong><dd>
41 :     Function calls in ML, like those of C, Pascal, C++, Java, etc., evaluate
42 :     their arguments before entering the body of the function.
43 :     Such a language is called <i>strict</i> or <i>call-by-value</i>,
44 :     in contrast to some functional programming languages that
45 :     are <i>lazy</i> or <i>call-by-need</i>. Strict evaluation makes it
46 :     easier for the programmer to reason about the execution of the program.
47 :    
48 :     <dt><strong>Polymorphic</strong><dd>
49 :     ML supports polymorphic functions and data types.
50 :     Data-type polymorphism
51 :     allows a single type declaration (such as "list") to describe
52 :     lists of integers, lists of strings, lists of lists of integers, and so on;
53 :     but the programmer can be assured that, given an "int list",
54 :     every element really is an "int". Function polymorphism allows
55 :     a single function declaration (such as filter_list) to operate on
56 :     lists of integers, lists of strings, lists of integer-lists,
57 :     and so on, avoid needless duplication of code.
58 :    
59 :     <dt><strong>Compile-time type checking</strong><dd>
60 :     Programmers in compile-time type-checked languages get the
61 :     benefit not only of faster execution but also less debugging:
62 :     many of the programmer's mistakes can be caught early in the
63 :     development process; and the types may lead to clearer thinking about
64 :     the program's specification.
65 :    
66 :     <dt><strong>Type inference</strong><dd>
67 :     The ML programmer need not write down the type of every
68 :     variable and function-parameter: the compiler can usually
69 :     calculate the type from context. This makes programs more
70 :     concise and easier to write.
71 :    
72 :     <dt><strong>Garbage collection</strong><dd>
73 :     Automatic deallocation of unreachable data makes programs
74 :     simpler, cleaner, and more reliable.
75 :    
76 :     <dt><strong>Exception handling</strong><dd>
77 :     ML's exception-handling mechanism -- similar to the ones
78 :     in C++, Java, Ada, etc. -- provides dynamic nesting of handlers
79 :     and eliminates the need for ad hoc, special exceptional
80 :     return values from functions.
81 :    
82 :     <dt><strong>Immutable data types</strong><dd>
83 :     In ML, most variables and
84 :     data structures -- once created and initialized -- are
85 :     <i>immutable</i>, meaning that they are never changed, updated, or
86 :     stored into. This leads to some powerful guarantees of noninterference
87 :     by different parts of the program operating on those data structures.
88 :     In a functional language such as ML, one tends to build new data
89 :     structures (and let the old ones be garbage collected) instead of
90 :     modifying old ones.
91 :    
92 :     <dt><strong>Updatable references</strong><dd>
93 :     However, ML does have updatable (assignable) <i>reference</i> types,
94 :     so that in those cases where destructive update is the most natural
95 :     way to express an algorithm, one can express it directly.
96 :    
97 :     <dt><strong>Abstract data types</strong><dd>
98 :     ML supports information hiding, so that one can implement a data
99 :     type whose representation is hidden by an interface that just exports
100 :     functions to construct and operate on the type.
101 :    
102 :     <dt><strong>Parametric modules</strong><dd>
103 :     A <i>functor</i> is an ML program module takes the signature
104 :     of another module as an argument. The functor can then be applied to
105 :     any module matching that signature. This facility is like the
106 :     <i>template</i> of C++ or the <i>generic</i> of Ada or Modula-3,
107 :     but in ML the functor can be completely type-checked and compiled
108 :     to machine code before it is applied to its argument(s); this leads
109 :     to better program modularity.
110 :    
111 :     <dt><strong>Efficient implementations</strong><dd>
112 :     Features such as polymorphism, parametric modules, and a heavy
113 :     reliance on garbage collection have meant that compiling ML to efficient
114 :     machine code requires techniques not usually necessary in C compilers.
115 :     Several Standard ML
116 :     compilers generate high-quality machine code, including
117 :     <a href="index.html">Standard ML of New Jersey</a> and
118 :     <a href="http://www.harlequin.com/products/ads/ml/">Harlequin ML Works</a>.
119 :    
120 :     <dt><strong>Formal definition</strong><dd>
121 :     The ML language is clearly specified by
122 :     <a href="http://mitpress.mit.edu/book-home.tcl?isbn=0262631814"><I>The Definition of Standard ML
123 :     (Revised)</I> (Milner, Tofte, Harper, MacQueen, MIT Press, 1997)</a>,
124 :     which defines the language in 93 pages of mathematical notation and
125 :     English prose. This book is not meant for the casual reader, but
126 :     it is accessible to the serious student of programming languages and
127 :     its existence and accessibility provide an implementation-independent
128 :     formulation of Standard ML.
129 :    
130 :     <dt><strong>Proof of soundness</strong><dd>
131 :     A consequence of having the language definition in a formal notation
132 :     is that one can
133 :     <a href="http://simon.trinhall.cam.ac.uk/~mvi20/papers/JAR.html">prove
134 :     important properties of the language</a>, such as
135 :     deterministic evaluation or soundness of type-checking.
136 :    
137 :     </dl>
138 :     </blockquote>
139 :     <HR>
140 :     <CENTER><STRONG>
141 :     | <A HREF="index.html">SML/NJ Home Page</A> |
142 :     </STRONG></CENTER>
143 :     <HR>
144 :     Send your comments to <A HREF="mailto:sml-nj@research.bell-labs.com">sml-nj@research.bell-labs.com</A><BR>
145 :     <FONT SIZE="-3">
146 :     Copyright &#169; 1998,
147 :     <A HREF="http://www.lucent.com/">Lucent Technologies; Bell Laboratories</A>.
148 :     <BR>
149 :     </FONT>
150 :     </BODY>
151 :     </HTML>
152 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0