in reply to Re^4: referencing slices - love that DWIM
in thread referencing slices - love that DWIM
To me, it is blatantly obvious that DWIMness dictates that \(@foo) ought to return the same as [@foo]I've never liked \(@foo) and thought it should be no different from \@foo (a reference to the array @foo).
My reasoning (undoubtedly flawed) is along the lines that the square brackets ([]) return a reference to whatever is within those brackets ...Flawed, yes. [] creates a new array, initialized from the list given, and returns a reference to it. This differs from "return[ing] a reference to whatever is within" in that it is a shallow copy, so \@foo is affected by later changes to @foo's elements, while [@foo] is not (unless those elements are references to other things which are changed.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: referencing slices - love that DWIM
by syphilis (Archbishop) on May 18, 2008 at 06:33 UTC | |
by ysth (Canon) on May 18, 2008 at 06:40 UTC |