## `.` -- concatenate objects

#### Introduction

`object1.object2` concatenates two objects.

`_concat(object1, object2, ...)` concatenates an arbitrary number of objects.

#### Call(s)

object1 . object2
`_concat(object1, object2...)`

#### Parameters

`object1` | - | a character string, an identifier, or a list
`object2` | - | a character string, an identifier, an integer, or a list

#### Returns

an object of the same type as `object1`.

### Overloadable:

`object1`, `object2`, `...`

#### Related Functions

`@`, `append`

#### Details

- `_concat(object1, object2)` is equivalent to `object1.object2`. The function call `_concat(object1, object2, object3, ...)` is equivalent to
  `((object1.object2).object3). ...` .
  `_concat()` returns the void object of type `DOM_NULL`.
- The following combinations are possible:

  `object1` | `object2` | `object1.object2`
  string | string | string
  string | identifier | string
  string | integer | string
  identifier | string | identifier
  identifier | identifier | identifier
  identifier | integer | identifier
  list | list | list

  E.g., `x.1` creates the identifier `x1`.
- Note that the objects to be concatenated are evaluated before concatenation. Thus, if `x := y`, `i := 1`, the concatenation `x.i` produces the identifier `y1`. However, the resulting identifier `y1` is not fully evaluated. Cf. example 2.
- `_concat` is a function of the system kernel.

#### Example 1

We demonstrate all possible combinations of types that can be concatenated. Strings are produced if the first object is a string:

    >> "x"."1", "x".y, "x".1

                                 "x1", "xy", "x1"

Identifiers are produced if the first object is an identifier:

    >> x."1", x.y , x.1

                                    x1, xy, x1

The concatenation operator `.` also serves for concatenating lists:

    >> [1, 2] . [3, 4]

                                   [1, 2, 3, 4]

    >> L := []: for i from 1 to 10 do L := L . [x.i] end_for: L

                     [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]

    >> delete L:

#### Example 2

We demonstrate the evaluation strategy of concatenation. Before concatenation, the objects are evaluated:

    >> x := "Val": i := ue: x.i

                                      "Value"

    >> ue := 1:  x.i

                                      "Val1"

An identifier produced via concatenation is not fully evaluated:

    >> delete x: x1 := 17: x.1, eval(x.1)

                                      x1, 17

The `.` operator can be used to create variables dynamically. They can be assigned values immediately:

    >> delete x: for i from 1 to 5 do x.i := i^2 end_for:

Again, the result of the concatenation is not fully evaluated:

    >> x.i $ i= 1..5

                                x1, x2, x3, x4, x5

    >> eval(%)

                                  1, 4, 9, 16, 25

    >> delete i, ue: (delete x.i) $ i = 1..5:

#### Example 3

The function `_concat` can be used to concatenate an arbitrary number of objects:

    >> _concat("an", " ", "ex", "am", "ple")

                                   "an example"

    >> _concat("0", " ".i $ i = 1..15)

                      "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"

    >> _concat([], [x.i] $ i = 1..10)

                     [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000