[Linux-disciples] perl question: why do modules return a reference to a hash and not a hash?

Stephen R Laniel steve at laniels.org
Thu Dec 22 10:21:08 EST 2005


On Thu, Dec 22, 2005 at 10:12:15AM -0500, Adam Rosi-Kessel wrote:
> Does anyone (particularly dpt, ken, slaniel) know why so many perl database
> functions return references to hashes rather than hashes?

My first inclination is to suggest that it's the same reason
why everyone recommends passing arguments by reference in C
and C++: because it uses much less memory. When you pass
around a raw object as an argument, rather than a reference
to that raw object, C and C++ make a copy of that object
onto the stack for that function. So you pass a reference
around, which is always a fixed size (equal to the size of a
word in that machine's memory). Then when you need to play
with the object itself, you dereference it.

That's just a guess. I'm looking around for other answers.

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20051222/5261be39/attachment.pgp


More information about the Linux-disciples mailing list