# 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

- `isArrayOpValid`

  #### Declaration

  `bool `isArrayOpValid`(Expression `e`);`

  Check that there are no uses of arrays without [].

- `arrayOp`

  #### Declaration

  `Expression `arrayOp`(BinExp `e`, Scope* `sc`);
  Expression `arrayOp`(BinAssignExp `e`, Scope* `sc`);`

  Construct the array operation expression, call object.arrayOp!(tiargs)(args).

  #### Discussion

  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/dmd/blob/cdfadf8a18f474e6a1b8352af2541efe3e3467cc/druntime/src/object.d#L4694 https://github.com/dlang/dmd/blob/master/druntime/src/core/internal/array/operations.d

- `isArrayOpImplicitCast`

  #### Declaration

  `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

  #### Return Value

  `true` if can be performed by arrayOp

- `isUnaArrayOp`

  #### Declaration

  `@safe bool `isUnaArrayOp`(EXP `op`);`

  Test if expression is a unary array `op`.

- `isBinArrayOp`

  #### Declaration

  `@safe bool `isBinArrayOp`(EXP `op`);`

  Test if expression is a binary array `op`.

- `isBinAssignArrayOp`

  #### Declaration

  `@safe bool `isBinAssignArrayOp`(EXP `op`);`

  Test if expression is a binary assignment array `op`.

- `isArrayOpOperand`

  #### Declaration

  `bool `isArrayOpOperand`(Expression `e`);`

  Test if operand is a valid array op operand.

- `arrayOpInvalidError`

  #### Declaration

  `ErrorExp `arrayOpInvalidError`(Expression `e`);`

  Print error message about invalid array operation.

  #### Parameters

  `Expression `e`` | expression with the invalid array operation

  #### Return Value

  instance of ErrorExp