Kapitel 7. Fortgeschrittene Programmierung mit GEL

Inhaltsverzeichnis

Fehlerbehandlung
Übergeordnete Syntax
Funktionen als Rückgabe
Echte lokale Variablen
GEL Startprozedur
Laden von Programmen

Fehlerbehandlung

If you detect an error in your function, you can bail out of it. For normal errors, such as wrong types of arguments, you can fail to compute the function by adding the statement bailout. If something went really wrong and you want to completely kill the current computation, you can use exception.

For example if you want to check for arguments in your function. You could use the following code.

function f(M) = (
  if not IsMatrix (M) then (
    error ("M not a matrix!");
    bailout
  );
  ...
)