summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>2013-06-03 18:22:31 +0000
committerFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>2013-06-03 18:22:31 +0000
commitace0205b6499ffdae4588cfdd640c45855217a8f (patch)
tree1947b15ae8a53781a6ec15dc386f5374aaeb0fbc
parent9b53f8b10d813b1791245d9d2ab08ef14d7a5512 (diff)
Add |> and @@ operators to Pervasives
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13739 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes1
-rwxr-xr-xboot/ocamlcbin1382859 -> 1388354 bytes
-rwxr-xr-xboot/ocamldepbin338782 -> 342777 bytes
-rwxr-xr-xboot/ocamllexbin176100 -> 176092 bytes
-rw-r--r--otherlibs/threads/pervasives.ml5
-rw-r--r--stdlib/pervasives.ml5
-rw-r--r--stdlib/pervasives.mli14
7 files changed, 25 insertions, 0 deletions
diff --git a/Changes b/Changes
index 25b314902..c6c3c29bb 100644
--- a/Changes
+++ b/Changes
@@ -38,6 +38,7 @@ Compilers:
Standard library:
- PR#5986: new flag Marshal.Compat_32 for the serialization functions
(Marshal.to_*), forcing the output to be readable on 32-bit hosts.
+- Add optimized composition operators |> and @@ in Pervasives
Runtime system:
* PR#6019: more efficient implementation of caml_modify() and caml_initialize().
diff --git a/boot/ocamlc b/boot/ocamlc
index 64b737a31..dd9d27407 100755
--- a/boot/ocamlc
+++ b/boot/ocamlc
Binary files differ
diff --git a/boot/ocamldep b/boot/ocamldep
index 078d9b49a..c5afc26b8 100755
--- a/boot/ocamldep
+++ b/boot/ocamldep
Binary files differ
diff --git a/boot/ocamllex b/boot/ocamllex
index d2a8a2726..746885c25 100755
--- a/boot/ocamllex
+++ b/boot/ocamllex
Binary files differ
diff --git a/otherlibs/threads/pervasives.ml b/otherlibs/threads/pervasives.ml
index 7ca7975d3..960eb25eb 100644
--- a/otherlibs/threads/pervasives.ml
+++ b/otherlibs/threads/pervasives.ml
@@ -26,6 +26,11 @@ let invalid_arg s = raise(Invalid_argument s)
exception Exit
+(* Composition operators *)
+
+external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply"
+external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"
+
(* Comparisons *)
external (=) : 'a -> 'a -> bool = "%equal"
diff --git a/stdlib/pervasives.ml b/stdlib/pervasives.ml
index dc767fe48..1640c203d 100644
--- a/stdlib/pervasives.ml
+++ b/stdlib/pervasives.ml
@@ -22,6 +22,11 @@ let invalid_arg s = raise(Invalid_argument s)
exception Exit
+(* Composition operators *)
+
+external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply"
+external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"
+
(* Comparisons *)
external ( = ) : 'a -> 'a -> bool = "%equal"
diff --git a/stdlib/pervasives.mli b/stdlib/pervasives.mli
index 2f93269af..449093ac4 100644
--- a/stdlib/pervasives.mli
+++ b/stdlib/pervasives.mli
@@ -136,6 +136,20 @@ external ( or ) : bool -> bool -> bool = "%sequor"
(** @deprecated {!Pervasives.( || )} should be used instead.*)
+(** {6 Composition operators} *)
+
+external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply"
+(** Reverse-application operator: [x |> f |> g] is exactly equivalent
+ to [g (f (x))].
+ @since 4.01
+*)
+
+external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"
+(** Application operator: [g @@ f @@ x] is exactly equivalent to
+ [g (f (x))].
+ @since 4.01
+*)
+
(** {6 Integer arithmetic} *)
(** Integers are 31 bits wide (or 63 bits on 64-bit processors).