[PRL] annoying types ARGH!
Matthias Felleisen
matthias at ccs.neu.edu
Thu May 12 20:41:32 EDT 2005
On May 12, 2005, at 7:53 PM, Carl Eastlund wrote:
> 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.
Correct. They bubble thru and trigger others.
The only proper type error was in the inShape function, where I had
used the wrong "default" because I was too lazy to finish the function
complete. The logical error was in <= . I compared it to the wrong
value of proper type. (I used to keep an error log when I programmed.
For some 10,000 lines of code a year, this was by far my most common
kind of mistake.)
> 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.
I forgot the rec for a moment but it was obvious. Otherwise I coped
with OCAML syntax after three years of abstinence w/o a hitch.
>> 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.
Yeap, it's a crime. And mzscheme is only an epsilon better in this
regard.
More information about the PRL
mailing list