Number::Fraction
Th. J. van Hoesel
th.j.v.hoesel at gmail.com
Fri May 3 07:52:29 BST 2013
to me, it would make sense for 3 parameters:
Number::Fraction->(int, num, den);
but that would be helpful to work with the so called vulgar fractions and cold write things like:
my $twothreefourth = Number::Fraction->new( 2, 3, 4);
can I drop other cases or do you prefer to allow method calls with unlimited number of parameters ???
Theo
Op 2 mei 2013, om 19:50 heeft Th. J. van Hoesel het volgende geschreven:
> 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