The declare datatype, Structures, Language grammar – Crunch CRiSP File Editor 6 User Manual

Page 25

Advertising
background image

Page 25

Primitive

Description

bookmark_list

List of bookmarks (placeholders).

command_list

List of primitives built into CRiSP.

dict_list

List of all symbols defined in a dictionary.

file_glob

List of files matching a wild card pattern.

key_list

Get keyboard bindings.

list_of_bitmaps

List of all bitmaps and pixmaps in a .xpl file.

list_of_buffers

List of all buffer IDs.

list_of_dictionaries

List of all object dictionaries..

list_of_keystroke_macros

List of all defined keystroke macros.

list_of_objects

List of all user defined dialog boxes.

list_of_screens

List of all screens (peel off windows).

list_of_windows

List of all windows in the current screen.

macro_list

List of macros defined.

{button See Also, ALink(crunch,,,)}

The declare datatype

The declare keyword is used to create a polymorphic variable. A polymorphic variable is one in which the
type of the variable stored can be changed. These are normally used as function parameters when it is not
known until run-time what the actual type will be, or for looking at elements in a list. The actual type of a
polymorphic variable is frozen when a new value is assigned to it, and until a new value is assigned the
function can treat the type of the variable as if it were of the type frozen. For example:

declare var;

var = 1.0;
var += 2.3;
/* var now contains value 3.3 */

var = "string";
var += "fred";

var = NULL;
/* Variable contains no value. */

{button See Also, ALink(crunch,,,)}

Structures

CRUNCH supports a minimal 'struct' facility. A structure is represented internally as a list but the usual X.Y
syntax allows convenient access to elements of a list/structure without having to manually #define indices.
Structures can be nested as in C. The order of definition of members of a structure is used to access
particular indices into a list structure. There is no concept of 'structure' padding as a CRUNCH structure is
not directly mapped on to a memory block.

{button See Also, Alink(crunch,,,)}

Language Grammar

The CRUNCH language is very similar to ANSI C. The following sections describe features of the language
grammar:

Declarations(pg. 26).

Advertising