Re: Syntax for label, NEW PROPOSAL

From: Christophe Raffalli (Christophe.Raffalli@univ-savoie.fr)
Date: Wed Mar 15 2000 - 07:58:42 MET

  • Next message: Benoit Deboursetty: "Re: let ... in layout"

    Jacques Garrigue wrote:
    >
    > In this case, I suppose we should read `%' as `is'.
    >

    > Objective Caml version 2.99+10
    >
    > # List.map;;
    > - : fun%('a -> 'b) -> 'a list -> 'b list = <fun>
    > # List.map [1;2;3] fun%succ;;
    > - : int list = [2; 3; 4]
    > # let sub ?(%pos = 0) ?%len s =
    > let len = match len with Some x -> x | None -> String.length s - pos in
    > String.sub %pos %len s;;
    > val sub : ?pos%int -> ?len%int -> string -> string = <fun>
    >

    I really do think that it looks better !

    You could continue to use ":" in types: because you are giving
    information about the type of a label. this would make

    # List.map;;
    - : fun:('a -> 'b) -> 'a list -> 'b list = <fun>
    # List.map [1;2;3] fun%succ;;
     - : int list = [2; 3; 4]
    # let sub ?(%pos = 0) ?%len s =
        let len = match len with Some x -> x | None -> String.length s - pos
    in
        String.sub %pos %len s;;
    val sub : ?pos:int -> ?len:int -> string -> string = <fun>

    -- 
    Christophe Raffalli
    Université de Savoie
    Batiment Le Chablais, bureau 21
    73376 Le Bourget-du-Lac Cedex
    

    tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI



    This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 08:52:00 MET