Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Say I have an object, $heap. And say I want to store some really whopping huge strings in this heap. But $heap was not written to know about aliases and I don't want to add the overhead of putting references into the heap and telling it to use a dereferencing comparison function.

Is there much chance that I could use:

alias $heap->Push( $dna );

to acheive a heap of aliases? My understanding of your description says "no". Would it make sense to be able to copy an opcode tree and transform the copy like:

my $heapPush= aliasize $heap->can("Push"); $heapPush->( $heap, $dna );

(noting that routines called by $heapPush would still remain unaffected, perhaps unfortunately)

How would you go about retrofitting a module to support storing aliases instead of copies?

On a related note, compare these two bits of code:

my @x; sub swap { my( $i, $j )= @_; alias @x[$i,$j]= @x[$j,$i]; } sub exchange { my( $i, $j )= @_; alias do { my $t= $x[$i]; $x[$i]= $x[$j]; $x[$j]= $t; }; }

Do these cases work?

swap( 0, 1 ); exchange( 0, 1 ); swap( 0, 0 );

I expect I could work that out for myself but I don't want to expend the effort and I thought you might appreciate the opportunity. (:

BTW, smashing great idea for a module.

- tye        


In reply to Re: RFC: Is there more to alias? (cases) by tye
in thread RFC: Is there more to alias? by xmath

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found