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.

52 • Chapter 3: <strong>Programming</strong> with Modules> noSuchModule:-e;Error, ‘noSuchModule‘ does not evaluate to a moduleHere, a module expression is assigned to the name m, and themember selection expression m:-e evaluates to the value of the exportedvariable e of m.> m := module() export e; e := 2 end module:> m:-e;2Since m does not export a variable named noSuchExport, the followingexpression raises an exception.> m:-noSuchExport;Error, module does not export ‘noSuchExport‘Important The following module exports an unassigned name. Thisillustrates the importance of distinguishing module exports from globalvariables.> m := module() export e; end:References to the exported name e in m evaluate to the name e.> m:-e;eNote, however, that this is a local name e, not the global instance ofthe name.> evalb( e = m:-e );falseThe first e in the previous expression refers to the global e, while theexpression m:-e evaluates to the e that is local to the module m. Thisdistinction between a global and export of the same name is useful. Forexample, you can create a module with an export sin. Assigning a valueto the export sin does not affect the protected global name sin.

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

Saved successfully!

Ooh no, something went wrong!