Hello,
As agreed upon with Dave Cross, I would make some really cool changes to his
module Number::Fraction - I as former math teacher love fraction.
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
Quoting "Th. J. van Hoesel" :
Hello,
As agreed upon with Dave Cross, I would make some really cool
changes to his module Number::Fraction - I as former math teacher
love fraction.
However, can someone point me out what is happening between lines
132 and 144 of Fraction.pm ?
thing too complicated. Let's reformat this:
my %_const_handlers =
(q => sub { return __PACKAGE__->new($_[0]) || $_[1] });
To this:
my $subroutine_ref = sub {
my $string_value_of_source = shift;
my $scalar_containing_value = shift;
# attempt to create a number fraction
my $numb
Dave wrote:
> Otherwise new() returns false and the original string is used instead.
Technically what Perl interpreted the original string to be is used instead.
i.e. you wrote:
return __PACKAGE__->new($_[0]) || $_[1]
Not
return __PACKAGE__->new($_[0]) || $_[0]
Which is where some of the conf
Quoting Dave Cross :
Should really give users the option to uninstall that handler too, I guess.
Oh. I did.
sub unimport {
overload::remove_constant(q => undef);
}
me++ # for code
me-- # for forgetting code
Dave...
Quoting Mark Fowler :
Dave wrote:
Otherwise new() returns false and the original string is used instead.
Technically what Perl interpreted the original string to be is used instead.
i.e. you wrote:
return __PACKAGE__->new($_[0]) || $_[1]
Not
return __PACKAGE__->new($_[0]) || $_[0]
Which
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...
= 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.
On 2 May 2013, at 18:50, "Th. J. van Hoesel" wrote:
> 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::Fractio
eeft James Laver het volgende
geschreven:
> On 2 May 2013, at 18:50, "Th. J. van Hoesel" wrote:
>
>> Back to your code, line 198:
>>
>> if (@_ >= 2)
>>
>> Why not check for
>>
>> if (@_ == 2)
>>
>> ?
>>
>> it sh
On 05/02/2013 11:50 PM, Th. J. van Hoesel wrote:
It doesn't make sense to call a function like 'sin (30 , 45, 270)'
Aditional parameters do not make sense.
You're right. Of course it doesn't. But you have no control at all over
how people use your code so (to me, at least) it makes sense to c
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
Quoting "Th. J. van Hoesel" :
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);
I think w
Op 3 mei 2013, om 10:21 heeft Dave Cross het volgende geschreven:
> Quoting "Th. J. van Hoesel" :
>
>> to me, it would make sense for 3 parameters:
>>
>> Number::Fraction->(int, num, den);
>>
>> but that would be helpful to work with the so
Quoting "Th. J. van Hoesel" :
Op 3 mei 2013, om 10:21 heeft Dave Cross het volgende geschreven:
Quoting "Th. J. van Hoesel" :
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 vulg
Op 3 mei 2013, om 12:34 heeft Dave Cross het volgende geschreven:
> Quoting "Th. J. van Hoesel" :
>
>>
>> Op 3 mei 2013, om 10:21 heeft Dave Cross het volgende geschreven:
>>
>>> Quoting "Th. J. van Hoesel" :
>>>
>>>>
Op 3 mei 2013, om 12:34 heeft Dave Cross het volgende geschreven:
> Quoting "Th. J. van Hoesel" :
>
>>
>> Op 3 mei 2013, om 10:21 heeft Dave Cross het volgende geschreven:
>>
>>> Quoting "Th. J. van Hoesel" :
>>>
>>>>
On 6 May 2013, at 13:57, "Th. J. van Hoesel" wrote:
>
> What if people figured out that the method did accept 3 or more arguments
> (why and how.. because they dug into the code ?). It would make no sensense
> at all to call the method Number::Fraction->new( 1,
James Laver het volgende geschreven:
> On 6 May 2013, at 13:57, "Th. J. van Hoesel" wrote:
>>
>> What if people figured out that the method did accept 3 or more arguments
>> (why and how.. because they dug into the code ?). It would make no sensense
>>
te constructors.
> I would like expand the string handling and allow it to pass in a string in
> the form off "a b/c". That is not a great deal, just a bit off code. However,
> I think it then looks a bit off to need an additional routine
> Number::Fraction->new_from_intege
ould make no sensense
> at all to call the method Number::Fraction->new( 1, 4, 6, 7, 2), but it would
> produce by some magic allowance that it should return a Number::Fraction
> object.
My policy for my code is that if I've documented something then I'll
continue to support it, bu
21 matches
Mail list logo