On Friday 04 April 2008 08:04:47 daniel.c.buenzli wrote: > On 4 avr, 00:09, Jon Harrop <[EMAIL PROTECTED]> wrote: > > Sure. F# simply cures a practically important class of bugs that OCaml > > leaves wide open. > > Well not in that case it seems. Frankly both approaches seem to have > problems. Best I think would be compile time warnings for caml when > abstract types are being compared with structural equality
Alas, that is impossible with OCaml's current design because it can't do monomorphization. All the OCaml compiler ever sees is a completely polymorphic: a = b and it has no idea that this will later be erroneously applied to an abstract type as well as its correct applications to other types. Your best chance of a simple solution is to copy SML's equality types, which would be a fundamental change to OCaml's type system. That doesn't scale as the F# solution does but at least it will catch this important class of bugs. Ideally, you just want to copy F#/.NET because that solution is now known to be a much better solution in practice. > (a wish you could have put in the bt by the way). What is "the bt"? > > That is an awful policy. > > Not it is not, there's just a balancing act to make, but most go in a > single direction which is to have the least explicitness to get > conciseness, a curse since it makes the coginitive load heavier to > understand the code. Brevity also reduces the cognitive load. If you look at the OCaml equivalent of "set [1 .. 1000]" it is clearly entirely superfluous piffle that does nothing whatsoever to help the reader understand what is going on. Indeed, it is *more* likely to be buggy. > > Look at the current thread on the caml-list about how > > unusable the Int64 type is. > > Non issue. Huge issue. > Very rarely is this type needed and when you need it you > usually don't use regular ints in the same module, A triumph of hope over reality, I am afraid. Numeric types are often used in conjuction, such as scalars, vectors and matrices. The thread on the caml-list even detailed a complete example that does exactly this for int and int64 in an attempt to overcome some of OCaml's other problems. > thus redefine standard operators (4 lines). You are looking at having to define and remember literally hundreds of different decorated operators in OCaml to cover the necessary permutations of basic types. As that is not feasible, OCaml neglects basic types (int16, float32) and provides no operators for many others (int8, int32, int64). -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ocaml-developer" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ocaml-developer?hl=en For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html -~----------~----~----~----~------~----~------~--~---
