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

Richard A. O'Keefe ok at atlas.otago.ac.nz
Mon May 7 09:51:20 AEST 2001


I wrote:
	 > 	      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
Terrence Brannon <princepawn at earthlink.net> wrote:
	
	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.
	
This is a fairly radical misunderstanding.
I said, suggested, and implied nothing about how numbers are represented
or manipulated *internally*.

I merely replaced, in an ***interface***, a data structure that couldn't
possibly work with one that could.  One would expect the insides of the
package to call C code to do the actual calculations, so the representation
of rational numbers *inside* the package might well be a suitably wrapped
C pointer, or perhaps two suitably wrapped C pointers.

Note in particular that if you are reading rational numbers from a file,
a method that converts strings with acceptable content to rational numbers
is exactly what you want.  Strings are often as appropriate for general-
purpose interfaces as they are lousy for processing.

--------------------------------------------------------------------------
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