github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/expr/addition_op_doc.yaml (about)

     1  - DocumentID: addition
     2    Title: >-
     3      `+` Addition Operator
     4    CategoryID: parser
     5    Summary: >-
     6      Adds two numeric values together (expression)
     7    Description: |-
     8      The Addition Operator adds two numeric values together in an expression. Those
     9      values are placed either side of the addition operator.
    10    Examples: |-
    11      #### Expression
    12  
    13      ```
    14      » 3+2
    15      5
    16      ```
    17  
    18      #### Statement
    19  
    20      ```
    21      out (3+2)
    22      » 5
    23      ```
    24    Detail: |-
    25      Unlike in some other programming languages, the `+` operator cannot be used to
    26      concatenate strings. This is because shells are historically untyped so you
    27      cannot always guarantee that numeric-looking value isn't a string. To solve
    28      this problem, by default Murex assumes anything that looks like a number is a
    29      number when performing addition. Thus overloading the `+` operator to
    30      concatenate strings would lead to a large class of bugs.
    31  
    32      ```
    33      » str = "3"
    34      » int = 2
    35      » $str + $int
    36      5
    37      ```
    38  
    39      For occasions when type safety is more important than the convenience of silent
    40      data casting, you can disable the above behaviour via `config`:
    41  
    42      ```
    43      » config set proc strict-types false
    44      » $str + $int
    45      Error in `expr` (0,1): cannot Add with string types
    46                          > Expression: $str + $int
    47                          >           : ^
    48                          > Character : 1
    49                          > Symbol    : Scalar
    50                          > Value     : '$str'
    51      ```
    52    Related:
    53    - expr
    54    - add-with
    55    - subtraction
    56    - multiplication
    57    - division
    58    - int
    59    - float
    60    - num
    61    - config
    62    - cast