Values and types

Every value has a datatype, and these functions make values, convert them from one datatype to another, and ask what a value is. type? names a value’s datatype; each datatype also has a test that ends in ?, and most have a conversion that starts with to-, a shorter way of writing to. See values.

make

Makes a new value of a type, or from a prototype object.

make type spec
  • type (any-value!)

  • spec (any-value!)

make object! [...] copies its block deep before it binds and runs it, so two objects made from the same block never share a series. An object written inside another one is copied again by each make around it, so text that nests objects thousands of levels deep takes time and memory that grow with the square of its depth: a chain of 1000 loads and runs at once, one of 10000 can run out of memory. Rebol 3 binds the block in place instead, and its mold and do fail on such a chain sooner.

to

Converts a value to another type.

to type value
  • type (datatype! any-value!)

  • value (any-type!)

A block gives a pair, a tuple or a time from its parts, as in R3: to pair! [3 4] is 3x4, to time! [9 30] is 9:30, and to time! [9 30 15.5] is 9:30:15.5; minutes and seconds over 59 carry over, and make time! takes the same block.

as-pair

Makes a pair of two numbers: as-pair 3 4 is 3x4.

as-pair x y
  • x (number!)

  • y (number!)

construct

Makes an object from a block without evaluating its values.

construct block
  • block (block!)

type?

The datatype of a value.

type? value
  • value (any-type!)

  • /word: Its name as a word, integer! for 3

For example type? 3 gives the datatype integer!; type?/word 3 gives the word integer!, to keep in a block or to compare with one.

value?

True if the word has a value.

value? word
  • word (any-word!)

quote

The value as it is, not evaluated.

quote :value
  • :value (any-type!)

any-type?

True if the value is any-type!

any-type? value
  • value (any-type!)

any-value?

True if the value is any-value!

any-value? value
  • value (any-type!)

number?

True if the value is number!

number? value
  • value (any-type!)

scalar?

True if the value is scalar!

scalar? value
  • value (any-type!)

any-string?

True if the value is any-string!

any-string? value
  • value (any-type!)

any-word?

True if the value is any-word!

any-word? value
  • value (any-type!)

any-block?

True if the value is any-block!

any-block? value
  • value (any-type!)

any-path?

True if the value is any-path!

any-path? value
  • value (any-type!)

any-object?

True if the value is any-object!

any-object? value
  • value (any-type!)

any-function?

True if the value is any-function!

any-function? value
  • value (any-type!)

none?

True if the value is none!

none? value
  • value (any-type!)

logic?

True if the value is logic!

logic? value
  • value (any-type!)

integer?

True if the value is integer!

integer? value
  • value (any-type!)

decimal?

True if the value is decimal!

decimal? value
  • value (any-type!)

percent?

True if the value is percent!

percent? value
  • value (any-type!)

money?

True if the value is money!

money? value
  • value (any-type!)

pair?

True if the value is pair!

pair? value
  • value (any-type!)

tuple?

True if the value is tuple!

tuple? value
  • value (any-type!)

date?

True if the value is date!

date? value
  • value (any-type!)

time?

True if the value is time!

time? value
  • value (any-type!)

char?

True if the value is char!

char? value
  • value (any-type!)

string?

True if the value is string!

string? value
  • value (any-type!)

file?

True if the value is file!

file? value
  • value (any-type!)

email?

True if the value is email!

email? value
  • value (any-type!)

url?

True if the value is url!

url? value
  • value (any-type!)

tag?

True if the value is tag!

tag? value
  • value (any-type!)

binary?

True if the value is binary!

binary? value
  • value (any-type!)

bitset?

True if the value is bitset!

bitset? value
  • value (any-type!)

word?

True if the value is word!

word? value
  • value (any-type!)

set-word?

True if the value is set-word!

set-word? value
  • value (any-type!)

get-word?

True if the value is get-word!

get-word? value
  • value (any-type!)

lit-word?

True if the value is lit-word!

lit-word? value
  • value (any-type!)

refinement?

True if the value is refinement!

refinement? value
  • value (any-type!)

issue?

True if the value is issue!

issue? value
  • value (any-type!)

block?

True if the value is block!

block? value
  • value (any-type!)

paren?

True if the value is paren!

paren? value
  • value (any-type!)

path?

True if the value is path!

path? value
  • value (any-type!)

set-path?

True if the value is set-path!

set-path? value
  • value (any-type!)

A path with a colon at its end sets what it names, and its last part may be a paren worked out first:

>> sizes: [5 6] n: 2 sizes/(n): 7 sizes
== [5 7]

get-path?

True if the value is get-path!

get-path? value
  • value (any-type!)

lit-path?

True if the value is lit-path!

lit-path? value
  • value (any-type!)

map?

True if the value is map!

map? value
  • value (any-type!)

object?

True if the value is object!

object? value
  • value (any-type!)

error?

True if the value is error!

error? value
  • value (any-type!)

function?

True if the value is function!

function? value
  • value (any-type!)

native?

True if the value is native!

native? value
  • value (any-type!)

op?

True if the value is op!

op? value
  • value (any-type!)

datatype?

True if the value is datatype!

datatype? value
  • value (any-type!)

typeset?

True if the value is typeset!

typeset? value
  • value (any-type!)

handle?

True if the value is handle!

handle? value
  • value (any-type!)

unset?

True if the value is unset!

unset? value
  • value (any-type!)

series?

True if the value is series!

series? value
  • value (any-type!)

to-logic

Converts a value to logic!

to-logic value
  • value (any value)

to-integer

Converts a value to integer!

to-integer value
  • value (any value)

to-decimal

Converts a value to decimal!

to-decimal value
  • value (any value)

to-percent

Converts a value to percent!

to-percent value
  • value (any value)

to-money

Converts a value to money!

to-money value
  • value (any value)

to-char

Converts a value to char!

to-char value
  • value (any value)

to-pair

Converts a value to pair!

to-pair value
  • value (any value)

to-tuple

Converts a value to tuple!

to-tuple value
  • value (any value)

to-date

Converts a value to date!

to-date value
  • value (any value)

to-time

Converts a value to time!

to-time value
  • value (any value)

to-string

Converts a value to string!

to-string value
  • value (any value)

to-file

Converts a value to file!

to-file value
  • value (any value)

to-email

Converts a value to email!

to-email value
  • value (any value)

to-url

Converts a value to url!

to-url value
  • value (any value)

to-tag

Converts a value to tag!

to-tag value
  • value (any value)

to-binary

Converts a value to binary!

to-binary value
  • value (any value)

to-bitset

Converts a value to bitset!

to-bitset value
  • value (any value)

to-word

Converts a value to word!

to-word value
  • value (any value)

to-set-word

Converts a value to set-word!

to-set-word value
  • value (any value)

to-get-word

Converts a value to get-word!

to-get-word value
  • value (any value)

to-lit-word

Converts a value to lit-word!

to-lit-word value
  • value (any value)

to-refinement

Converts a value to refinement!

to-refinement value
  • value (any value)

to-issue

Converts a value to issue!

to-issue value
  • value (any value)

to-block

Converts a value to block!

to-block value
  • value (any value)

to-paren

Converts a value to paren!

to-paren value
  • value (any value)

to-path

Converts a value to path!

to-path value
  • value (any value)

to-set-path

Converts a value to set-path!

to-set-path value
  • value (any value)

to-get-path

Converts a value to get-path!

to-get-path value
  • value (any value)

to-lit-path

Converts a value to lit-path!

to-lit-path value
  • value (any value)

to-map

Converts a value to map!

to-map value
  • value (any value)