Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# dmd.arrayop

Implement array operations, such as a[] = b[] + c[].

Specification Array Operations

Authors:
Walter Bright
License:
Boost License 1.0

Source arrayop.d

Documentation https://dlang.org/phobos/dmd_arrayop.html

Coverage https://codecov.io/gh/dlang/dmd/src/master/src/dmd/arrayop.d

bool `isArrayOpValid`(Expression `e`);
  Check that there are no uses of arrays without [].
Expression `arrayOp`(BinExp `e`, Scope* `sc`);
Expression `arrayOp`(BinAssignExp `e`, Scope* `sc`);
  Construct the array operation expression, call object.arrayOp!(tiargs)(args).
  Encode operand types and operations into tiargs using reverse polish notation (RPN) to preserve precedence. Unary operations are prefixed with "u" (e.g. "u~"). Pass operand values (slices or scalars) as args.
  Scalar expression sub-trees of `e` are evaluated before calling into druntime to hoist them out of the loop. This is a valid evaluation order as the actual array operations have no side-effect.

  References https://github.com/dlang/druntime/blob/master/src/object.d#L3944 https://github.com/dlang/druntime/blob/master/src/core/internal/array/operations.d

bool `isArrayOpImplicitCast`(TypeDArray `tfrom`, TypeDArray `tto`);
  Some implicit casting can be performed by the arrayOp template.
  Parameters:

  TypeDArray `tfrom` | type converting from
  TypeDArray `tto` | type converting to

  Returns:
  true if can be performed by arrayOp
bool `isUnaArrayOp`(TOK `op`);
  Test if expression is a unary array op.
bool `isBinArrayOp`(TOK `op`);
  Test if expression is a binary array op.
bool `isBinAssignArrayOp`(TOK `op`);
  Test if expression is a binary assignment array op.
bool `isArrayOpOperand`(Expression `e`);
  Test if operand is a valid array op operand.
ErrorExp `arrayOpInvalidError`(Expression `e`);
  Print error message about invalid array operation.
  Parameters:

  Expression `e` | expression with the invalid array operation

  Returns:
  instance of ErrorExp

Copyright © 1999-2020 by the D Language Foundation | Page generated by Ddoc on Mon May 11 10:57:55 2020