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

Terrence Brannon princepawn at earthlink.net
Tue May 8 12:37:49 AEST 2001


Point taken. The reason I posted both a Perl and Mercury version of
the rational number source code was to stimulate some discussion about
packaging mechanisms in the two languages. 

Perl manages to do the same with less. It has two means of
sequestering related code and data into a structure. It has the
keyword package and hashes (associative arrays). 

Mercury has associative arrays. And in addition it has typeclasses and
modules (similar to perl packages) for grouping related code and data
into a structure.

The expressive ease of both appears to be about the same. They both
handle object-oriented dispatch based on more than one type. It is
builtin to Mercury. You have to install Class::MultiMethods if you
want this for Perl.

...it's amazing how waiting to the next day to actually send a mail
actually leads to more lucent thought about what one wants to say.


 > 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

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