Browse thread
Teaching bottomline, part 3: what should improve.
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Gerd Stolpmann <info@g...> |
| Subject: | Re: [Caml-list] Teaching bottomline, part 3: what should improve. |
Am Mittwoch, den 23.05.2007, 08:49 -0400 schrieb Brian Hurt: > Vincent Hanquez wrote: > > On Wed, May 23, 2007 at 09:16:44AM +1000, skaller wrote: > > > > > On Tue, 2007-05-22 at 18:10 -0400, David Teller wrote: > > > > > > > > > > * Error messages of the type system are somewhat obscure. The reflex of > > > > many students is "OCaml wants it to be of type XXX", rather than "there > > > > is a contradiction in what I wrote". It would be nice if there was a way > > > > to ask OCaml to display additional information on type errors. > > > > > > > This is a long standing peeve of mine. Lets face it: Ocaml just lies. > > > If it has inferred a type, then finds a contradiction, it should > > > report both the location of the contradication AND all of the source > > > lines that contributed to the inference. > > > > > > > I agree, this is one of the worst thing about ocaml type inference, > > and you sometimes end up to have to put explicit type to functions to > > find the offending lines (usually hundreds lines before the actual line > > that's printed), defeating the whole thing... > > > > Cheers, > > > > Hundreds of lines? I've seen ten's of lines, but never hundreds. I can confirm that: hundreds. This happens especially for mismatching class types, because the compiler tries to break the mismatch down. But beginners shouldn't use classes. > Of course, I generally type annotate at the level of functions at > least (using .mli files is to be encouraged, IMO). So type errors > generally don't escape functions. And I keep functions reasonably > short- tens of lines long at most... There is certainly a point. The length of type errors depends on your programming style. A teacher can give hints how to make everything easier to handle. (Although it is also a valid point in education to let the students find their limits.) Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------