osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tutor] beginning to code


On 23/09/2017 04:06, Bill wrote:
> Mark Lawrence wrote:
>> On 22/09/2017 08:01, Bill wrote:
>>> Steve D'Aprano wrote:
>>>> On Fri, 22 Sep 2017 02:57 pm, Bill wrote:
>>>>
>>>>> I find Python to be more more
>>>>> like Java, with regard to "passing objects by reference".
>>>> Which is not a surprise, since both Python and Java use the same 
>>>> value passing
>>>> style: pass by object reference, or pass by sharing if you prefer.
>>>>
>>>> Java people don't call it that. They call it pass by value, and 
>>>> categorically
>>>> deny that it is pass by reference. (They're right about the second 
>>>> point.)
>>>
>>> I figure that, internally, an address, a pointer, is being passed by 
>>> value to implement pass by reference.? Why do you say "they are 
>>> right" above? Are you saying it's not pass by reference?
>>>
>>
>> Please see 
>> http://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyreference-neither/ 
>> and http://effbot.org/zone/call-by-object.htm
>>
> 
> 
> I would would agree with the description provided for the C++ example 
> provided
> 
> string some_guy = "fred";
>  ?is replaced by
> char* some_guy="fred";
> 
> To see that this is correct, note the some_guy may subsequently be 
> assigned to a character string much longer then "fred".? An additional 
> note: A character string literal, like "cat", never occurs more than 
> once in compiled C++ program unit.? This also shows that the provided 
> description can't be completely correct. One last thing,
> 
> string some_guy = "fred"
> 
> is really the same thing as
> 
> string some_guy("fred");
> 
> and both equivalently call the string constructor.
> 
> The data type of "fred" is const char*, not (class) string.
> 

I have no interest it what the C++ does, looks like or anything else. 
All I'm bothered about is that two highly respected members of the 
Python community have stated quite clearly that Python is call by 
object.  Many other people have stated the same in this thread or 
previously, yet still people who know squat about Python continue to 
debate the subject.  Why waste effort going over old ground?  Is it 
completely impossible for people to step outside of their world of pass 
by value or pass by reference?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

---
This email has been checked for viruses by AVG.
http://www.avg.com