Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>

[[ 🗃 ^yEzqv rel4tion-wiki ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/yEzqv

SSH: git clone USERNAME@vervis.peers.community:yEzqv

Branches

Tags

master :: projects / idan / manual / 03-statements /

06-nested-blocks.mdwn

[[!meta title=“3.6 | Nested Blocks”]]

Nested Blocks

A nested block is a statement block which appears after the object of a statemet, and before its identifier. It contains a list of predicate sections, whose shared subject is the object of the containing statements. It allows a resource to be defined in the same place where it is used.

The list of predicate sections is written between square brackets ([]). If the statement object before them is <%>, it may be omitted. Example:

<%>
    smaoin:is_a myns:Person
    myns:has_name
    [
        myns:first "John"
        myns:last  "Doe"
    ]
    myns:has_age 34
    myns:has_height 170

The object can be explicitly specified, like any statement object: as a Uid, a generator, a reference, etc. Example:

<%>
    myns:has_name <%>
    [
        myns:first "John"
        myns:last  "Doe"
    ]

There are two ways to specify an anchor (e.g. =name) when using a nested block. One way is right after the object, if specified. The other is right after the opening bracket, i.e. the [ of the nested block. If the object is omitted, the second way is the only way. Examples:

<%>
    myns:has_name <%> =name
    [
        myns:first "John"
        myns:last  "Doe"
    ]

<%>
    myns:has_name <%>
    [ =name
        myns:first "John"
        myns:last  "Doe"
    ]

<%>
    myns:has_name
    [ =name
        myns:first "John"
        myns:last  "Doe"
    ]

The nested block content can written either as an indented block (as above) or as a free-form block. Examples:

<%>
    myns:has_name
    [
        myns:first "John" ;
        myns:last "Doe" .
    ]

<%>
    myns:has_name
    [
        myns:first "John" ; myns:last "Doe" .
    ]

<%>
    myns:has_name
    [ myns:first "John" ; myns:last "Doe" . ]

<%>
    myns:has_name [ myns:first "John" ; myns:last "Doe" . ]

<%> myns:has_name [ myns:first "John" ; myns:last "Doe" . ]
[See repo JSON]