Renommage type format -> format4 et reintroduction type format a 3 arguments pour compatibilite arriere
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5658 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
62e030d764
commit
1a4be860d0
|
@ -19,7 +19,7 @@ val emit_string: string -> unit
|
|||
val emit_int: int -> unit
|
||||
val emit_nativeint: nativeint -> unit
|
||||
val emit_symbol: char -> string -> unit
|
||||
val emit_printf: ('a, out_channel, unit, unit) format -> 'a
|
||||
val emit_printf: ('a, out_channel, unit) format -> 'a
|
||||
val emit_char: char -> unit
|
||||
val emit_string_literal: string -> unit
|
||||
val emit_string_directive: string -> string -> unit
|
||||
|
|
BIN
boot/ocamlc
BIN
boot/ocamlc
Binary file not shown.
BIN
boot/ocamllex
BIN
boot/ocamllex
Binary file not shown.
|
@ -496,13 +496,14 @@ module LargeFile =
|
|||
end
|
||||
|
||||
(* Formats *)
|
||||
type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4
|
||||
external format_of_string :
|
||||
('a, 'b, 'c, 'd) format -> ('a, 'b, 'c, 'd) format = "%identity"
|
||||
external string_of_format : ('a, 'b, 'c, 'd) format -> string = "%identity"
|
||||
('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4 = "%identity"
|
||||
external string_of_format : ('a, 'b, 'c, 'd) format4 -> string = "%identity"
|
||||
|
||||
external string_to_format : string -> ('a, 'b, 'c, 'd) format = "%identity"
|
||||
let (( ^^ ) : ('a, 'b, 'c, 'd) format -> ('d, 'b, 'c, 'e) format ->
|
||||
('a, 'b, 'c, 'e) format) = fun fmt1 fmt2 ->
|
||||
external string_to_format : string -> ('a, 'b, 'c, 'd) format4 = "%identity"
|
||||
let (( ^^ ) : ('a, 'b, 'c, 'd) format4 -> ('d, 'b, 'c, 'e) format4 ->
|
||||
('a, 'b, 'c, 'e) format4) = fun fmt1 fmt2 ->
|
||||
string_to_format (string_of_format fmt1 ^ string_of_format fmt2);;
|
||||
|
||||
(* Miscellaneous *)
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
than the [fprintf] concise formats.
|
||||
|
||||
For instance, the sequence
|
||||
[open_box (); print_string "x ="; print_space (); print_int 1; close_box ()]
|
||||
[open_box 0; print_string "x ="; print_space (); print_int 1; close_box ()]
|
||||
that prints [x = 1] within a pretty-printing box, can be
|
||||
abbreviated as [printf "@[%s@ %i@]" "x =" 1], or even shorter
|
||||
[printf "@[x =@ %i@]" 1].
|
||||
|
@ -552,7 +552,7 @@ val pp_get_formatter_tag_functions :
|
|||
|
||||
(** {6 [printf] like functions for pretty-printing.} *)
|
||||
|
||||
val fprintf : formatter -> ('a, formatter, unit, unit) format -> 'a;;
|
||||
val fprintf : formatter -> ('a, formatter, unit) format -> 'a;;
|
||||
(** [fprintf ff format arg1 ... argN] formats the arguments
|
||||
[arg1] to [argN] according to the format string [format],
|
||||
and outputs the resulting string on the formatter [ff].
|
||||
|
@ -611,13 +611,13 @@ val fprintf : formatter -> ('a, formatter, unit, unit) format -> 'a;;
|
|||
It prints [x = 1] within a pretty-printing box.
|
||||
*)
|
||||
|
||||
val printf : ('a, formatter, unit, unit) format -> 'a;;
|
||||
val printf : ('a, formatter, unit) format -> 'a;;
|
||||
(** Same as [fprintf] above, but output on [std_formatter]. *)
|
||||
|
||||
val eprintf : ('a, formatter, unit, unit) format -> 'a;;
|
||||
val eprintf : ('a, formatter, unit) format -> 'a;;
|
||||
(** Same as [fprintf] above, but output on [err_formatter]. *)
|
||||
|
||||
val sprintf : ('a, unit, string, string) format -> 'a;;
|
||||
val sprintf : ('a, unit, string) format -> 'a;;
|
||||
(** Same as [printf] above, but instead of printing on a formatter,
|
||||
returns a string containing the result of formatting the arguments.
|
||||
Note that the pretty-printer queue is flushed at the end of each
|
||||
|
@ -630,7 +630,7 @@ val sprintf : ('a, unit, string, string) format -> 'a;;
|
|||
the predefined formatter [str_formatter] and call
|
||||
[flush_str_formatter ()] to get the result. *)
|
||||
|
||||
val bprintf : Buffer.t -> ('a, formatter, unit, unit) format -> 'a;;
|
||||
val bprintf : Buffer.t -> ('a, formatter, unit) format -> 'a;;
|
||||
(** Same as [sprintf] above, but instead of printing on a string,
|
||||
writes into the given extensible buffer.
|
||||
As for [sprintf], the pretty-printer queue is flushed at the end of each
|
||||
|
@ -643,6 +643,6 @@ val bprintf : Buffer.t -> ('a, formatter, unit, unit) format -> 'a;;
|
|||
pretty-printer queue would result in unexpected and badly formatted
|
||||
output. *)
|
||||
|
||||
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) format -> 'b;;
|
||||
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b;;
|
||||
(** Same as [sprintf] above, but instead of returning the string,
|
||||
passes it to the first argument. *)
|
||||
|
|
|
@ -401,13 +401,14 @@ external incr: int ref -> unit = "%incr"
|
|||
external decr: int ref -> unit = "%decr"
|
||||
|
||||
(* Formats *)
|
||||
type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4
|
||||
external format_of_string :
|
||||
('a, 'b, 'c, 'd) format -> ('a, 'b, 'c, 'd) format = "%identity"
|
||||
external string_of_format : ('a, 'b, 'c, 'd) format -> string = "%identity"
|
||||
('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4 = "%identity"
|
||||
external string_of_format : ('a, 'b, 'c, 'd) format4 -> string = "%identity"
|
||||
|
||||
external string_to_format : string -> ('a, 'b, 'c, 'd) format = "%identity"
|
||||
let (( ^^ ) : ('a, 'b, 'c, 'd) format -> ('d, 'b, 'c, 'e) format ->
|
||||
('a, 'b, 'c, 'e) format) = fun fmt1 fmt2 ->
|
||||
external string_to_format : string -> ('a, 'b, 'c, 'd) format4 = "%identity"
|
||||
let (( ^^ ) : ('a, 'b, 'c, 'd) format4 -> ('d, 'b, 'c, 'e) format4 ->
|
||||
('a, 'b, 'c, 'e) format4) = fun fmt1 fmt2 ->
|
||||
string_to_format (string_of_format fmt1 ^ string_of_format fmt2);;
|
||||
|
||||
(* Miscellaneous *)
|
||||
|
|
|
@ -784,21 +784,33 @@ external decr : int ref -> unit = "%decr"
|
|||
(** Decrement the integer contained in the given reference.
|
||||
Equivalent to [fun r -> r := pred !r]. *)
|
||||
|
||||
|
||||
(** {6 Operations on format strings} *)
|
||||
|
||||
(** See modules {!Printf} and {!Scanf} for more operations on
|
||||
format strings. *)
|
||||
|
||||
type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4
|
||||
(** Simplified type for format strings, included for backward compatibility
|
||||
with earlier releases of Objective Caml.
|
||||
['a] is the type of the parameters of the format,
|
||||
['c] is the result type for the "printf"-style function,
|
||||
and ['b] is the type of the first argument given to
|
||||
[%a] and [%t] printing functions. *)
|
||||
|
||||
external string_of_format :
|
||||
('a, 'b, 'c, 'd) format -> string = "%identity"
|
||||
('a, 'b, 'c, 'd) format4 -> string = "%identity"
|
||||
(** Converts a format string into a string.*)
|
||||
external format_of_string :
|
||||
('a, 'b, 'c, 'd) format -> ('a, 'b, 'c, 'd) format = "%identity"
|
||||
('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4 = "%identity"
|
||||
(** [format_of_string s] returns a format string read from the string
|
||||
constant [s]. *)
|
||||
literal [s]. *)
|
||||
|
||||
val ( ^^ ) :
|
||||
('a, 'b, 'c, 'd) format -> ('d, 'b, 'c, 'e) format ->
|
||||
('a, 'b, 'c, 'e) format;;
|
||||
(** [f1 ^^ f2] catenates formats [f1] and [f2], leading to a format
|
||||
that accepts arguments from [f1] then arguments from [f2] in turn. *)
|
||||
('a, 'b, 'c, 'd) format4 -> ('d, 'b, 'c, 'e) format4 ->
|
||||
('a, 'b, 'c, 'e) format4;;
|
||||
(** [f1 ^^ f2] catenates formats [f1] and [f2]. The result is a format
|
||||
that accepts arguments from [f1], then arguments from [f2]. *)
|
||||
|
||||
|
||||
(** {6 Program termination} *)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(** Formatted output functions. *)
|
||||
|
||||
val fprintf : out_channel -> ('a, out_channel, unit, unit) format -> 'a
|
||||
val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
|
||||
(** [fprintf outchan format arg1 ... argN] formats the arguments
|
||||
[arg1] to [argN] according to the format string [format],
|
||||
and outputs the resulting string on the channel [outchan].
|
||||
|
@ -94,23 +94,23 @@ val fprintf : out_channel -> ('a, out_channel, unit, unit) format -> 'a
|
|||
[x=1 y=2 x=1 y=3]. To get the expected behavior, do
|
||||
[List.iter (fun y -> printf "x=%d y=%d " 1 y) [2;3]]. *)
|
||||
|
||||
val printf : ('a, out_channel, unit, unit) format -> 'a
|
||||
val printf : ('a, out_channel, unit) format -> 'a
|
||||
(** Same as {!Printf.fprintf}, but output on [stdout]. *)
|
||||
|
||||
val eprintf : ('a, out_channel, unit, unit) format -> 'a
|
||||
val eprintf : ('a, out_channel, unit) format -> 'a
|
||||
(** Same as {!Printf.fprintf}, but output on [stderr]. *)
|
||||
|
||||
val sprintf : ('a, unit, string, string) format -> 'a
|
||||
val sprintf : ('a, unit, string) format -> 'a
|
||||
(** Same as {!Printf.fprintf}, but instead of printing on an output channel,
|
||||
return a string containing the result of formatting
|
||||
the arguments. *)
|
||||
|
||||
val bprintf : Buffer.t -> ('a, Buffer.t, unit, unit) format -> 'a
|
||||
val bprintf : Buffer.t -> ('a, Buffer.t, unit) format -> 'a
|
||||
(** Same as {!Printf.fprintf}, but instead of printing on an output channel,
|
||||
append the formatted arguments to the given extensible buffer
|
||||
(see module {!Buffer}). *)
|
||||
|
||||
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) format -> 'b
|
||||
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b
|
||||
(** [kprintf k format arguments] is the same as [sprintf format arguments],
|
||||
except that the resulting string is passed as argument to [k]; the
|
||||
result of [k] is then returned as the result of [kprintf]. *)
|
||||
|
|
|
@ -72,7 +72,7 @@ exception Scan_failure of string;;
|
|||
cannot be read according to the given format. *)
|
||||
|
||||
val bscanf :
|
||||
Scanning.scanbuf -> ('a, Scanning.scanbuf, 'b, 'b) format -> 'a -> 'b;;
|
||||
Scanning.scanbuf -> ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b;;
|
||||
(** [bscanf ib format f] reads tokens from the scanning buffer [ib] according
|
||||
to the format string [format], converts these tokens to values, and
|
||||
applies the function [f] to these values.
|
||||
|
@ -171,22 +171,22 @@ val bscanf :
|
|||
(module [Str]), stream parsers, [ocamllex]-generated lexers,
|
||||
[ocamlyacc]-generated parsers. *)
|
||||
|
||||
val fscanf : in_channel -> ('a, Scanning.scanbuf, 'b, 'b) format -> 'a -> 'b;;
|
||||
val fscanf : in_channel -> ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b;;
|
||||
(** Same as {!Scanf.bscanf}, but inputs from the given channel.
|
||||
If efficiency is a concern, when scanning a file [fname],
|
||||
consider using [bscanf] in conjonction with fast bufferized reading,
|
||||
as obtained by [bscanf (Scanning.from_file fname)]. *)
|
||||
|
||||
val sscanf : string -> ('a, Scanning.scanbuf, 'b, 'b) format -> 'a -> 'b;;
|
||||
val sscanf : string -> ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b;;
|
||||
(** Same as {!Scanf.bscanf}, but inputs from the given string. *)
|
||||
|
||||
val scanf : ('a, Scanning.scanbuf, 'b, 'b) format -> 'a -> 'b;;
|
||||
val scanf : ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b;;
|
||||
(** Same as {!Scanf.bscanf}, but inputs from [stdin]
|
||||
(the standard input channel). *)
|
||||
|
||||
val kscanf :
|
||||
Scanning.scanbuf -> (Scanning.scanbuf -> exn -> 'a) ->
|
||||
('b, Scanning.scanbuf, 'a, 'a) format -> 'b -> 'a;;
|
||||
('b, Scanning.scanbuf, 'a) format -> 'b -> 'a;;
|
||||
(** Same as {!Scanf.bscanf}, but takes an additional function argument
|
||||
[ef] that is called in case of error: if the scanning process or
|
||||
some conversion fails, the scanning function aborts and applies the
|
||||
|
|
|
@ -28,7 +28,7 @@ and ident_unit = Ident.create "unit"
|
|||
and ident_exn = Ident.create "exn"
|
||||
and ident_array = Ident.create "array"
|
||||
and ident_list = Ident.create "list"
|
||||
and ident_format = Ident.create "format"
|
||||
and ident_format4 = Ident.create "format4"
|
||||
and ident_option = Ident.create "option"
|
||||
and ident_nativeint = Ident.create "nativeint"
|
||||
and ident_int32 = Ident.create "int32"
|
||||
|
@ -44,7 +44,7 @@ and path_unit = Pident ident_unit
|
|||
and path_exn = Pident ident_exn
|
||||
and path_array = Pident ident_array
|
||||
and path_list = Pident ident_list
|
||||
and path_format = Pident ident_format
|
||||
and path_format4 = Pident ident_format4
|
||||
and path_option = Pident ident_option
|
||||
and path_nativeint = Pident ident_nativeint
|
||||
and path_int32 = Pident ident_int32
|
||||
|
@ -123,7 +123,7 @@ let build_initial_env add_type add_exception empty_env =
|
|||
Type_variant(["[]", []; "::", [tvar; type_list tvar]], Public);
|
||||
type_manifest = None;
|
||||
type_variance = [true, false, false]}
|
||||
and decl_format =
|
||||
and decl_format4 =
|
||||
{type_params = [newgenvar(); newgenvar(); newgenvar(); newgenvar()];
|
||||
type_arity = 4;
|
||||
type_kind = Type_abstract;
|
||||
|
@ -166,7 +166,7 @@ let build_initial_env add_type add_exception empty_env =
|
|||
add_type ident_nativeint decl_abstr (
|
||||
add_type ident_lazy_t decl_lazy_t (
|
||||
add_type ident_option decl_option (
|
||||
add_type ident_format decl_format (
|
||||
add_type ident_format4 decl_format4 (
|
||||
add_type ident_list decl_list (
|
||||
add_type ident_array decl_array (
|
||||
add_type ident_exn decl_exn (
|
||||
|
|
|
@ -40,7 +40,7 @@ val path_unit: Path.t
|
|||
val path_exn: Path.t
|
||||
val path_array: Path.t
|
||||
val path_list: Path.t
|
||||
val path_format: Path.t
|
||||
val path_format4: Path.t
|
||||
val path_option: Path.t
|
||||
val path_nativeint: Path.t
|
||||
val path_int32: Path.t
|
||||
|
|
|
@ -700,7 +700,7 @@ let type_format loc fmt =
|
|||
|
||||
let ty_ares, ty_res = scan_format 0 in
|
||||
newty
|
||||
(Tconstr(Predef.path_format,
|
||||
(Tconstr(Predef.path_format4,
|
||||
[ty_res; ty_input; ty_ares; ty_result],
|
||||
ref Mnil))
|
||||
|
||||
|
@ -1604,7 +1604,7 @@ and type_expect ?in_function env sexp ty_expected =
|
|||
exp_type =
|
||||
(* Terrible hack for format strings *)
|
||||
begin match (repr (expand_head env ty_expected)).desc with
|
||||
Tconstr(path, _, _) when Path.same path Predef.path_format ->
|
||||
Tconstr(path, _, _) when Path.same path Predef.path_format4 ->
|
||||
type_format sexp.pexp_loc s
|
||||
| _ -> instance Predef.type_string
|
||||
end;
|
||||
|
|
Loading…
Reference in New Issue