The Hyper Programming Language

Postfix Operator Expressions

General

Postfix operator expressions are expressions that consist of an expression followed by a postfix operator. An important thing to note is that the operand of a postfix operator expression is used as a non-pointer type. If the operand has a pointer type, then it will be automatically dereferenced.

Postfix operators

Hyper has the following postfix operators:

Operator Meaning
.member Member selection
(arguments) Procedure call
[index] Array index

The first two operators in the table are fairly straightforward and behave like in C++ and Java, except for the fact that their (left) operand can be a pointer. Also, there can be no whitespace between the . and the member. This member must be a valid identifier. For the procedure operator the argument list can be empty, of course.

If the result of a member selection expression is a procedure and no procedure call expression is present, then an implicit procedure call is applied.

The array operator is a bit of a special case. First of all, it can have multiple indexes. Second, adjacent array indexing operators are merged together. The compiler can then split the index list according to the array type the operator is used on. For example, when you use an index list of eight elements on an operand that is an array with three dimensions, then the compiler will use the first three indexes to apply the array operator of the operand, and the type that results will be used to apply the remaining five indexes, and so on.

Example

procedure printHello()
  # call the function printLn that is located in the class `Out' which in turn is
  # located in the `system' namespace
  system.Out.printLn("Hello!")
end

procedure isCellEmpty(x & y : nat, c : [ ] * [ ] * int) : bool
  return c[x, y] =$ null
end

See also


Valid HTML 4.01 Strict Valid CSS!