Chapter 7. Advanced Programming with GEL

Table of Contents

Error Handling
Toplevel Syntax
Returning Functions
True Local Variables
GEL Startup Procedure
Loading Programs

Error Handling

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!");