TOC < Back Next > Updated: 6-Feb-2009 Edit History

# REBOL 3 Datatypes: Paren!

## Concept

A paren! datatype is a block that is immediately evaluated. It is identical to a block in every way, except that it is evaluated when it is encountered and its result is returned.

When used within an evaluated expression, a paren! allows you to control the order of evaluation:

```print 1 + (2 * 3)
7```
```print 1 + 2 * 3
9```

The value of a paren! can be accessed and modified in the same way as any block. However, when referring to a paren!, care must be taken to prevent if from being evaluated. If you store a paren in a variable, you will need to use a get-word form (:word) to prevent it from being evaluated.

Parens are a type of series, thus anything that can be done with a series can be done with paren values.

```paren: first [(1 + 2 * 3 / 4)]

print type? :paren
paren!```
```print length :paren
7```
```print first :paren
1```
```print last :paren
4```
```insert :paren [10 + 5 *]
probe :paren
(10 + 5 * 1 + 2 * 3 / 4)```
```print paren
12.75```

## Format

Parens are identified by their open and closing parenthesis. They can span multiple lines and contain any data, including other paren values.

## Creation

The make function can be used to allocate a paren value:

```paren: make paren! 10
insert :paren 10
insert :paren `+
insert :paren 20

print :paren
20 + 10```
```print paren
30```

The to-paren function converts data to the paren! datatype:

```probe to-paren "123 456"
(123 456)```
```probe to-paren [123 456]
(123 456)```

## Related

Use paren? to test the datatype.

```blk: [(3 + 3)]
probe pick blk 1
(3 + 3)```
```probe paren? pick blk 1
true```

As parens are a subset of the [bad-link:datatypes/series.txt] pseudotype, use series? to check this:

```probe series? pick blk 1
true```

Using form on a paren value creates a string from the contents contained in the paren:

```probe form pick blk 1
3 + 3```

 TOC < Back Next > Feedback Admin