next up previous
Next: Syntax Up: ODL: Language Report Previous: Parameterization

Predefined Classes

Besides the special classes Any and System, the following abstract classes are predefined.

class Bool
  fn val: bool;
  op t!: ()   ==> val' = true end
  op f!: ()   ==> val' = false end
  op set(b: bool): () ==> val' = b end
end

class Char
  fn val: char;
  op set(c: char): () ==> val' = c end
end

class Int
  fn val: int;
  op inc: ()          ==> val' = val + 1   end
  op dec: ()          ==> val' = val - 1   end
  op neg: ()          ==> val' = -val      end
  op set(i: int):  () ==> val' = i         end
  op add(i: int):  () ==> val' = val + i   end
  op sub(i: int):  () ==> val' = val - i   end
  op mul(i: int):  () ==> val' = val * i   end
  op dvd(i: int):  () ==> val' = val div i end
  op rem(i: int):  () ==> val' = val mod i end
end

class Real
  fn val: real;
  op neg: ()          ==> val' = -val      end
  op set(r: real): () ==> val' = r         end
  op add(r: real): () ==> val' = val + r   end
  op sub(r: real): () ==> val' = val - r   end
  op mul(r: real): () ==> val' = val * r   end
  op dvd(r: real): () ==> val' = val / r   end

  op set(i: int):  () ==> val' = i         end
  op add(i: int):  () ==> val' = val + i   end
  op sub(i: int):  () ==> val' = val - i   end
  op mul(i: int):  () ==> val' = val * i   end
  op dvd(i: int):  () ==> val' = val / i   end
end

class Time
  fn val: time;
  op set(t: time): () ==> val' = t         end
  op add(t: time): () ==> val' = val + t   end
  op sub(t: time): () ==> val' = val - t   end
  op mul(i: int):  () ==> val' = val * i   end
  op dvd(i: int):  () ==> val' = val div i end
end

As syntactic sugar, the val fn for an instance of any predefined class may be accessed via postfix ?.

At least one primitively implemented concrete subclass must be available for each of the above; minimally:

class BOOL is Bool ... end
class INT  is Int  ... end
class REAL is Real ... end
class CHAR is Char ... end
class TIME is Time ... end

There are no predefined classes supporting blob values. Implementations may provide them.

The partially predefined class System and single instance system are handled differently than all others. There need not be a single identifiable system object during execution. Its functionality may be spread (perhaps redundantly) across all processes or otherwise achieved in a constructed system.


Doug Lea@Sat Apr 8 10:25:42 EDT 1995