[system] Repository:
ViewVC logotype

Revision 3716

Jump to revision: Previous Next
Author: dpvc
Date: Sun Oct 16 03:37:17 2005 UTC (14 years, 1 month ago)
Log Message:
In the past, when Value objects were inserted into strings, they would
automatically include parentheses so that if you had $f equal to 1+x
and $g equal to 1-x, then Formula("$f/$g") would mean (1+x)/(1-x)
rather than 1+(x/1)-x, which is what would happen as a straing string

The problem is that this would also happen for real numbers, vectors,
and everything else, even when it wasn't necessary.  So if $x=Real(3),
then "Let x = $x" would be "Let x = (3)".

I have changed the behavior of the string concatenation for Value
objects so that parentheses are only added in a few cases: for
Formulas, Complex numbers, and Unions.  This makes the other Value
objects work more like regular variables in strings, but might cause
some problems with strings that are used as formulas.  For example, if
$a = Real(-3), then "x + 2 $a" will become "x + 2 -3", or "x-1" rather
than the expected "x - 6".  (The old approach would have made it "x +
2 (-3)" which would have worked properly).  For the most part, it is
easier to use something like "x + 2*$a" or even "x" + 2*$a in this
case, so the extra trouble of having to avoid parentheses when you
really meant to substitute the value into a string didn't seem worth

Changed paths:

Path Details
Directorytrunk/pg/lib/Value/Complex.pm modified , text changed
Directorytrunk/pg/lib/Value/Formula.pm modified , text changed
Directorytrunk/pg/lib/Value/Infinity.pm modified , text changed
Directorytrunk/pg/lib/Value/Interval.pm modified , text changed
Directorytrunk/pg/lib/Value/List.pm modified , text changed
Directorytrunk/pg/lib/Value/Matrix.pm modified , text changed
Directorytrunk/pg/lib/Value/Point.pm modified , text changed
Directorytrunk/pg/lib/Value/Real.pm modified , text changed
Directorytrunk/pg/lib/Value/Set.pm modified , text changed
Directorytrunk/pg/lib/Value/String.pm modified , text changed
Directorytrunk/pg/lib/Value/Union.pm modified , text changed
Directorytrunk/pg/lib/Value/Vector.pm modified , text changed
Directorytrunk/pg/lib/Value.pm modified , text changed

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9