in reply to Re^8: Scalar context of slice (vs grep)
in thread Scalar context of slice
A slice does make that same return decision based on context, but that's at the implementation level. At the language level the description can usually be abstracted away, because there is no simple way to redefine the return behavior of the slice from Perl. What they return in scalar context is effectively fixed unless you're pulling dirty tricks on your code's next maintainer.
Subroutines can easily be changed to care or not care about the calling context and to do different things if they care (or even based on the caller or other things more esoteric than the context) at the Perl level. Named built-in procedures look and act like more like subs than variable accesses do. Therefore, it's often easier to explain them in terms of Perl-level behavior of subs than C-level behavior of RHS and LHS in the interpreter.
Speaking of contexts, human conversation has context, too. A big part of that context is the abstraction level of the concepts involved. For effective communication, one usually doesn't intermingle abstraction levels without delineating them. If you choose to abstract slice accesses differently than FunkyMonk, then that's fair. I think you're intermingling the Perl language level with how perl does Perl under the hood in the middle of a language-level a bit differently than some other people in the thread are. Once they come to understand what you're actually discussing or you agree to write about what they are actually discussing, then it'll be easier for everyone to be clear and save everyone some headaches.
I'm not going to arbitrate which level is more suitable or which abstraction at the language level for slices (the one that more closely matches the implementation or the one that's IMO frankly clearer to people coming from a C-like language POV) is a better way to present the idea. I think it may be fruitful for the participants of the thread to recognize that the whole thread is a muddled mess of conflicting descriptions from different levels which eventually could be understood the same way. Different readers will understand one better than the other, but it's easier once both are put forward if the differences between them are made apparent.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Scalar context of slice (vs grep)
by tye (Sage) on Oct 08, 2008 at 20:23 UTC | |
by mr_mischief (Monsignor) on Oct 08, 2008 at 21:32 UTC | |
by tye (Sage) on Oct 09, 2008 at 06:40 UTC | |
by mr_mischief (Monsignor) on Oct 09, 2008 at 19:22 UTC | |
by tye (Sage) on Oct 09, 2008 at 20:32 UTC |