-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User-defined indexing operator without array indexing #622
Commits on Jun 19, 2016
-
Add a special syntax for index operators
This commit introduces a new syntax for index operators. Five core parenthesis operator are added: .[], .{}, .{,}, .{,,}, .{,..,}. The .{,}/.{,,}/.{,,,} operators are defined for compatibility with the Bigarray syntax extension. Each core index operator is available in a access and assignement versions. For instance, .[] is declined in * .[] : index operator * .[]<- : indexed assignment operator The general syntax for these index operators as implemented in the parser is index_operator::= index_operator_core [<-].
Configuration menu - View commit details
-
Copy full SHA for e1a6add - Browse repository at this point
Copy the full SHA e1a6addView commit details -
User-defined indexing operator (.[])
This commit modifies the parser to use the newly defined (.[]) and (.[]<-) operators. It also moves the definition of the .[] operators for String/Bytes to the pervasives module. Before this commit, expressions of the form `string.[index]` where desugared to String.get[_unsafe] string index. The safe or unsafe version were chosen depending on the presence of the "-unsafe" compiler option. Such expression are now desugared to `( .[] ) string index`. The same desugar operation is applied to `string.[index] <- value` which is translated to `( .[]<- ) array index value`. In order to keep the standard semantic for string index operations, these new index operators are defined in the pervasives module using new compiler primitives, e.g. ` let .[] = "%string_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 `.[]` operators should be easier, at the cost of losing access to the standard index operator for string.
Configuration menu - View commit details
-
Copy full SHA for a46f696 - Browse repository at this point
Copy the full SHA a46f696View commit details -
User-defined indexing operator (.{})
This commits modify the Bigarray syntax extension in order to facilitate the use of custom (.{}) operators. The compatibility with the existing Bigarray syntax has been preserved as much as possible. However, this commit will break code which use the Bigarray (.{}) syntax without opening the Bigarray module first! Like the previous commit, this commit modifies the parser to desugar bigarray1.{index} to ( .{} ) bigarray1 index. Following the bigarray syntax, the index operator used in the desugaring changes if the index is a n-tuple: 1-tuple ⟹ `.{}` 2-tuple ⟹ `.{,}` 3-tuple ⟹ `.{,,}` 4 and more tuples ⟹ `.{,..,}` The bigarray modules has been modified to use this new index operators. Note that this means that these index operators are not anymore accessible without opening the bigarray module.
Configuration menu - View commit details
-
Copy full SHA for 6c17c78 - Browse repository at this point
Copy the full SHA 6c17c78View commit details -
PR#6885: documentation for index operators
This commit documents the new syntax for index operators ( .[], .{}) and updates the documentation of the bigarray specific syntax: * A new section "Customizable index operators" (7.28) describes the index operator syntax. Within this section, two subsections details respectively the particularities of the multidimensional index operator (.{}) and some potential source compatibility problem with the previous bigarray specific syntax. * The "Syntax for bigarray access" section (7.21) has been partially removed and only mention that this extension has been superseded by the new extension and deprecated, with forward references to the new section 7.28 and compatibility subsection TODO: * The documentation would have to be updated again when/if the mantis issue ocaml#6765 is integrated in trunk : for now, the documentation only mention that using the ( .{} ) syntax without opening the Bigarray module is "deprecated".
Configuration menu - View commit details
-
Copy full SHA for dd15146 - Browse repository at this point
Copy the full SHA dd15146View commit details -
Configuration menu - View commit details
-
Copy full SHA for 99651a2 - Browse repository at this point
Copy the full SHA 99651a2View commit details -
Indexing submodule for bigarray
The objective of this commit is to introduce a short notation for bringing in scope the bigarray index operators and only them. For that purpose, the bigarray index operators are regrouped in a single submodule. This submodule is also included inside the global bigarray module to preserve compatibility and ease of use of the bigarray module.
Configuration menu - View commit details
-
Copy full SHA for 42e07e8 - Browse repository at this point
Copy the full SHA 42e07e8View commit details -
Bigarray index operators deprecated warning
With the simplification of index operators, the expressions a.{..} are no longer automatically resolved to Bigarray.Array[n].[g|s]et. To use these operators, it is now necessary to bring them in scope, for instance by opening either the Bigarray or Bigarray.Operators module. To ease the transition period, this patch add an hack in `typing/typetexp.ml` to catch the cases where the index operators `.{}/.{,}..` are used without being bound in the current scope and tranlate then to Bigarray.(..) with a deprecated warning.
Configuration menu - View commit details
-
Copy full SHA for ddc86c5 - Browse repository at this point
Copy the full SHA ddc86c5View commit details -
Manual: Document bigarray compatibility warning
This commit update the documentation on the compatibility problems between the deprecated bigarray specific syntax extension and the new user-defined index operators extension. In particular, this commit describes the new deprecated warning for implicit use of the `Bigarray(.{...})` operators and states that this warning might be turned into an error in the undetermined futures. This commits also amend the documentation to mention the new `Bigarray.Operators` submodule when useful.
Configuration menu - View commit details
-
Copy full SHA for a1eb9c1 - Browse repository at this point
Copy the full SHA a1eb9c1View commit details -
Manual: Fix user-defined index operators
Change the name from customizable to user-defined index operators and fix the alignment of the latex tables for better readability.
Configuration menu - View commit details
-
Copy full SHA for 18e299a - Browse repository at this point
Copy the full SHA 18e299aView commit details -
Extended syntax for indexing operator
Enable module path prefix for indexing operator: * `a.M.[i]` ≡ `M.(.[]) a i` * `a.M.[i]<-v` ≡ `M.(.[]<-) a i v` * `a.M.{i}` ≡ `M.(.{}) a i` * `a.M.{i}<-v` ≡ `M.(.{}<-) a i v`
Configuration menu - View commit details
-
Copy full SHA for 298071a - Browse repository at this point
Copy the full SHA 298071aView commit details -
Configuration menu - View commit details
-
Copy full SHA for f14a4ef - Browse repository at this point
Copy the full SHA f14a4efView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c9ee63 - Browse repository at this point
Copy the full SHA 9c9ee63View commit details