* no error with ocamlc, a syntax error with ocaml
@ 2006-09-29 7:54 Francois Colonna
2006-09-29 8:25 ` [Caml-list] " micha
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Francois Colonna @ 2006-09-29 7:54 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
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
[-- Attachment #2: tuvuw_from_data_error.ml --]
[-- Type: text/plain, Size: 1580 bytes --]
(**
* 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 () ;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] no error with ocamlc, a syntax error with ocaml
2006-09-29 7:54 no error with ocamlc, a syntax error with ocaml Francois Colonna
@ 2006-09-29 8:25 ` micha
2006-09-29 8:27 ` Jonathan Roewen
2006-09-29 8:40 ` Virgile Prevosto
2 siblings, 0 replies; 5+ messages in thread
From: micha @ 2006-09-29 8:25 UTC (permalink / raw)
To: caml-list; +Cc: colonna
Am Fri, 29 Sep 2006 09:54:09 +0200
schrieb Francois Colonna <colonna@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] no error with ocamlc, a syntax error with ocaml
2006-09-29 7:54 no error with ocamlc, a syntax error with ocaml Francois Colonna
2006-09-29 8:25 ` [Caml-list] " micha
@ 2006-09-29 8:27 ` Jonathan Roewen
2006-09-29 8:40 ` Virgile Prevosto
2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Roewen @ 2006-09-29 8:27 UTC (permalink / raw)
To: colonna; +Cc: caml-list
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
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] no error with ocamlc, a syntax error with ocaml
2006-09-29 7:54 no error with ocamlc, a syntax error with ocaml Francois Colonna
2006-09-29 8:25 ` [Caml-list] " micha
2006-09-29 8:27 ` Jonathan Roewen
@ 2006-09-29 8:40 ` Virgile Prevosto
2006-09-29 9:11 ` Francois Colonna
2 siblings, 1 reply; 5+ messages in thread
From: Virgile Prevosto @ 2006-09-29 8:40 UTC (permalink / raw)
To: caml-list
Hello,
Le ven 29 sep 2006 09:54:09 CEST,
Francois Colonna <colonna@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] no error with ocamlc, a syntax error with ocaml
2006-09-29 8:40 ` Virgile Prevosto
@ 2006-09-29 9:11 ` Francois Colonna
0 siblings, 0 replies; 5+ messages in thread
From: Francois Colonna @ 2006-09-29 9:11 UTC (permalink / raw)
To: caml-list
Virgile Prevosto wrote:
> Hello,
>
> Le ven 29 sep 2006 09:54:09 CEST,
> Francois Colonna <colonna@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.
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-09-29 9:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-29 7:54 no error with ocamlc, a syntax error with ocaml Francois Colonna
2006-09-29 8:25 ` [Caml-list] " micha
2006-09-29 8:27 ` Jonathan Roewen
2006-09-29 8:40 ` Virgile Prevosto
2006-09-29 9:11 ` Francois Colonna
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox