Re: Syntax for label, NEW PROPOSAL

From: Remi VANICAT (remi.vanicat@labri.u-bordeaux.fr)
Date: Wed Mar 15 2000 - 20:11:08 MET

  • Next message: Xavier Leroy: "Re: Syntax for label (and more)"

    Pierre Weis <Pierre.Weis@inria.fr> writes:

    > $ ocamlpedantic
    > Objective Caml version 2.99+10
    >
    > # let sum l = List.fold_right ( + ) l 0;;
    > ^^^^^
    > This expression has type int -> int -> int but is here used with type 'a list
    >
    > Clearly, there is something wrong now! We may remark that the error
    > message is not that clear, but this is a minor point, since error
    > messages are never clear enough anyway!
    >
    > The real problem is that fixing the code makes no good at all to its
    > readability (at least that's what I would say):
    >
    > # let sum l = List.fold_right fun:begin fun x acc:y -> x + y end acc:0;;
    > val sum : 'a -> int list -> int = <fun>

    here, i prefer to use parenthesis as :

    let sum l = List.fold_right fun:(fun x acc:y -> x + y) acc:0;;

    it's more readable

    also i do want the fun: label (you may change the name, but a label
    here is useful) to be able to write

    let sum l = List.fold_right acc:0
                  fun:(fun long multi line function definition here)

    but i agreed that the acc label (in fun x acc:y -> x + y) is a pain,
    because he forbid the use of usual function here

    -- 
    Rémi Vanicat
    vanicat@labri.u-bordeaux.fr
    http://dept-info.labri.u-bordeaux.fr/~vanicat
    



    This archive was generated by hypermail 2b29 : Fri Mar 17 2000 - 09:11:50 MET