background image
C H A P T E R 1 1
Data Storage and Retrieval
About Data Storage on Newton Devices
Introduction to Data Storage Objects
Newton devices represent data as objects. The NewtonScript programming
language provides four basic object types that applications can use to
represent data:
Because immediates, binaries, and arrays are object representations of data types
common to many programming languages, they are not discussed further here. For
complete descriptions of these objects, see The NewtonScript Programming
The frame is of particular interest, however, as it can contain any of the other
objects and is the only NewtonScript object to which you can send messages. In
addition, the following characteristics of frames make them a particularly flexible
and efficient way to store data:
Frames are sized dynamically--they grow and shrink as necessary.
All frames support a common set of predefined NewtonScript data types that
allows them to share most data virtually transparently.
Dissimilar data types can be stored in a single frame.
Like a database record, a frame stores data items. An individual data item in the
frame is held in a slot, which may be thought of as a field in the database record.
Unlike database records, however, frames need not contain the same complement
of slots.
Any slot can hold any NewtonScript data type, including strings, numeric formats,
arrays, and binary objects. Note that NewtonScript does not require that slots
declare a datatype. Slots are untyped because every NewtonScript object stores
datatype information as part of the object itself. (NewtonScript variables need not
declare a type, either, for the same reason.)
Slots can also hold other frames, as well as references to frames, slots, and
NewtonScript objects. A frame's ability to reference other frames from its slots
allows it to inherit attributes and behaviors from ROM-based objects known as
system prototypes or "protos." This feature of the object system also provides
dynamic slot lookup and message-passing between frames. For detailed
descriptions of NewtonScript syntax, system-supplied data types, dynamic slot
A small, immutable object such as a character, integer or
Boolean value.
Raw binary data.
A collection of object references accessed from a
numerical index.
A collection of object references accessed by name.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна