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.)
In reply to Re^5: referencing slices - love that DWIM
by ysth
in thread referencing slices - love that DWIM
by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |