[PRL] annoying types ARGH!

Carl Eastlund carl.eastlund at gmail.com
Thu May 12 19:53:36 EDT 2005


On 9/1/05, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> I just wrote this little program for Karl:
> 
[snip]
> > let distance((x1,y1),(x2,y2)) =
> >     let dx = x1 -. x2 in
> >     let dy = y1 -. y2 in
> >       sqrt(dx *. dx +. dy *. dy)
[snip]
> Before I finished, I had_10_ type errors, one was real. Can you guess
> what went wrong?

Well, I would guess that leaving out the "." after the +,-,* would
cause most of those.  That is one part of OCaml I could do without. 
Not that I find the need to do inexact math much.

Also, if it were me writing the code I'd forget the "rec" after the
"let" and probably screw up the commas somewhere (OCaml's tuple syntax
is dumb if you do anything unexpected with a comma).  I don't know
which of these errors you'd call "real" though.

> Next I had one logical error, which would have launched anti-aircraft
> rockets at anything remotely on the planet. (This is an excerpt from
> the Hudak-documented DoD programming contest, reformulated a in A
> Little Java for peaceful purposes :-)

I suppose this means your program wasn't supposed to launch
anti-aircraft rockets at everything on the planet.  You'll never make
it in the video game market that way.

> Yes, I am on record saying that I'd use OCAML if I worked in industry,
> but boy this makes me reconsider this one.

Well, this is my second summer of OCaml hacking and for
interpreter-writing it still seems like the right thing.  One might
claim, "but not every job is interpreter-writing", but mine all seem
to be so this conclusion works for me.  Still, I could write a very
long list of things I'd change about OCaml.  Starting with decoupling
the module system from the file system.  ARGH.

--Carl



More information about the PRL mailing list