O'Caml - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

O'Caml

Description:

let result = ChemParse.input Lexer.token lexbuf in. print_endline ... with Lexer.Eof - exit 0. Integer operators. Float operators. More Syntax and Semantics ... – PowerPoint PPT presentation

Number of Views:121
Avg rating:3.0/5.0
Slides: 12
Provided by: brentbr
Category:
Tags: caml | lexer

less

Transcript and Presenter's Notes

Title: O'Caml


1
O'Caml
  • COSC 4153
  • Spring 2008
  • Assignment 11
  • Brent Bradbury

2
Overview
  • Brief history
  • Syntax and semantics
  • Uses of the language
  • Advantages and disadvantages
  • Likes and dislikes
  • Conclusion
  • Sources

3
Brief History
  • Caml was originally an acronym for Categorical
    Abstract Machine Language.
  • First made by INRIA, a French CS research program
  • Guy Cousineau made CAML in 1987
  • Xavier Leroy and Damien Doligez followed in '91
    and '92 with CAML Light
  • Xavier Leroy released CAML Special Light in 1995,
    adding a native compiler and module system

4
And finally,
  • O'Caml added support for object-oriented
    functional programming in 1996
  • O'Caml combines standard object-oriented
    techniques with the static typing and type
    inference of ML

5
Basic Syntax and Semantics
( main.ml)? open ChemParse open Lexer let
_ try let lexbuf Lexing.from_channel
stdin in while true do
let result ChemParse.input Lexer.token lexbuf
in print_endline result
flush stdout done with Lexer.Eof -gt
exit 0
6
More Syntax and Semantics
let rec add x y if y 0 then x else
(add x (y - 1)) 1 let rec mult x y
if y 0 then 0 else let z (mult x (y - 1))
in add x z
  • Recursive functions must be explicitly defined,
    otherwise their name is outside their internal
    scope
  • Types are not implicitly coerced. Operators,
    since they are also considered functions, must
    work on appropriate types.

Integer operators
Float operators

let average a b (a . b) /. 2.0
let average a b (a b) / 2
7
Uses of the Language
  • Almost entirely used in academia
  • Can substitute for Matlab in some applications
  • Has hooks into many useful libraries (LAPACK,
    OpenGL, GTK, etc.)?
  • Still isn't very practical for large applications
  • A few small companies use O'Caml, but no one
    significant

8
Advantages and Disadvantages
  • Advantages
  • Algorithm development is fast
  • It can be compiled, and runs quickly
  • Doesn't stay so functional that it can't be made
    practical
  • Disadvantages
  • It's obscure
  • It lacks infrastructure for proper software
    engineering
  • The syntax is unintuitive and hard to learn

9
Likes and Dislikes
  • Likes
  • Algorithms are concise
  • I feel really smart whenever I make anything work
  • Objects are useful and grant good flexibility.
  • Dislikes
  • The syntax is annoying
  • Doing everything functionally is frustrating
  • Static typing is frustrating, mostly.

10
Conclusion
  • O'Caml is not very useful
  • It's a good academic exercise, though
  • I plan to write an IUPAC alkane name to NMR
    Spectroscopy parser with complete unit tests,
    because I have to for a job interview
  • I'm using ocamlyacc and ocamllex to do the
    parsing
  • I'm using OUnit for unit testing

11
Sources
  • http//www.ocaml-tutorial.org
  • http//caml.inria.fr/about/history.en.html
  • http//wiki.cocan.org/people/north_america
Write a Comment
User Comments (0)
About PowerShow.com