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.

3.1 Syntax and Semantics • 59> m := module() end:> m;m> type( m, ’last_name_eval’ );trueAlthough type module is a surface type, it acts also as a structuredtype. Parameters passed as arguments to the unevaluated name moduleare taken to be the names of exports. For example, the module> m := module() export a, b; end:has the structured module type ‘module‘( a, b ):> type( m, ’‘module‘( a, b )’ );trueIt also has type type ‘module‘( a )> type( m, ’‘module‘( a )’ );truebecause any module that exports symbols a and b is a module thatexports the symbol a.Example: A Symbolic DifferentiatorThis section illustrates the various module concepts through a symbolicdifferentiator example. Since Maple provides a built-in differentiator diff,the example symbolic differentiator is named differentiate. Its (final)implementation is in the module DiffImpl (later in this chapter), whichholds all the local state for the program. Much of the code for the differentiatoris designed to implement either a standard rule (such as therule that the derivative of a sum is the sum of the derivatives of the summands),or special case rules for mathematical functions such as sin andexp. The example differentiator handles only real valued functions of asingle real variable.

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

Saved successfully!

Ooh no, something went wrong!