Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: RFC: Junction.pm

by fireartist (Chaplain)
on May 04, 2005 at 09:01 UTC ( #453839=note: print w/replies, xml ) Need Help??


in reply to Re^4: RFC: Junction.pm
in thread RFC: Junction.pm

What does the dereferencing @{} overloading do in your code? I can't see where it's being used.

I think it'd be very nice to be able to do

if ( all(@foo) ) {...}
and have is evaluate the arguments for 'truth'. So I'll be adding that when I get a chance.

I don't think I'll be adding stringification overloading. I can't really explain why, but I really don't like print any(@foo) printing a random element.

Replies are listed 'Best First'.
Re^6: RFC: Junction.pm
by eric256 (Parson) on May 04, 2005 at 15:11 UTC

    The @{} lets you do my $large = any(1..10) > 5;my @large = @{$large}; That is why I don't short circuit. The stringification is something i went back and forth on. It might fit better as any(1..10)->string; but I dunno.

    BTW I added in the arthimitic. The nice thing about the dynamic way I overload is that it was only a few extra lines of code.

    my $mix = all(1..5) + any(1,2); produces a result like my $mix = all(any(2,3),any(3,4), any(4,5),any(5,6), any(6,7));

    Operator overloading realy is magic. ;) I also added a regex ->match method which alls things like if (any(@strings)->match(all($regex))

      P6 also has 'one'.
      return $true if (($self->{type} eq 'none') && scalar @{$true} == +0) or (($self->{type} eq 'all') && scalar @{$false} == +0) or (($self->{type} eq 'any') && scalar @{$true} != +0) or (($self->{type} eq 'one') && scalar @{$true} == +1);

      Also, @EXPORT should become @EXPORT_OK. I may want to import all(), but I already have an any() I don't want you to clobber.

      Lastly - you gonna release this or attempt to patch Perl6::Junction? The number of tests for this is going to be quite ... impressive. :-)


      • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
      • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

        Yea I can add a one function. There was some reason I didn't but I can't remember it now. ;) Might have been an older version of the code and yea I did intend to fix the export stuff and release it. Now I don't realy want to release it because his code does the same thing in the end, but they are drasticaly different code wise (and of course I'm quite fond of my own way ;) ). So wadda think? Release a second one that does almost the same thing? Or just keep it as my pet project on PerlMonks? Is there any harm to me releaseing a seperate but similar module just so that I can get experience with module releases?


        ___________
        Eric Hodges

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://453839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2021-01-27 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?