11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.1 Syntax and Semantics3.1 Syntax and Semantics • 45The syntax of module definitions is very similar to that of procedures,given in the Introductory <strong>Programming</strong> <strong>Guide</strong>, Chapter 6. Here is anexample of a simple module definition.> module()> export e1;> local a, b;>> a := 2;> b := 3;> e1 := x -> a^x/b^x;> end module:Evaluating this expression results in a module with one export, e1, andtwo local variables, a and b.A template for a module definition looks like:module()local L;export E;global G;options O;description D;Bend moduleThe simplest valid module definition is> module() end;module() end moduleThis module definition does not have: exported variables, locals, references,global variables, or a body of statements. The module to whichthis evaluates is not very useful.The Module DefinitionEvery module definition begins with the keyword module, followed byan empty pair of parentheses. Following that is an optional declarationsection and the module body. The keyword combination end module (orjust end) terminates a module definition.

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

Saved successfully!

Ooh no, something went wrong!