NOTE: **use Perl;** is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

tsee

reversethis-{gro.napc} {ta} {relleums}

http://steffen-mueller.net/

reversethis-{gro.napc} {ta} {relleums}

http://steffen-mueller.net/

You can find most of my Open Source Perl software in my CPAN directory [cpan.org].

Sunday December 17, 2006

06:26 AM

I just read today's "Perl Advent Calendar" (http://perladvent.pm.org/2006/16/) entry and found out that in today's entry, Jerrad Pierce introduces one of my modules, Number::WithError (http://search.cpan.org/dist/Number-WithError). Yay!

Now, he certainly has interesting things to say, but to cut down on the dependencies, he suggests commenting out three lines of the module code. Sure, I mean, it's Free Software. You could do that and even release the same module with just this change under a different name! But he goes on to say:

If you'd rather avoid installing the first three, you can do so by commenting out the following lines in v0.06 of Number::WithError with no apparent side-effects

*"With no apparent side-effects"?*

The test suite is failing all over the place because you have just removed the implementation of the tangent function!

Now, to be fair, he has a point. The dependencies are, at this stage, just there for tangent, which would otherwise be

```
sub my_tan { sin($_[0]) / cos($_[0]) }
```

# or rather in the module's context

sub my_tan { CORE::sin($_[0]) / CORE::cos($_[0]) }

Originally, I intended to leverage the implementation of the various less-common trigonometric and hyperbolic functions found in Math::Symbolic and add them to the repertoire of Number::WithError. I haven't done so because I didn't need it at the time. Then I forgot about it. Doh.

If it was just for the implementation of those ten or so functions, it would be questionable whether the dependencies (which are all pure-Perl, at least) are worse than duplicating a couple of functions. But there's more: Gaussian error propagation involves derivatives. Other than that, it's a straightforward formula. Math::Symbolic can compute derivatives for you. Got the idea?

Basically, one would get the implementation of most code in Number::WithError for free by generating the derivatives of the functions using Math::Symbolic and compiling them to Perl subroutines using Math::SymbolicX::Inline during the package BEGIN time. This made particular sense since hand-coding every routine was rather prone to small errors and unless he does the math by hand, it's not necessarily obvious to a programmer reading the code why it does what it does.

Fact is, I didn't do it back then. I don't even remember why. Probably some time constraint or "let's get this working before I make it elegant" thinking. It doesn't matter. I don't think publicly suggesting users to comment out random code is a good idea. I'll forward the bug reports stemming from this if they surface.

Steffen

Full

Abbreviated

Hidden

Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.

## Ummm (Score:2)

Were that I say, pancakes?

## Patched: (Score:2)

Were that I say, pancakes?

## Re: (Score:2)

Were that I say, pancakes?

## Re: (Score:1)

- Please try Number::WithError 0.08 which is on its way to CPAN now. It fixes the bug that would make the constructor tests fail if Math::Symbolic wasn't loaded. Why the tests didn't fail if M::S was loaded is completely opaque to me, but the problem was related to (non) stringification of Math::BigFloat objects.

- That release also removes any dependency on Math::Symbolic*.

- How is this related to Module::Build

## Re: (Score:1)

* Re: M::B it doesn't always fail, and not in those ways. How does it relate? All of the build and test errors desensitized me to those that followed. Besides, how seriously do most people take test failures? It's usually a judgement call (80%+ success seems pretty good) since they all have the same weight (that might be an interesting extension... bumps and bruises vs. core meltdown)

* Re: SOACAHTOA Yes, it's a mnemonic for learning gemoetric relationships of a triangle's sides and angles.

*

Were that I say, pancakes?