Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegant code & Efficient code

Name: Anonymous 2007-01-28 12:40

Elegant code & Efficient code, are they inversly proportional?

Name: Anonymous 2007-01-29 9:44

Silly me, with a name like factor, I figured it would return the factors of a number or something.
why would i possibly want to do that? that would be completely useless.

Returning a reference is for efficiency.  You clearly haven't done much work in C if you like to return things by value.  Of course, you could always use the wantarray builtin to determine which context you are being called in, and return appropriately.  But I never bother with the extra boolean compare.  There is rarely ever a reason to return a literal list/hash instead of a ref.
perl is not c. returning a ref is not more efficient than returning a list. the only reason to return a ref is if you're returning multiple arrays and don't want them collapsed into one list.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List