"Steven D'Aprano" <steve+comp.lang.pyt...@pearwood.info> wrote in message news:555c225b$0$2769$c3e8da3$76491...@news.astraweb.com...
> The mental gymnastics they go through to force the round peg of pass-by- > sharing object semantics into the false dichotomy "pass-by-value versus > pass-by-reference" is just crazy. > > One consequence of this is that the meaning of "call by value" depends on > whether the value you are talking about is a boxed or unboxed value. > Unboxed > values are copied. Boxed values are not. Except that they are, if you > understand that "the value" doesn't refer to the actual value, but to some > hidden and implementation-dependent reference to the value. I have a language where everything is boxed (the data that isn't boxed, has to be before it can be manipulated). But simple data such as small integers and floats are passed by value. Bigger data is 'sort of' passed by reference, but not full reference (the details are a bit messy, but if an object consists of two parts (A,B), then a copy of descriptor A is passed, which contains a pointer to B. For small scalars, the B part doesn't exist). (A proper reference is available when passing arguments to functions: a boxed pointer to (A,B) is constructed.) However, I was so impressed with how (C)Python does things (working exclusively with pointers, doing assignments by simply copying pointers, and using reference counting to manage memory), that I'm experimenting with letting my language work the same way. (Also then I can benchmark the two more fairly.) Then I get a little disillusioned when I find out in this thread that a simple slice of an array actually copies every element! Since I currently create a view (a good term I'd never come across before) for a slice, does that mean I now also have to do what Python does? (Currently, /assignments/ of arrays - and slices - involve a deep copy. But for use as operands or passing as function arguments, only the lightweight descriptor A is passed, the 'view' in the case of a slice.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list