ref! values denote named references, such as social media handles or identifiers with an implied domain name.
ref! datatype belongs to any-string! typeset while being conceptually close to an issue! datatype, differing from it in implementation (string-like vs. symbol-like) and offered set of trade-offs.
ref! values can be created using literal syntax at load-time or constructed at run-time using either a make constructor or a to conversion.
ref! values support only one unique literal form described below.
Syntax
<ref> format : @<name> <name> : optional name of a referent
-
<name>is zero or more characters other than# $ ' , = > @ \ ^; -
literal form is terminated by one of the
" ( ) ; < [ ] { }or blank (space, tab,CR,LF) characters.
Examples
@ @red_lang @dockimbel @§2.1
Rules of ref! construction using make are as follows:
-
float!andinteger!specs denote the number of bytes to pre-allocate (float!is truncated); -
construction from any other datatype is equivalent to
toconversion.
Examples
make ref! 9.2
== @
make ref! 14
== @
make ref! <ref>
== @ref
make ref! [red (_lang)]
== @red_lang
make ref! #{76616C7565}
== @value
make ref! none
** cannot make error
make ref! #datatype
== @datatype
ref! supports a subset of datatype conversions valid for any-string! typeset.
In particular, when converting a given value to ref!, the transformations described below are applied, followed by the prepending of a @ character.
ref!.
| Datatype | Description |
|---|---|
|
Content is copied verbatim. |
|
|
|
Converted to string form if it contains a valid UTF-8 encoding. |
|
Forbidden. |
Other |
Equivalent to |
Examples
to-ref [f /o #o]
== @foo
to-ref #{626172}
== @bar
to-ref <qux>
== @qux
to-ref none
** cannot make error
Being a part of any-string! typeset, ref! values support many target types for conversion; their list and descriptions are given in the table below.
ref!.
| Datatype | Description |
|---|---|
|
Equivalent to enclosing |
|
Content is copied verbatim. |
|
In general equivalent to conversion to More details on supported literal formats can be found in the respective documentation. |
|
Value of a given datatype is returned (singleton). |
|
Logical |
|
UTF-8 encoded binary representation is returned as a result. |
|
First character, if present, is extracted. |
Other |
Forbidden. |
Examples
to-paren @ABC
== (@ABC)
to-tag @tag
== <tag>
to-float @+88.7
== 88.7
to-tuple @1.3.3.7
== 1.3.3.7
to-none @whatever
== none
to-logic @this-ref-is-false
== true
to-binary @matrix
== #{6D6174726978}
to-char @
** cannot make error
to-char @.:
== #"."
ref! supports all series actions (except for put, sort and trim) and all types of comparison in addition to min and max.
|
Note
|
form applied to ref! value discards a @ character, while mold preserves it.
|
Examples
reverse @alucard == @dracula find @haystack "needle" == none find @haystack 'stack == @stack skip @stackoverflow 5 == @overflow @this = "this" == true @this = @that == false @that == @that == true min @A @Z == @A form @content == "content" mold/part @catastrophy 4 == "@cat"