record, declare record

declaration/definition

Syntax
declare abstract? record record-type-name (extends record-type-name)?
   ((field field declaration)* | elsewhere)
    


Purpose

You can use declare record to declare a record type.

Here is how you would declare a record type to hold a simple metadata record for a document:

  declare record document-metadata-type
     field string  author
     field string  title
     field string  publisher
     field integer year
     field switch  in-print initial {true}
        

Each field in the record is itself of a particular type and is declared just as a local variable of that type would be declared, substituting the word field for the word local. Each field in a record is itself a shelf.

A record declaration by itself simply defines a record type. To create a record you must create a shelf of the record type.

A record can be declared as an extension of another record type, using extends:

  declare record book-metadata-type extends document-metadata-type
     field string isbn-number
        

An extended record type inherits the fields of its base type.

A record can be declared abstract by prefixing the keyword record with the keyword abstract. An abstract record cannot be instantiated, but can only be extended.

The keyword elsewhere can be used to make the record name and some of the properties available without defining all of the record's properties.