Set-path! datatype

1. Abstract

Set-path! sets a "contextual reference" (word in a context, indexes slot in a series, or keyed reference in a series or map).

Set-path! is a member of the following typesets: any-block!, any-path!, series!

2. Creation

Set-path! values can be created at runtime by using a make constructor or to conversion.

>> make set-path! [foo bar baz]
== foo/bar/baz:

You can create an empty set-path of a given size by supplying an integer value as an argument to make:

>> make set-path! 10
== :

To conversion:

>> to set-path! "foo bar baz"
== foo/bar/baz:

3. Literal syntax


<set-path-literal> ::= <path-literal>:

<path-literal> ::= <path-head>/<selector>
<path-head>    ::= <word-literal> | <path-literal>
<selector> ::= <integer> | <word-literal> | :<word-literal> | <paren>


set-path: [set-word! some selector]
selector: [#"/" [integer! | word! | get-word! | paren!]]

Path-head datatypes: set-word!, set-path!

Selector datatypes: integer!, word!, get-word!, paren!

4. Evaluation Steps

A set-path! value follows the same evaluation rules as path! until the selector is reached, at which point the selector is set to the value of the expression that follows it.

If there is no expression following the selector, or if the expression returns unset, an error is raised.

5. Testing values

Use set-path? to check if a value is of the set-path! datatype.

>> set-path? first [foo/bar:]
== true

>> set-path? quote foo/bar:
== true

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

>> type? first [foo/bar:]
== set-path!

>> type? quote foo/bar:
== set-path!

6. Pre-defined words

6.1. Functions

set-path?, to-set-path

results matching ""

    No results matching ""