The latest issue of Monad.Reader (a electronic magazine about Haskell) includes an interesting article about Jane Street Capital (a Wall Street trading company) and its use of OCaml. The author points good and bad things about the language; these aren't new, in fact the things pointed are well-known by the community, but it's good to hear them from someone using the language in a production setting.
Anyway, it's a case of large-scale adoption -- in the sense of using it as the main language for all development -- of a functional programming language, which is still rare, unfortunately.
Monday, April 30, 2007
Tuesday, April 3, 2007
One Language to Rule Them All
A discussion on LtU about the Next Big language, the next Java or something like it. Links to the post by Steve Yegge too. Once again Scala is mentioned as a fine language that anyone needing to develop for the JVM should try.
I don't believe Scala will be the next big language, but it really is fine. At the moment I'm finishing implementation of a simple distributed system written in Scala. It had to run on the JVM to communicate with other Java programs. It was a breeze to do, thanks to the Actors library. Scala's type system is quite interesting too, I plan on giving more attention to it when I have the time.
I don't believe Scala will be the next big language, but it really is fine. At the moment I'm finishing implementation of a simple distributed system written in Scala. It had to run on the JVM to communicate with other Java programs. It was a breeze to do, thanks to the Actors library. Scala's type system is quite interesting too, I plan on giving more attention to it when I have the time.
EOPL - 3.2 - Exercise 3.5
Exercise 3.5 asks you to add a
In the lexer specification a token for the
And, in the parser, this token must be declared and dealt with:
The remaining parts of these three files are the same as the previous two posts.
print
primitive to the language, which prints its argument and returns the value 1. The relevant changes are simple. In module Eopl_3
only the definition of type Primitive
and function apply_primitive
are different:
// in eopl_3.fs (module Eopl_3)
type Primitive = AddPrim | SubtractPrim | MultPrim | IncrPrim
| DecrPrim | PrintPrim
let apply_primitive prim args =
match (prim, args) with
(AddPrim, [a; b]) -> a + b
| (SubtractPrim, [a; b]) -> a - b
| (MultPrim, [a; b]) -> a * b
| (IncrPrim, [a]) -> a + 1
| (DecrPrim, [a]) -> a - 1
| (PrintPrim, [a]) -> (print_endline (string_of_int a); 1)
| _ -> failwith "Incorrect argument list for primitive"
In the lexer specification a token for the
print
primitive is added:
rule token = parse
| whitespace { token lexbuf }
| '%' [^ '\n']* { token lexbuf }
| newline { record_newline lexbuf; token lexbuf }
| "+" { PLUS }
| "-" { MINUS }
| "*" { MULT }
| "(" { LPAREN }
| ")" { RPAREN }
| "," { COMMA }
| "add1" { INCR }
| "sub1" { DECR }
| "print" { PRINT }
| id { ID(lexeme lexbuf) }
| ['-']?digit+ { LIT (Int32.Parse(lexeme lexbuf)) }
| eof { EOF }
And, in the parser, this token must be declared and dealt with:
%token PRINT INCR DECR LPAREN RPAREN PLUS MINUS MULT COMMA EOF
Prim: PLUS { AddPrim }
| MINUS { SubtractPrim }
| MULT { MultPrim }
| INCR { IncrPrim }
| DECR { DecrPrim }
| PRINT { PrintPrim }
The remaining parts of these three files are the same as the previous two posts.
Subscribe to:
Posts (Atom)