Log Message:
-----------
Fixed a bug that would cause step() to produce an error when called on
a constant value. Also, added fact() function that was defined in
Algparser but not in Parser (which uses x! notation).
Modified Files:
--------------
pg/lib/Parser/Legacy:
Numeric.pm
Revision Data
-------------
Index: Numeric.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/Numeric.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -Llib/Parser/Legacy/Numeric.pm -Llib/Parser/Legacy/Numeric.pm -u -r1.1 -r1.2
--- lib/Parser/Legacy/Numeric.pm
+++ lib/Parser/Legacy/Numeric.pm
@@ -1,19 +1,28 @@
##########################################################
#
-# Implements a context in which the "step" function
-# is defined. This was defined in the old AlgParser,
-# but not in the Parser's standard Numeric context.
+# Implements a context in which the "step" and "fact"
+# functions are defined. These were defined in the old
+# AlgParser, but are not in the Parser's standard
+# Numeric context.
+#
+# Warning: since step and fact already are defined in
+# PGauxiliarymacros.pl we can't redefine them here, so you
+# can't use step(formula) or fact(formula) to automatically
+# generate Formula objects, as you can with all the other
+# functions. Since this context is for compatibility with
+# old problems that didn't know about Formula objects
+# anyway, that should not be a problem.
#
-# Warning: since step is already defined in PGauxiliarymacros.pl
-# we can't redefine it here, so you can't use step(formula) to
-# automatically generate Formula objects, as you can with
-# all the other functions.
package Parser::Legacy::Numeric;
our @ISA = qw(Parser::Function::numeric);
-sub step {shift; main::step((shift)->value)}
+sub step {shift; do_step(shift)}; sub do_step {Value::pgCall('step',@_)}
+sub fact {shift; do_fact(shift)}; sub do_fact {Value::pgCall('fact',@_)}
my $context = $Parser::Context::Default::context{Numeric}->copy;
$Parser::Context::Default::context{LegacyNumeric} = $context;
-$context->functions->add(step => {class => 'Parser::Legacy::Numeric'});
+$context->functions->add(
+ step => {class => 'Parser::Legacy::Numeric', perl => 'Parser::Legacy::Numeric::do_step'},
+ fact => {class => 'Parser::Legacy::Numeric', perl => 'Parser::Legacy::Numeric::do_fact'},
+);
|