1Math::Symbolic::Custom(U3s)er Contributed Perl DocumentatMiaotnh::Symbolic::Custom(3)
2
3
4
6 Math::Symbolic::Custom - Aggregate class for tree tests and transforma‐
7 tions
8
10 # Extending the class:
11 package Math::Symbolic::Custom::MyTransformations;
12 use Math::Symbolic::Custom::Base;
13 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
14
15 our $Aggregate_Export = [qw/apply_transformation1 .../];
16 sub apply_transformation1 {
17 # ...
18 }
19 # ...
20
21 # Using the custom class:
22 use Math::Symbolic;
23 use Math::Symbolic::Custom::MyTransformations;
24
25 # later...
26 $tree->apply_transformation1();
27 $tree->mod_transformation2();
28 die unless $tree->is_type1();
29 die unless $tree->test_condition1();
30 die if $tree->contains_something1();
31 print $tree->to_latex();
32
34 This is an aggregate class for all custom modification, transformation,
35 testing and output extensions for Math::Symbolic trees. Some default
36 transformations and tests are implemented in the Math::Symbolic::Cus‐
37 tom::DefaultMods and Math::Symbolic::Custom::DefaultTests packages,
38 default output routines in Math::Symbolic::Custom::DefaultDumpers which
39 are automatically loaded by the Math::Symbolic::Custom class.
40
41 Math::Symbolic::Custom imports all constants from Math::Sym‐
42 bolic::ExportConstants
43
44 EXPORT
45
46 None by default.
47
49 In order to extend the functionality of Math::Symbolic, you have to go
50 through the following steps: (also see the synopsis in this document.)
51
52 · Choose an appropriate namespace in the Math::Symbolic::Custom::*
53 hierarchy or if you desparately wish, somewhere else.
54
55 · Create a new module (probably using "h2xs -AX MODULENAME") and put
56 the following lines of code in it:
57
58 # To make sure we're cooperating with Math::Symbolic's idea of
59 # method delegation.
60 use Math::Symbolic::Custom::Base;
61 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
62
63 our $Aggregate_Export = [
64 # Put the list of method names to be exported.
65 /];
66
67 · Think well about the naming of your exported methods. Answer the
68 following questions:
69
70 Does the name start with 'is_', 'test_', 'mod_', 'apply_', 'con‐
71 tains_', or 'to_'? If not, find a suitable name that does.
72
73 Does the name clash with any of the methods exported by Math::Sym‐
74 bolic::Custom::DefaultTests, Math::Symbolic::Custom::DefaultMods,
75 or Math::Symbolic::Custom::DefaultDumpers? If so, please consider
76 choosing a different name.
77
78 Does the name map to the idea behind the method prefix ('is_',
79 ...)? Only methods starting with one of the prefixes listed above
80 can be delegated. Any others will never be called. The idea behind
81 delegating methods with several prefixes is to provide for a rea‐
82 sonable choice for naming methods. 'is_' and 'contains_' are meant
83 to be used for accurate tests like "is_constant". 'test_' is meant
84 for all tests that either make use of heuristics or can't be fitted
85 into either 'is_' or 'contains_'. The prefixes 'mod_' and 'apply_'
86 are meant for use with methods that modify the Math::Symbolic tree.
87 Finally, the prefix 'to_' is meant to be used with conversion and
88 output methods like 'to_latex' or 'to_string'. (Though as of ver‐
89 sion 0.122, to_string is implemented in the core Math::Symbolic
90 modules.)
91
92 · Make sure you document exactly what your methods do. Do they modify
93 the Math::Symbolic tree in-place or do they clone using the new()
94 constructor and return a copy? Make sure you mention the behaviour
95 in the docs.
96
97 · Consider packaging your extensions as a CPAN distribution to help
98 others in their development with Math::Symbolic. If you think the
99 extensions are generic enough to be a worthwhile addition to the
100 core distribution, try sending your extensions to the Math::Sym‐
101 bolic developers mailing list instead.
102
103 · Load your extension module after loading the Math::Symbolic module.
104
105 · Start using your custom enhancements as methods to the Math::Sym‐
106 bolic trees (any term types).
107
108 · Send bug reports and feedback to the Math::Symbolic support mailing
109 list.
110
112 Please send feedback, bug reports, and support requests to the
113 Math::Symbolic support mailing list: math-symbolic-support at lists dot
114 sourceforge dot net. Please consider letting us know how you use
115 Math::Symbolic. Thank you.
116
117 If you're interested in helping with the development or extending the
118 module's functionality, please contact the developers' mailing list:
119 math-symbolic-develop at lists dot sourceforge dot net.
120
121 List of contributors:
122
123 Steffen Müller, symbolic-module at steffen-mueller dot net
124 Stray Toaster, mwk at users dot sourceforge dot net
125 Oliver Ebenhöh
126
128 New versions of this module can be found on http://steffen-mueller.net
129 or CPAN. The module development takes place on Sourceforge at
130 http://sourceforge.net/projects/math-symbolic/
131
132 Math::Symbolic::Custom::Base Math::Symbolic::Custom::DefaultTests
133 Math::Symbolic::Custom::DefaultMods Math::Symbolic::Custom::Default‐
134 Dumpers
135
136 Math::Symbolic
137
138
139
140perl v5.8.8 2008-02-22 Math::Symbolic::Custom(3)