[mercury-users] Perl implementation of Rational numbers (documentation)

Terrence Brannon princepawn at earthlink.net
Fri May 4 14:46:06 AEST 2001

Richard A. O'Keefe writes:
 > Terrence Brannon <princepawn at earthlink.net> wrote:
 > 	NAME
 > 	    Rational - Perl extension for manipulating rational numbers
 > ...
 > It was not clear to me whether this was a manual page for a package
 > that already exists, or a sample of what it would look like.  If the

I wrote and documented a small Perl class to handle rational numbers

 > package already exists, what are the names of the other operations?

The standard way to document Perl modules is via the sections:

NAME, SYNOPSIS, DESCRIPTION, METHODS (here is where you list all the
operations). But since this was a quick hack to stimulate dicussion, I
didn't go into that.

 > If it's a sample for discussion, then
 > 	      my $r1 = Rational->new(numerator=>1, denominator=>3);
 > suggests to me that for many uses
 > 	my $r1 = Rational::from("1/3")
 > would be better.  Amongst other things, rational numbers using bounded

But you were the one who just said that Perl people tend to use
strings where a structured approach to data manipulation was more
possible... your approach is string-based, mine is structural.

 > how often they didn't.  There are four approaches to handling integers
 > that are too big to fit in machine words:
 >   - The Burroughs Algol approach:  raise an exception so that you KNOW
 >     you're getting wrong answers.
 >   - The C approach: quietly give devastatingly wrong answers.  (This is
 >     optional in C, explicitly required in Java.)
 >   - The Perl approach: quietly give subtly wrong answers so that their
 >     wrongness only shows up much later.
 >   - The Lisp approach: give the RIGHT answer all the time.
 > A rational arithmetic package based on unsound integer arithmetic is
 > of very limited usefulness, whatever the programming language.

I see. 

mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list