Number::Fraction

Th. J. van Hoesel th.j.v.hoesel at gmail.com
Thu May 2 18:50:24 BST 2013


That was a very clear explenation!.

the :constants is some heavy powerlifting for the compiler/interpreter. btw, what happens if more modules would do that. Is the interpeter just passing every bit of string to all the subs reference in that hash ? can two modules grab the same data and mess up the thing? will only the first in the hash been used? will they be nested, who comes first ?

First I was a bit confused at what all the different branchings were about in the constructor, but now I see where they are comming from... and why needed.

Back to your code, line 198:

  if (@_ >= 2)

Why not check for 

  if (@_ == 2)

?

it should have only two arguments to construct a fraction from calling Number::Fraction->new(1, 2);

Why would you allow it to pass other arguments?


Op 2 mei 2013, om 15:22 heeft Dave Cross het volgende geschreven:

> Quoting "Th. J. van Hoesel" <th.j.v.hoesel at gmail.com>:
> 
>> However, can someone point me out what is happening between lines 132 and 144 of Fraction.pm ? This part is the neatest part of the module, where it enables the module to use constants in your Perl programs.
> 
> I don't know if it's any help, but I've just rediscovered (and republished) the article that I wrote explaining how Number::Fraction works.
> 
>  http://perlhacks.com/articles/perl-com/overloading-perl-objects/
> 
> Cheers,
> 
> Dave...



More information about the london.pm mailing list