[ic] mv_credit_card_reference

Javier Martin interchange-users@interchange.redhat.com
Tue Feb 19 11:11:01 2002


Mike said:

> > So, what should be the good behavior of &calc=return 0;? To
> > cause or not to cause profile failure?
>
> Hmm. At this point I would say that you should have to return(undef, 0) to
> explicitly cause a failure. Anything else might cause systems to break.

Yes but we still need some changes to the Order.pm because the &calc pragma
currently goes:

    '&calc'         =>  sub { Vend::Interpolate::tag_calc($_[1]) },


While the tag_calc sub at Interpolate.pm goes:

    sub tag_calc {

      ...
      $result = $ready_safe->reval($body);

      ...
      return $result;
    }


Which means that only the first scalar from the return stack is returned and
the rest are discarded.

The only way to solve this with minimum hassle (while trying not to break
running systems) would be:

    &calc=return [undef, 0];


Yes call me dirty, we return a reference to the array and nothing is
discarded by tag_eval. This needs a slight modification to the %Parse hash
at Order.pm:

    '&calc'  => sub { my $result = Vend::Interpolate::tag_calc($_[1]);
                      return ref($result) ? @$result : $result;
                    }


My problem is that I need to check things at PROFILE time rather than ITL
time and these checks should be able to abort the profile, so I have no
options besides &calc. :(

Another option is to write a new &calc_version_2 pragma that takes this into
account because the 'return [0, 0]' thing is certainly not much intuitive.

Javier