jbrugger has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
After being away from Perl for a year, i'm back, and i seek new wisdom :)
In the .Net platform an object is stored in the heap. When passing the object 'as value' and not as a reference, the object itself isn't copied, you still get a reference to it (instead of a fresh copy).
If you want a copy (like items on the stack), you need to deep copy (clone) the object by hand.
I wonder how this is done in Perl, since i could not find any info on it.
Thanks again :)
edit:
as just stated by jkva (and the others below (thanks) ).... an object in Perl already IS a reference... So it stays a reference as it's passed :).
In the .Net platform an object is stored in the heap. When passing the object 'as value' and not as a reference, the object itself isn't copied, you still get a reference to it (instead of a fresh copy).
If you want a copy (like items on the stack), you need to deep copy (clone) the object by hand.
I wonder how this is done in Perl, since i could not find any info on it.
Thanks again :)
edit:
as just stated by jkva (and the others below (thanks) ).... an object in Perl already IS a reference... So it stays a reference as it's passed :).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: VB-ish behaviour byVar or byRef of objects in Perl
by moritz (Cardinal) on Dec 11, 2007 at 14:54 UTC | |
Re: VB-ish behaviour byVar or byRef of objects in Perl
by holli (Abbot) on Dec 11, 2007 at 14:47 UTC | |
Re: VB-ish behaviour byVar or byRef of objects in Perl
by sundialsvc4 (Abbot) on Dec 11, 2007 at 15:37 UTC | |
Re: VB-ish behaviour byVar or byRef of objects in Perl
by ikegami (Patriarch) on Dec 11, 2007 at 18:56 UTC | |
by webfiend (Vicar) on Dec 11, 2007 at 20:54 UTC | |
by Fletch (Bishop) on Dec 12, 2007 at 17:49 UTC |
Back to
Seekers of Perl Wisdom