HyperFun: Types, Variables and Declarations

There are two fundamental types for variables (’real’ and ‘array’) and an additional one (’string’).

Real

‘Real’ is the only elementary numeric type that is floating-point type and is equivalent to a ‘double’ type in C. Note that one can use integer constants but they are treated as a subclass of the same floating-point type; there is no explicit Boolean type but in the relational operators the floating-point value ‘0.’ is treated as ‘false’, and other values are treated as ‘true’.

Examples:

6.5
0
0.
-9.0
18
25e-3
-1.15E4

No declarations for floating-point variables are needed.

Array

Array consisting of elements of numerical real (floating-point) type is the only structured type in the HyperFun. The declarations for arrays are necessary and have the following general form:

‘array’ <arrayName> ‘[’<size>’]’ ‘;’

where ‘size’ is a constant representing a number of elements of the array. The array’s elements are indexed from 1 to size. So one can access the i-th element as

<arrayName>[i]

Examples of declarations of arrays with names ‘xx’ and ‘pz’:

array xx[3], pz[8];

The first element of ‘xx’ will be xx[1], and the forth element of ‘pz’ will be pz[4].

There are three special arrays with reserved names:

  • ‘x’ в_” denotes an array of coordinate variables for any given point of modeling space;
  • ‘a’ в_” denotes an array of ‘external’ numerical parameters;
  • ‘s’ в_” denotes an array of scalar functions representing attributes.

So, expressions inside a program can contain the elements of these arrays (for example: x[2], a[1], s[13]). It is supposed that ‘x’ and ‘a’ are input parameters, and ‘s’ is input/output parameter. This means that the actual values for both ‘x’ and ‘a’ arrays’ elements are defined outside the program, and that the actual values for ‘s’ can be defined both outside and inside the program. The declarations for these arrays must be given in the head of a program.

String

This type has a limited usage only as a constant being substituted instead of a corresponding library function’s argument. A string is represented as a sequence of characters surrounded by double quotation marks. The most typical usage of this type is to reference to a file name. Example:

“teapot.dat”

hyperfun/hf_types.txt · Last modified: 2008/12/11 10:04 by admin
This site contains HyperFun and other software that is free to use and modify under the provisions of the CGPL agreement unless otherwise stated.
Project hosted by the Digital Materialization Group
HyperFun CGPL Creative Commons License Valid CSS