Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Op! datatype

1. Abstract

Op! values are infix functions of two arguments that are constructed from existing native!, action!, function!, or routine! values.

Op! values take evaluation precedence over other function types and over set-word! values. They cannot contain optional arguments.

Op! is a member of the following typesets: any-function!, default!

2. Creation

Op values can be created at runtime by using a make constructor.

2.1. Runtime creation

<op> ::= make op! <prefix-function>


Logical or and and operators.

>> ||: make op! func [a b][any [a b]]  ; return the first value that is true
== make op! [[a b]]

>> 1 || 2
== 1

>> false || 2
== 2

>> &&: make op! func [a b][all [a b]]  ; if all values are true, return the last value; else return none
== make op! [[a b]]

>> 1 && 2
== 2

>> false && 2
== none

3. Conversions

No conversions are supported for op! values.

4. Comparisons

Op values can be compared for sameness and equality with same?, ==, equal?, strict-equal?, not-equal?, <>.

5. Testing values

Use op? to check if a value is of the op! datatype.

>> op? :&&
== true

Use type? to return the datatype of a given value.

>> type? :||
== op!

6. Predefined words

Op! values can be viewed by typing help op! in the Red console.