11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

48 • Chapter 3: <strong>Programming</strong> with ModulesImportant Do not assign a named module to another variable.> SomeName := eval( NamedModule );SomeName :=module NamedModule () export e; end module> SomeName:-e;NamedModule : −eExports of named modules are printed using the distinguished namethat was given to the module when it was created, regardless of whetherit has been assigned to another name.Whether a module has a name also affects the reporting of errorsthat occur during its evaluation. When the second attempt to evaluatethe named module definition above failed, the error message reported thelocation of the error by name. By contrast, when an error occurs duringthe evaluation of a normal module definition, the name unknown is usedinstead.> NormalModule := module() export e; error "oops"; end;Error, (in unknown) oopsThis differs from procedure error reporting. Maple cannot reportthe name of a normal module (that is, the name of the variable to whichthe module is assigned), because the evaluation of the right side of anassignment occurs before the assignment to the name takes place. So theerror occurs before any association between a variable and the modulehas occurred.DeclarationsThe declarations section of the module must appear immediately afterthe parentheses. All statements in the declarations section are optional,but at most one of each kind may appear. Most module declarations arethe same as those for procedures.Description Strings Provide a brief description outlining the purposeand function of any module you write. It is valuable to other users whoread your code. Include your overview after the description keyword,just as you would in a procedure definition.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!