Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Only one line is different (the second one), and one can deal with several kind of parameters, while the other can't :
- ----------------------- Works :
- let string_d =
- let t = 3.1 in
- (fun brick_name brick_verb verb x ->
- Printf.ksprintf (fun s ->
- if verb <= brick_verb
- then Printf.printf "[%s]%s" brick_name s else ()) x)
- ;;
- ----------------------- Doesn't works :
- let string_d =
- let t = Sys.time () in
- (fun brick_name brick_verb verb x ->
- Printf.ksprintf (fun s ->
- if verb <= brick_verb
- then Printf.printf "[%s]%s" brick_name s else ()) x)
- ;;
- ----------------------- PROF :
- let string_d =
- let t = 3.1 in
- (fun brick_name brick_verb verb x ->
- Printf.ksprintf (fun s ->
- if verb <= brick_verb
- then Printf.printf "[%s]%s" brick_name s else ()) x)
- ;;
- Characters 23-24:
- let t = 3.1 in
- ^
- Warning 26: unused variable t.
- val string_d : string -> 'a -> 'a -> ('b, unit, string, unit) format4 -> 'b =
- <fun>
- # string_d "brickname" 5 1 "bonjour %s" "hi";;
- [brickname]bonjour hi- : unit = ()
- # string_d "brickname" 5 1 "bonjour %d" 4;;
- [brickname]bonjour 4- : unit = ()
- # let string_d =
- let t = Sys.time () in
- (fun brick_name brick_verb verb x ->
- Printf.ksprintf (fun s ->
- if verb <= brick_verb
- then Printf.printf "[%s]%s" brick_name s else ()) x)
- ;;
- Characters 23-24:
- let t = Sys.time () in
- ^
- Warning 26: unused variable t.
- val string_d :
- string -> '_a -> '_a -> ('_b, unit, string, unit) format4 -> '_b = <fun>
- # string_d "brickname" 5 1 "bonjour %s" "hi";;
- [brickname]bonjour hi- : unit = ()
- # string_d "brickname" 5 1 "bonjour %d" 4;;
- Characters 25-37:
- string_d "brickname" 5 1 "bonjour %d" 4;;
- ^^^^^^^^^^^^
- Error: This expression has type
- (string -> unit, string -> unit) CamlinternalFormatBasics.precision
- but an expression was expected of type
- (string -> unit, int -> 'a) CamlinternalFormatBasics.precision
- Type string is not compatible with type int
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement