Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: A pair of "mathematical" attributes for arrays?

by blazar (Canon)
on Sep 12, 2007 at 07:45 UTC ( [id://638504]=note: print w/replies, xml ) Need Help??


in reply to Re: A pair of "mathematical" attributes for arrays?
in thread A pair of "mathematical" attributes for arrays?

I like the :nocirc suggestion, but the name doesn't make much sense to me. How about :posindex?

Well, I find it better than mine, but unsatisfactory too. I just couldn't concoct anything better: I wanted something short enough to be practical and I was thinking about "no circularity", but of course it's at best imprecise and more realistically patently wrong. OTOH yours gives me an impression of "positive indices only" which is not the case either. It's a matter of disabling a feature related to negative indices instead, for which I cannot think of a short enough description. But then you'll agree that it's a minor point anyway.

Update: (just not to clutter the thread with yet another reply) yes, TGI, I like all of your suggestions. Of course they are all as far away from reality as a more thorough coverage and a better implementation of attributes and a wider adoption of them.

Replies are listed 'Best First'.
Re^3: A pair of "mathematical" attributes for arrays?
by TGI (Parson) on Sep 12, 2007 at 17:10 UTC

    My first though was along the lines of :nonegindex. But that's long and unwieldy. What about something with an argument:

    # $foo[-1] returns 'Illegal Array Index Error' @foo :negindex( value => 'Illegal Array Index Error' ); # $foo[-1] normal behavior @foo :negindex( REVERSE ); # $foo[-1] apply some filter ( filter takes array, index as args) @foo :negindex( filter => sub { return -1 * $_[0]->[ abs( $_[1]) ] } ) +; # $foo[-1] returns undef, exists( $foo[-1] ) is false. #@foo :negindex( DO_NOT_WANT ); @foo :negindex( NO_EXIST ); # And to anticipate all future feature creep: # $foo[-1] returns sends an email message @foo :negindex( email => bob@example.com );


    TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found