diff options
| author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-12-13 22:13:34 +0000 |
|---|---|---|
| committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-12-13 22:13:34 +0000 |
| commit | 7e47735db8bbc4e54e1653d218cc1e6c90813ba4 (patch) | |
| tree | d9448cd04710c390f41b52b5559534ff7d53802f /boot | |
| parent | 16bc43219cbd49bb3450e362c6c3e0b3a129f374 (diff) | |
| download | ocaml-7e47735db8bbc4e54e1653d218cc1e6c90813ba4.tar.gz | |
Simplify the use of custom .() and .[]
This commit modifies the parser to use the newly defined .() and .[] operators. It also moves the definition of the standard .() and .[] operator for String/Bytes and Array to the pervasives module.
Before this commit, expressions of the form array.(index) and string.(index) where desugared to Array.get[_unsafe] array index and Strinf.get[_unsafe] string index. The unsafe or unsafe version were chosen depending on the presence of the "-unsafe" compiler option. Such expression are now desugared to ( .() ) array index and ( .[] ) string index respectively. The same desugar operation is applied to array.(index) <- value which becomes ( .()<- ) array index value.
In order to keep the standard semantic for the string and array index operations, these new index operators are defined in the pervasives module using new compiler primitives, e.g.
let .() = "%array_opt_get".
These new primitives are then mapped to safe or unsafe version depending on the
the "-unsafe" compiler option. Consequently, these modifications should have no impact on existing code.
With these modifications, defining custom .() and .[] operators should be easier, at the cost of losing access to the standard index operator for either array or string.
From: octachron <octa@polychoron.fr>
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15661 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'boot')
| -rwxr-xr-x | boot/ocamlc | bin | 1733548 -> 1733481 bytes |
| -rwxr-xr-x | boot/ocamldep | bin | 535576 -> 535509 bytes |
| -rwxr-xr-x | boot/ocamllex | bin | 255121 -> 255121 bytes |
3 files changed, 0 insertions, 0 deletions
diff --git a/boot/ocamlc b/boot/ocamlc Binary files differindex 3759b54d0d..7607ce4f78 100755 --- a/boot/ocamlc +++ b/boot/ocamlc diff --git a/boot/ocamldep b/boot/ocamldep Binary files differindex 02a12b6f6c..e62f25bcfb 100755 --- a/boot/ocamldep +++ b/boot/ocamldep diff --git a/boot/ocamllex b/boot/ocamllex Binary files differindex 860f011a9b..78b32802a4 100755 --- a/boot/ocamllex +++ b/boot/ocamllex |
