Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FFS what do you want? The odd/even example is good. Just use your imagination. Do you really want me to post 5502 lines of mutually recursive Ocaml functions used flx_lookup.ml, used in my Felix compiler? [I'd give a link but the webserver is crashing at the moment;[</p> <pre><code>let rec trclose state bsym_table rs sr fs = ... and resolve_inherits state bsym_table rs sr x = ... and inner_lookup_name_in_env state bsym_table env rs sr name : entry_set_t = ... and lookup_qn_in_env2' state (bsym_table:Flx_bsym_table.t) (env:env_t) (rs:recstop) (qn: qualified_name_t) : entry_set_t * typecode_t list = ... and lookup_qn_in_env' (state:lookup_state_t) bsym_table (env:env_t) rs (qn: qualified_name_t) : entry_kind_t * typecode_t list = ... and inner_bind_type state (bsym_table:Flx_bsym_table.t) env sr rs t = ... ... lots more ... </code></pre> <p>You'll notice the annotations on some of the arguments, that's because type inference sucks when it comes to finding type errors in precisely the circumstances you're asking for a benefit. The annotations constrain the inference enough to help the compiler bug out on the line actually containing the bug. Ocaml compiler is not smart enough to trace how it infers types when a conflict is detected: this is a downside of inference (tracing the source of the inference is essential for reporting type errors, but it would seem to be very hard and it isn't clear that even if the information were available it could be reported in a suitable way).</p> <p>I personally dislike inference, particularly as it has some very bad properties: it doesn't work properly in Ocaml in the presence of polymorphic variants, is hard to extend to support overloading, is hard to extend to support polymorphic recursion, and doesn't necessarily terminate. It makes code hard to read because types are not named and the reader has to effectively duplicate the inference process in their head.</p> <p>The upside is it makes code look cleaner. After adding type annotations to find bugs, on finding the bug I often remove the annotations.</p> <p>If you compare Ocaml function definitions with those in Felix, which does not provide inference, you will immediately see the Felix code is a lot more verbose. However inference really shines when refactoring. It makes it so easy.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload