Version française
Home     About     Download     Resources     Contact us    
Browse thread
no error with ocamlc, a syntax error with ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] no error with ocamlc, a syntax error with ocaml
Why aren't you doing: ocaml tuvuw_from_data_error.ml?

You don't need to redirect input. Whether this is a bug or just an
unsupported use case is another question.

Jonathan

On 9/29/06, Francois Colonna <colonna@ccr.jussieu.fr> wrote:
> Hello,
>
> the small ocaml program attached gives no errors at compilation
>
> ocamlc -c tuvuw_from_data_error.ml
>
> and this syntax error at execution:
>
> ocaml < tuvuw_from_data_error.ml
>        Objective Caml version 3.09.2
>
> # * *       val s_d1 : string = "1"
> # val s_d2 : string = "2"
> # val s_d3 : string = "3"
> # val s_d4 : string = "4"
> # val s_d5 : string = "5"
> #     val d1 : int = 1
> # val d2 : int = 2
> # val d3 : int = 3
> # val d4 : int = 4
> # val d5 : int = 5
>  print_string (" w d5 = ") ;t = <fun>
>  print_int (w_from_data ( d5 ) ) ;>
>  print_newline () ;t -> int = <fun>
>    val t : int * int -> int = <fun>
>  print_string (" v d3 d4 d5 = ") ;ta : int -> int = <fun>
>  print_int (v_from_data ( d3, d4, d5 ) ) ;= <fun>
>  print_newline () ;_data : int * int * int -> int = <fun>
>          val t_from_data : int * int * int * int * int -> int = <fun>
>  print_string (" u  d1 d2 = ") ;      for data :  d1 = 1 d2 = 2 d3 = 3
> d4 = 4 d5 = 5
>  print_int (u_from_data ( d1, d2 ) ) ;
>  print_newline () ;3 d4 d5 = 22
>    unit = ()
> #
> Syntax error
> #
>
>
>
> By the way, why is the output mixed up ?
>
> Thanks
> François Colonna
>
>
> (**
>  * trying to implement cascade
>  *)
>
>
> let s_d1 = "1" ;;
> let s_d2 = "2" ;;
> let s_d3 = "3" ;;
> let s_d4 = "4" ;;
> let s_d5 = "5" ;;
>
>
> let d1 = int_of_string (s_d1) ;;
> let d2 = int_of_string (s_d2) ;;
> let d3 = int_of_string (s_d3) ;;
> let d4 = int_of_string (s_d4) ;;
> let d5 = int_of_string (s_d5) ;;
>
> (**
>  * define functions as function of their sons
>  *)
>
> let w (a_a) = a_a + 3 ;;
>
> let u (a_a, b_a) = a_a + b_a + 1;;
>
> let v (a_a, b_a) = a_a + b_a + 2 ;;
>
> let t (a_a, b_a) = a_a + b_a ;;
>
>
> (**
>  * express each function as a function of its data
>  * using the functon of its sons
>  *)
>
>
> let w_from_data ( a_a ) =
>    w ( a_a )
> ;;
>
> let u_from_data ( a_a, b_a ) =
>    u ( a_a, b_a )
> ;;
>
> let v_from_data ( a_a, b_a, c_a ) =
>    v ( u_from_data ( a_a, b_a),
>        w_from_data ( c_a) )
> ;;
>
> let t_from_data ( a_a, b_a, c_a, d_a, e_a ) =
>    t ( u_from_data (a_a, b_a),
>        v_from_data (c_a, d_a, e_a) )
> ;;
>
> (**
>  * execution
>  *)
>
>
> print_string (" for data : ") ;
> print_string (" d1 = ") ;
> print_int d1 ;
> print_string (" d2 = ") ;
> print_int d2 ;
> print_string (" d3 = ") ;
> print_int d3 ;
> print_string (" d4 = ") ;
> print_int d4 ;
> print_string (" d5 = ") ;
> print_int d5 ;
> print_newline () ;
> ;;
>
> print_string (" t d1 d2 d3 d4 d5 = ") ;
> print_int (t_from_data ( d1, d2, d3, d4, d5 ) ) ;
> print_newline () ;
> ;;
>
> print_string (" w d5 = ") ;
> print_int (w_from_data ( d5 ) ) ;
> print_newline () ;
>
> print_string (" v d3 d4 d5 = ") ;
> print_int (v_from_data ( d3, d4, d5 ) ) ;
> print_newline () ;
>
> print_string (" u  d1 d2 = ") ;
> print_int (u_from_data ( d1, d2 ) ) ;
> print_newline () ;
>
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>