Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Lit-word! datatype

1. Abstract

A lit-word! value is an unevaluated word! value. It has the literal value of itself.

A lit-word! value will decay into a word! when evaluated, such as when entered into the Red REPL.

Lit-word! is a member of the following typesets: any-word!, all-word!, immediate!

2. Creation

Lit-word values can be created using literal syntax, or at runtime using a to conversion from the datatypes: char!, logic!, string!, datatype!, issue!, and refinement!.

>> 'test
== test

>> type? 'test
== word!
>> to lit-word! #"X"
== 'X

>> to lit-word! true
== 'true

>> to lit-word! "Hello"
== 'Hello

>> to lit-word! float!
== 'float!

>> to lit-word! #A42
== 'A42

>> to lit-word! /only
== 'only

3. Literal syntax

An apostrophe ' followed by one or more characters from the entire Unicode range, including punctuation characters from the ASCII subset: ! & ' * + - . < = > ? _ | ~`

Illegal characters are control characters, whitespace characters, and punctuation characters from the ASCII subset: / \ ^ , [ ] ( ) { } " # $ % @ : ;

A lit-word! value cannot begin with a number.

4. Comparisons

All comparators can be applied on lit-word!: =, ==, <>, >, <, >=, <=, =?.

5. Testing values

Use lit-word? to check if a value is of the lit-word! datatype.

>> lit-word? first ['foo bar baz]
== true

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

>> type? first ['foo bar baz]
== lit-word!

6. Predefined words

6.1. Functions

to-lit-word