Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] no error with ocamlc, a syntax error with ocaml

1 view
Skip to first unread message

Francois Colonna

unread,
Sep 29, 2006, 3:58:19 AM9/29/06
to caml...@yquem.inria.fr
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

tuvuw_from_data_error.ml

micha

unread,
Sep 29, 2006, 4:27:41 AM9/29/06
to caml...@yquem.inria.fr
Am Fri, 29 Sep 2006 09:54:09 +0200
schrieb Francois Colonna <col...@ccr.jussieu.fr>:

> Hello,
>
> the small ocaml program attached gives no errors at compilation
>
> ocamlc -c tuvuw_from_data_error.ml
>
> and this syntax error at execution:

the compiled program runs without errors. Also if you do:
#use "tuvuw_from_data_error.ml";;

it runs without errors. So I think the error comes from the redirecting
of the input by the shell...

Michael

_______________________________________________
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

Jonathan Roewen

unread,
Sep 29, 2006, 4:29:05 AM9/29/06
to col...@ccr.jussieu.fr
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

> (**
> * 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 () ;
>
>
>

Virgile Prevosto

unread,
Sep 29, 2006, 4:42:29 AM9/29/06
to caml...@yquem.inria.fr
Hello,

Le ven 29 sep 2006 09:54:09 CEST,
Francois Colonna <col...@ccr.jussieu.fr> a écrit :

> ocaml < tuvuw_from_data_error.ml

> print_string (" u d1 d2 = ") ;

> print_int (u_from_data ( d1, d2 ) ) ;
> print_newline () ;
>

The issue is here: in the interpreter, it is mandatory to close a
toplevel phrase with ';;', since ocaml rely on it to know when it has
to evaluate something.

--
E tutto per oggi, a la prossima volta.
Virgile

Francois Colonna

unread,
Sep 29, 2006, 5:12:45 AM9/29/06
to caml...@yquem.inria.fr
Virgile Prevosto wrote:
> Hello,
>
> Le ven 29 sep 2006 09:54:09 CEST,
> Francois Colonna <col...@ccr.jussieu.fr> a écrit :
>
>
>> ocaml < tuvuw_from_data_error.ml
>>
>
>
>> print_string (" u d1 d2 = ") ;
>> print_int (u_from_data ( d1, d2 ) ) ;
>> print_newline () ;
>>
>>
>
> The issue is here: in the interpreter, it is mandatory to close a
> toplevel phrase with ';;', since ocaml rely on it to know when it has
> to evaluate something.
>
>

_______________________________________________

0 new messages