Penguin

Differences between version 14 and predecessor to the previous major change of ML.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 14 Last edited on Sunday, February 16, 2003 6:06:08 pm by GlynWebster Revert
Older page: version 10 Last edited on Saturday, February 15, 2003 11:58:12 pm by GianPerrone Revert
@@ -1,20 +1,19 @@
 ''(I'm still working on this, so some parts will still be gibberish. --GlynWebster)'' %%% 
-''(And I may be wandering off into little tutorials where I don't need to. What do you think? --GlynWebster)'' 
+''(And I may be wandering off into little tutorials where I don't need to. What do you think? --GlynWebster)''%%%  
+''(Tutorial's are good, this is supposed to be an interesting place to go and learn stuff from, however, not all these concepts are exclusively ML, for instance StaticallyTyped, HigherOrder, PolyMorphic, Functional, StandardisedLanguage, are all attributes of other programming languages too, breaking these out into their own pages would be educational no? -- PerryLorier )'' 
  
 !!!ML in one paragraph, with buzzwords: 
  
-ML is a family of statically typed [1], higher-order[2], polymorphic[3], strict [4 ] functional programming languages with a higher-order module system[5]. ML is very good general purpose programming language[6] with a strength in pattern matching[7]. ML can  
- be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of ML are [Ocaml] and [SML]. SML is a standardized language[8] with several implementations[9]. Ocaml has a single open source implementation[10],  
- it extends ML with an OOP system[11]. Both major dialects have compilers that produce native code that rivals the speed of C++, and extensive standard[12] and third-party[13] libraries. 
+ML is a family of StaticallyTyped [1], [strict | StrictEvaluation][4] [ higher-order | HigherOrderFunctions] [2], polymorphic[3], [FunctionalLanguage ]s with and a higher-order module system[5]. ML is very good general purpose programming language[6] with a strength in pattern matching[7]. ML can be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of ML are [Ocaml] and [SML]. SML is a standardised language[8] with several implementations[9]. Ocaml has a single open source implementation[10], it extends ML with an OOP system[11]. Both major dialects have compilers that produce native code that rivals the speed of C++, and extensive standard[12] and third-party[13] libraries. 
  
 ''(Click a footnote for more info.)'' 
  
 !!!An example of ML code: 
  
  __fun__ interpret_functionally (program : opcode list) : unit = 
  (* Interprets a parsed [Brainf*ck] program using integers 
- on a strip of Turing Machine tape as the memory. *) 
+ on a strip of TuringMachine tape as the memory. *) 
  __let__ 
  __val__ fresh_tape = Tape.make(0) 
  __fun__ step (tape, op) = 
  __let__ byte = Tape.read(tape) __in__ 
@@ -25,10 +24,10 @@
  | Dec_byte n => Tape.write(byte - n, tape) 
  | Putchar => ( putchar(byte) ; tape ) 
  | Getchar => Tape.write(getchar(), tape) 
  | Loop body => 
- __if__ byte = 0 __then__ tape  
- __else__ step (step_sequence (tape, body), op) 
+ __if__ byte = 0 __then__ tape  
+ __else__ step (step_sequence (tape, body), op) 
  __end__ 
  __fun__ step_sequence (tape, oplist) = 
  List.foldl(step, tape, oplist) 
  __in__ 
@@ -38,23 +37,15 @@
 (This is in SML. The following examples will be in Ocaml.) 
  
 ---- 
  
-[1]  
-!!!Static Typing  
-  
-ML does all its type checking at compile time. ML can determine a variable's type by analyzing how it is used: you only need to declare types in places where you think it improves your code's clarity.  
-  
-''The other approach to type checking is "dynamic typing". Types are associated with values, and programs are left to do their own type checking at run time. [Perl], [Python], and [Scheme] (a language that semantically similar to ML in other respects) are dynamically typed.''  
+[1] ML can determine a variable's type by analyzing how it is used: you only need to declare types in places where you think it improves your code's clarity. 
  
  
 [2] 
 !!!Polymorphism 
  
-This is what prevents ML's strong type checking from being a pain in  
- the bum. You don't have to define the type of everything ''exactly'',  
- you can leave some types, or parts of some types unspecified. For  
- example this is a type for binary trees: 
+This is what prevents ML's strong type checking from being a pain in the bum. You don't have to define the type of everything ''exactly'', you can leave some types, or parts of some types unspecified. For example this is a type for binary trees: 
  
  # __type__ 'a tree = Leaf __of__ 'a | Node __of__ 'a tree * 'a tree ;; 
  ''type 'a tree = Leaf of 'a | Node of 'a tree * 'a tree'' 
  
@@ -82,10 +73,9 @@
  
 [3] 
 !!!Higher-order Functions 
  
-Higher-order functions are functions that take other functions as parameters,  
- create functions or return functions. 
+Higher-order functions are functions that take other functions as parameters, create functions or return functions. 
  
 I want make new trees from old ones by changing the leaves. So I write a function to do this for me. One of its parameters will be a function that takes the value of a leaf and returns the changed value. 
  
  # __let rec__ map change tree = 
@@ -112,20 +102,19 @@
 And it does! 
  
 If I write a few more functions like this I will have a reusable library of binary tree operations. ML makes writing reusable code and easy and ''reliable'' process. 
  
-There's a lot more things you can do with higher-order functions, some of then very painful. I've just shown you there's at least ''one'' good thing you can do with then here. 
+There's a lot more things you can do with higher-order functions, some of them very painful. I've just shown you there's at least ''one'' good thing you can do with then here. 
  
 ''Higher-order functions are something ML has in common with [Haskell].'' 
  
  
 [4] 
 !!!Strict Evaluation 
  
-ML expression and function calls are evaluated in the strict fashion: the value of the expression for each parameter is worked out before passing to a function . If you've used a an ImperativeLangauge like [C] or [Java], then this is just what you are used to. Strict evaluation means you can predict the order that ML expressions will be  
-evaluated in, and ML can allow reassignable variables and a conventional I/O system -- which it does. 
+ML uses StrictEvaluation . This means that ML can allow reassignable variables and a conventional I/O system -- and it does. 
  
-''The other approach to evaluation is "lazy evaluation". A functions is passed whole expressions as parameters and do not evaluate them until it need their values. (I won't go into __why__ you'd want that, but there are good reasons.) [Haskell]'s main semantic difference from ML is that is it is lazy . ( If you enjoyed Haskell programming at WaikatoUniversity but because exasperated with "monads" and working out convoluted ways to make your programs preserve state, ML may be the thing for you.) '' 
+''[Haskell]'s main semantic difference from ML is that is it uses LazyEvaluation . If you enjoyed Haskell programming at WaikatoUniversity but because exasperated with [Monad]s and working out convoluted ways to make your programs preserve state, ML may be the thing for you.'' 
  
  
 [5] 
 !!!Higher-Order Module System