Updated 2013-09-02 04:17:06 by RLE

struct command

struct <sub command> ?<arg> ...?
struct create <structure name> <list>
Creates an instance of the named structure type initialising the contents of the structure to the contents of the list. e.g.
        % set a [struct create node {root {} {}}]
        <feather::structure 0x2004e278>
struct define <structure name> <definition>
Defines a new structure type or redefines an old structure type. The definition is simply a list of member names. e.g.
        % struct define node {
             data
             left
             right
        }
struct contents <structure instance>
Returns the contents of the structure as a list.

As a structure is also a container it is possible to use the generic container Feather Container commands with it. e.g.
        % struct define node {
             data
             left
             right
        }
        % set a [struct create node {root {} {}}]
        <feather::structure 0x2004e278>
        % getx $a data
        root
        % setx $a left [struct create node {child1 {} {}}]
        % struct contents $a
        root {<feather::structure 0x2004ef18>} {}
        % getx $a left data
        child1