Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Sat, 9 Sep 2017 10:34 am, Gregory Ewing wrote: > Steve D'Aprano wrote: >> The paradox of the axe is one illustration of the difficulty in defining "the >> same" in full generality. > > The axe situation doesn't arise in Python, because "same > object" in Python is a concept that only applies t

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: The paradox of the axe is one illustration of the difficulty in defining "the same" in full generality. The axe situation doesn't arise in Python, because "same object" in Python is a concept that only applies to objects existing at the same time. There's no way to even a

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: I don't think that talking about the average integer is meaningful. We're not averaging the integers, we're averaging their numbers of digits, which are natural numbers. To do this rigorously you could write down an expression for the average length of integers up to som

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Pavol Lisy
On 9/8/17, Gregory Ewing wrote: > Steve D'Aprano wrote: >> A harder question is, what if you take a random number from the Integers? >> How >> many digits will it have in (say) base 10? I don't have a good answer to >> that. >> I think it may be ill-defined. > > I think the answer is that on avera

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 11:01 pm, Rhodri James wrote: > On 08/09/17 13:45, Stefan Ram wrote: >> Gregory Ewing writes: >> [a random integer will on average have ] >>> infinitely many >>> digits -- despite every actual integer only having finitely >>> many di

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 01:01 pm, Rustom Mody wrote: > On Friday, September 8, 2017 at 7:39:38 AM UTC+5:30, Steve D'Aprano wrote: >> Rustom, I've already given you the definitive answer to your question about >> how to define `is` without talking about memory. You haven't replied or >> acknowledged i

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 08:20 pm, Ben Bacarisse wrote: > Steve D'Aprano writes: > >> On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: >> >>> languages without mutable objects don't >>> really care whether they're pass-by-X or pass-by-Y. >> >> Only if you don't care about efficiency. >> >> Believe m

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): > Marko Rauhamaa writes: >>I definitely trust that: >>a = b >>assert a is b >>even when b holds an immutable object. > > |Python 3.6.0 ... > |>>> x = 21568 > |>>> x is 21568 > |False I wasn't talking about x or 21568. I was talking about a and b. Marko --

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Antoon Pardon
Op 08-09-17 om 04:09 schreef Steve D'Aprano: > On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote: > >> On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: >>> Rustom Mody wrote: >>> I said: In that case please restate the definition of 'is' from the manual which invok

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:54 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> py> class K: # defines an object >> ... def __init__(self, x): >> ... self.x = x >> ... def append(self, value): >> ... self.x.append(value) >> ... >> py> a = [] >> py> b = K(a) >> py> a is

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Rhodri James
On 08/09/17 13:45, Stefan Ram wrote: Gregory Ewing writes: [a random integer will on average have ] infinitely many digits -- despite every actual integer only having finitely many digits! This is not possible because every integer has a finit

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Chris Angelico
On Fri, Sep 8, 2017 at 10:05 PM, Steve D'Aprano wrote: > On Fri, 8 Sep 2017 05:48 pm, Gregory Ewing wrote: > >> Steve D'Aprano wrote: >>> A harder question is, what if you take a random number from the Integers? >>> How >>> many digits will it have in (say) base 10? I don't have a good answer to

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:48 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> A harder question is, what if you take a random number from the Integers? How >> many digits will it have in (say) base 10? I don't have a good answer to >> that. I think it may be ill-defined. > > I think the answer is

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > >> languages without mutable objects don't >> really care whether they're pass-by-X or pass-by-Y. > > Only if you don't care about efficiency. > > Believe me, the first time you pass a five gigabyte array to a function

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> I definitely trust that: >> >>a = b >>assert a is b >> >> even when b holds an immutable object. > > That's true, but there's rarely a good use case for that > fact that isn't better addressed with an equality comparison > rather than an 'is' test

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Marko Rauhamaa wrote: I definitely trust that: a = b assert a is b even when b holds an immutable object. That's true, but there's rarely a good use case for that fact that isn't better addressed with an equality comparison rather than an 'is' test. As an example, back in the days of s

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: Models are needed Math is one possible model Machines are another I'm not sure there's any real distinction between "math" and "machines". A Turing machine, for example, is an idealised mathematical model of computation. Maybe the distiction you're trying to get at is "stat

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: I'd like to know what these rules are I can't give you a complete list of them off the top of my head, but some examples of the kind of rules I have in mind are: * After the assigment a = b a and b refer to the same object. * After x = [e1, e2, e3, ...] x refers

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: py> class K: # defines an object ... def __init__(self, x): ... self.x = x ... def append(self, value): ... self.x.append(value) ... py> a = [] py> b = K(a) py> a is b # these are not the same object (they're different types) False py> b.appe

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: A harder question is, what if you take a random number from the Integers? How many digits will it have in (say) base 10? I don't have a good answer to that. I think it may be ill-defined. I think the answer is that on average it has infinitely many digits -- despite every

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: 2. is — machine representation, too fine to be useful No, it's *not* machine representation. As I pointed out before, it's part of the abstract semantics of Python. And it's not "too fine to be useful". On the contrary, being aware of which objects are the same and which are

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Marko Rauhamaa
Gregory Ewing : > There is more leeway when it comes to immutable objects; > implementations are free to cache and re-use them, so well-written > code avoids depending on the result of "is" for immutable objects. I definitely trust that: a = b assert a is b even when b holds an immutable o

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Fri, Sep 8, 2017 at 1:01 PM, Rustom Mody wrote: > >> Can you show an actual false positive (two distinct objects for which `is` >> returns True) or false negative (the same object given as both operands for >> `is` nevertheless returns False)? In the absence of any actual bugs in the >> definit

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On Friday, September 8, 2017 at 7:39:38 AM UTC+5:30, Steve D'Aprano wrote: > On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote: > > > On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: > >> Rustom Mody wrote: > >> > >> > I said: In that case please restate the definition of

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote: > On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: >> Rustom Mody wrote: >> >> > I said: In that case please restate the definition of 'is' from the manual >> > which invokes the notion of 'memory' without bringing in memo

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:15 am, Stefan Ram wrote: > It computing newsgroups, for example, people > ask about how to compute the number of digits > of a number, when, actually, only numerals > (representations of numbers in a particular > numeral system) have digits. Um, yes? That's implici

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > > I said: In that case please restate the definition of 'is' from the manual > > which > > invokes the notion of 'memory' without bringing in memory. > > I don't know whether it's in the manual,

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On 06/09/17 14:02, Stefan Ram wrote: > Chris Angelico writes: >> The 'is' operator tests if two things are the same thing. > >»Roughly speaking, to say of two things that they are >identical is nonsense, and to say of one thing that it >is identical with itself is to say not

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 02:24 am, Chris Angelico wrote: > On Fri, Sep 8, 2017 at 1:30 AM, Steve D'Aprano > wrote: >> On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: >> >>> languages without mutable objects don't >>> really care whether they're pass-by-X or pass-by-Y. >> >> Only if you don't care ab

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Fri, Sep 8, 2017 at 1:30 AM, Steve D'Aprano wrote: > On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > >> languages without mutable objects don't >> really care whether they're pass-by-X or pass-by-Y. > > Only if you don't care about efficiency. > > Believe me, the first time you pass a five

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > languages without mutable objects don't > really care whether they're pass-by-X or pass-by-Y. Only if you don't care about efficiency. Believe me, the first time you pass a five gigabyte array to a function using pass-by-value, on a machine wi

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Thu, Sep 7, 2017 at 11:21 PM, Gregory Ewing wrote: > Rustom Mody wrote: > >> I said: In that case please restate the definition of 'is' from the manual >> which invokes the notion of 'memory' without bringing in memory. > > > I don't know whether it's in the manual, but at least for > mutable o

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Gregory Ewing
Steve D'Aprano wrote: I think that these two increment procedures will be (more or less?) equivalent: procedure increment(var n: integer); begin n := n + 1 end; procedure increment2(p: intpointer); begin p^ := p^ + 1 end; They are, with the proviso that, in standard Pascal, in

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Gregory Ewing
Rustom Mody wrote: I said: In that case please restate the definition of 'is' from the manual which invokes the notion of 'memory' without bringing in memory. I don't know whether it's in the manual, but at least for mutable objects, there is a way to define the notion of "same object" that do

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Marko Rauhamaa
Chris Angelico : > *facepalm* > > I got nothing to say to you. Then why say anything? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Antoon Pardon
Op 07-09-17 om 03:27 schreef Steve D'Aprano: > >> Yes it is. Pascal VAR parameters are exactly like Python a assignment. > Proof by assertion? > > "It is true, because I say it is true!" I didn't just assert, I also explained. That you choose to ignore the explanation doesn't make it a proof by as

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Thu, 7 Sep 2017 12:11 am, Antoon Pardon wrote: [...] > No it would not translate to the above diagram. It would translate to my > diagram. All variables in pascal refer to some object (in memory), they don't > refer to other variables. If you have a pointer variable, you have a variable > that

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 11:02 pm, Stefan Ram wrote: > Chris Angelico writes: >>The 'is' operator tests if two things are the same thing. > > »Roughly speaking, to say of two things that they are > identical is nonsense, and to say of one thing that it > is identical with itself is t

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 10:11 pm, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking of memory? >> >> Yes. >> >> id() returns an abstract

Re: A question on modification of a list via a function invocation

2017-09-06 Thread breamoreboy
On Wednesday, September 6, 2017 at 1:12:22 PM UTC+1, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: > > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > > > > > > > Can you explain what "id" and "is" without talking of memory? > > > > Yes. > >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
On 06-09-17 15:14, Stefan Ram wrote: > Steve D'Aprano writes: >> or any of the other things we can do in a language with references-as-values, >> like C or Pascal. > > I have always taken the stance that one has to use the words > as the language specification of the language one talks > ab

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
Op 06-09-17 om 14:58 schreef Steve D'Aprano: > On Wed, 6 Sep 2017 05:12 pm, Antoon Pardon wrote: > > [...] >>> I'm not saying that we should never use this model. Its a good model. But we >>> should be clear that it is a model of the implementation, and it describes >>> entities which are not part

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rhodri James
On 06/09/17 14:02, Stefan Ram wrote: Chris Angelico writes: The 'is' operator tests if two things are the same thing. »Roughly speaking, to say of two things that they are identical is nonsense, and to say of one thing that it is identical with itself is to say nothing at

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 11:02 PM, Stefan Ram wrote: > Chris Angelico writes: >>The 'is' operator tests if two things are the same thing. > > »Roughly speaking, to say of two things that they are > identical is nonsense, and to say of one thing that it > is identical with itself i

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 05:12 pm, Antoon Pardon wrote: [...] >> I'm not saying that we should never use this model. Its a good model. But we >> should be clear that it is a model of the implementation, and it describes >> entities which are not part of the Python language. We cannot do this: >> >> >>

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 10:44 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:48:48 PM UTC+5:30, Chris Angelico wrote: >> On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: >> a = (1,2) >> b = (1,2) >> a is b >> > False >> x = 1 >> y = 1 >> x is y >> >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 5:48:48 PM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: > > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano > > wrote: > >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > >> > >> > >> > Can you e

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 4:03:40 PM UTC+5:30, ROGER GRAYDON CHRISTMAN wrote: > On 5 Sep 2017 14:28:44, (Dennis Lee Bier) wrote: > > On 5 Sep 2017 17:57:18 GMT, > >> But what does "a C++ reference" refer to? > >> > > > Per Stroustrup (The C++ Programming Language 4th Ed, page 189) >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread nopsidy
https://www.youtube.com/watch?v=pNe1wWeaHOU&list=PLYI8318YYdkCsZ7dsYV01n6TZhXA6Wf9i&index=1 Thank you, -Alex Goretoy http://launchpad.net/~a1g On Wed, Sep 6, 2017 at 7:18 PM, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: >> On Wednesday, September 6, 2017 at 5:08:2

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking of memory? >> >> Yes. >> >> id() returns an abstract

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > > > > Can you explain what "id" and "is" without talking of memory? > > Yes. > > id() returns an abstract ID number which is guaranteed to be an integer, and > guara

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > Can you explain what "id" and "is" without talking of memory? Yes. id() returns an abstract ID number which is guaranteed to be an integer, and guaranteed to be distinct for all objects which exist at the same time. When an object ceases to exis

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steven D'Aprano wrote: Not in standard Pascal, but most actual Pascal compilers let you perform pointer arithmetic. Well, sort of. In the ones I've seen, it's more like being able to cast a pointer to an integer, do arithmetic on that and then cast it back. The results are about as implementati

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steven D'Aprano wrote: But many (perhaps even most) people have no problem dealing with location as a metaphor, where being in two places (metaphorically) is no problem at all: - I am in love, in trouble and in denial all at once. Sometimes the word "in" implies physical location, sometimes

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rhodri James
On 05/09/17 23:29, Grant Edwards wrote: On 2017-09-05, Marko Rauhamaa wrote: Pointer arithmetics is not an essential part of C. One could argue that it was a mistake to include it in the language. One may argue that it was a mistake, but I remember at least one implementation where pointer ar

Re: A question on modification of a list via a function invocation

2017-09-06 Thread ROGER GRAYDON CHRISTMAN
On 5 Sep 2017 14:28:44, wlfr...@ix.netcom.com (Dennis Lee Bier) wrote: > On 5 Sep 2017 17:57:18 GMT, https://webmail.psu.edu/webmail/retrieve.cgi?mailbox=inbox&start_num=14200&limit=50&sort=0&display=4×tamp=20170906045729&mid=mailman%2e%2e1504662834%2e2732%2epython%2dlist%40python%2eorg#";>r.

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 7:13 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 12:51:25 PM UTC+5:30, Gregory Ewing wrote: >> Rustom Mody wrote: >> > 2. is — machine representation, too fine to be useful >> >> Disagree - "is" in Python has an abstract definition that >> doesn't depend on m

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 7:01 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> You can't do this with Python, since pointer arithmetic fundamentally >> doesn't exist. > > > Pointer arithmetic doesn't exist in Pascal either, yet > Pascal most definitely has pointers as a distinct data > type. >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 12:51:25 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > 2. is — machine representation, too fine to be useful > > Disagree - "is" in Python has an abstract definition that > doesn't depend on machine representation. > > -- > Greg There is this (AFA

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Chris Angelico wrote: You can't do this with Python, since pointer arithmetic fundamentally doesn't exist. Pointer arithmetic doesn't exist in Pascal either, yet Pascal most definitely has pointers as a distinct data type. Insisting that only pointer arithmetic counts as "manipulating" pointer

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steve D'Aprano wrote: No, they aren't first-class. Maybe not fully, but you can do a lot more with them than you can in Pascal or Modula-2. - Containers of references are not allowed. You can't have arrays of references, but struct and class members can be references, so you can certainly b

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Rustom Mody wrote: 2. is — machine representation, too fine to be useful Disagree - "is" in Python has an abstract definition that doesn't depend on machine representation. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
Op 04-09-17 om 17:43 schreef Steve D'Aprano: > On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > >> Anton gave a picture explaining why/how references are needed and to be >> understood > Antoon gave a picture demonstrating one model of Python's semantics. > > It's a nice model that has a lot going

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Wed, 06 Sep 2017 01:04:17 +0300, Marko Rauhamaa wrote: > Chris Angelico : > >> That shows that the Java '==' operator is like the Python 'is' >> operator, and checks for object identity. You haven't manipulated >> pointers at all. In contrast, here's a C program that actually >> MANIPULATES po

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Tue, 05 Sep 2017 21:17:30 -0700, Rustom Mody wrote: > Sure you can say with Steven that this can be 'explained' by saying an > object can be in two places at one time. > Others would then say 'Humpty-dumpty!' since you have removed the most > basic intuition of objects and you are in effect say

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Wed, 06 Sep 2017 03:42:31 +, Stefan Ram wrote: > Well, this /is/ from the PRL: > > »An object's identity never changes once it has been created; > you may think of it as the object's address in memory.«. > ¯¯ > - Th

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Marko Rauhamaa
Rustom Mody : > On Wednesday, September 6, 2017 at 3:34:41 AM UTC+5:30, Marko Rauhamaa wrote: >> Pointer arithmetics is not an essential part of C. One could argue that >> it was a mistake to include it in the language. > > This is subjective of course… but still I wonder where you are coming from

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 9:55:10 AM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 2:17 PM, Rustom Mody wrote: > > Well ⅓ the point of pointers may be printing them out — which even in a > > language > > with 1st class pointers like C is rarely done/needed > > But still the us

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 2:17 PM, Rustom Mody wrote: > Well ⅓ the point of pointers may be printing them out — which even in a > language > with 1st class pointers like C is rarely done/needed But still the useless part. You don't actually *achieve* anything by printing out the pointer. > Another

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 9:22:15 AM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram wrote: > > Steve D'Aprano writes: > >>So in what sense are references part of the Python language? > > > > It would be possible to describe Python using a concept > > calle

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram wrote: > Steve D'Aprano writes: >>So in what sense are references part of the Python language? > > It would be possible to describe Python using a concept > called "reference", it's just that the The Python Language > Reference, Release 3.6.0 (PRL)

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:11 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> The third entity is the reference linking the name to the object (the arrow). >> This isn't a runtime value in Python, nor is it a compile time entity that >> exists in source code. It is pure implementation, and as such,

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 3:34:41 AM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico : > > > That shows that the Java '==' operator is like the Python 'is' > > operator, and checks for object identity. You haven't manipulated > > pointers at all. In contrast, here's a C program that actu

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Grant Edwards
On 2017-09-05, Marko Rauhamaa wrote: > Pointer arithmetics is not an essential part of C. One could argue that > it was a mistake to include it in the language. One may argue that it was a mistake, but I remember at least one implementation where pointer arithmetic was hugely more efficient than

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Marko Rauhamaa
Chris Angelico : > That shows that the Java '==' operator is like the Python 'is' > operator, and checks for object identity. You haven't manipulated > pointers at all. In contrast, here's a C program that actually > MANIPULATES pointers: > > [...] > > You can't do this with Python, since pointer

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 6:42 AM, Stefan Ram wrote: > Chris Angelico writes: >>here's a C program that actually MANIPULATES pointers: > ... >>x += 2; > ... >>You can in C. Can you in Java? > > »dog = null« in Java would correspond to »x = 0« in C. > > It seems, to you, an assignment of »x + 2«

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 5:48 AM, Stefan Ram wrote: > Depends on the meaning of "meaningful". In Java, one can > inspect and manipulate pointers like in this program for > example: > [chomp code] That shows that the Java '==' operator is like the Python 'is' operator, and checks for object id

Re: A question on modification of a list via a function invocation

2017-09-05 Thread MRAB
On 2017-09-05 20:08, Steve D'Aprano wrote: On Tue, 5 Sep 2017 11:47 pm, Gregory Ewing wrote: Steve D'Aprano wrote: [quoting Scott Stanchfield] Figure 7: (Java) Defining a Dog pointer Dog d; When you write that definition, you are defining a pointer to a Dog object, not a D

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 5:28 AM, Dennis Lee Bieber wrote: > On 5 Sep 2017 17:57:18 GMT, r...@zedat.fu-berlin.de (Stefan Ram) declaimed > the following: > >> But what does "a C++ reference" refer to? >> > > Per Stroustrup (The C++ Programming Language 4th Ed, page 189) > > """ > * .

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:47 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> [quoting Scott Stanchfield] >> Figure 7: (Java) Defining a Dog pointer >> Dog d; >> >> When you write that definition, you are defining a pointer to a Dog >> object, not a Dog object itself. >> [e

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:28 PM, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 3:15 AM, Ned Batchelder wrote: >> On 9/5/17 1:02 PM, Steve D'Aprano wrote: >>> On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: >>> Dennis Lee Bieber wrote: > Pascal, probably Modula-2, Visual BASIC are closer to the C++

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Tuesday, September 5, 2017 at 10:45:45 PM UTC+5:30, Ned Batchelder wrote: > On 9/5/17 1:02 PM, Steve D'Aprano wrote: > > On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > > > >> Dennis Lee Bieber wrote: > >>> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference > >>> semanti

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 3:15 AM, Ned Batchelder wrote: > On 9/5/17 1:02 PM, Steve D'Aprano wrote: >> On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: >> >>> Dennis Lee Bieber wrote: Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference semantics, in that the definition

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:08 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>[quote] >>The mistake they make is in the definition of >>Figure 7: (Java) Defining a Dog pointer >>Dog d; >>itself. When you write that definition, you are defining a pointer to a Dog >>object, not a Dog object itself. >>[

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:02 PM, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > >> Dennis Lee Bieber wrote: >>> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference >>> semantics, in that the definition of a function declares how the >>> argument(s) are passed. >>

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > Dennis Lee Bieber wrote: >> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference >> semantics, in that the definition of a function declares how the >> argument(s) are passed. > > Well, sort of. In Pascal and Modula, and also

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Tuesday, September 5, 2017 at 7:12:48 PM UTC+5:30, Rustom Mody wrote: > On Tuesday, September 5, 2017 at 6:42:07 PM UTC+5:30, Gregory Ewing wrote: > > Steve D'Aprano wrote: > > > The third entity is the reference linking the name to the object (the > > > arrow). > > > This isn't a runtime value

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Tue, Sep 5, 2017 at 11:11 PM, Gregory Ewing wrote: > Steve D'Aprano wrote: >> >> The third entity is the reference linking the name to the object (the >> arrow). >> This isn't a runtime value in Python, nor is it a compile time entity that >> exists in source code. It is pure implementation, an

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Gregory Ewing
Steve D'Aprano wrote: [quoting Scott Stanchfield] Figure 7: (Java) Defining a Dog pointer Dog d; When you write that definition, you are defining a pointer to a Dog object, not a Dog object itself. [end quote] Here Scott mixes up what the compiler does (creates a pointer

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Tuesday, September 5, 2017 at 6:42:07 PM UTC+5:30, Gregory Ewing wrote: > Steve D'Aprano wrote: > > The third entity is the reference linking the name to the object (the > > arrow). > > This isn't a runtime value in Python, nor is it a compile time entity that > > exists in source code. It is p

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Gregory Ewing
Dennis Lee Bieber wrote: Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference semantics, in that the definition of a function declares how the argument(s) are passed. Well, sort of. In Pascal and Modula, and also VB I think, parameters are the only things that can be

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Gregory Ewing
Steve D'Aprano wrote: On Tue, 5 Sep 2017 02:51 am, Stefan Ram wrote: > I am assuming that there are two argument passing mechanismss in the languages mentioned by me (C, C++, VBA, C#, Java, JavaScript, and Python): - pass by aliassing (reference) - pass "as if by assignment" That assumpti

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Gregory Ewing
Steve D'Aprano wrote: The third entity is the reference linking the name to the object (the arrow). This isn't a runtime value in Python, nor is it a compile time entity that exists in source code. It is pure implementation, and as such, exists outside of the Python domain. The fact that there

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
Dennis, That's an excellent summary of a number of programming languages' calling conventions, thank you. Unfortunately you have the X-No-Archive header set, so it will be lost to prosperity. To prevent that, I'm taking the liberty of quoting you in full below (and top posting). A couple of comm

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Chris Angelico
On Tue, Sep 5, 2017 at 1:36 AM, Dennis Lee Bieber wrote: > On Tue, 05 Sep 2017 00:20:25 +1000, Steve D'Aprano > declaimed the following: > >>(Of course this is silly. As all physicists know, there are no people, animals >>or cars in the world, there are only quarks and electrons.) > > Qua

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
On 04-09-17 16:30, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 12:09 am, Antoon Pardon wrote: > >> Op 04-09-17 om 15:26 schreef Steve D'Aprano: >>> On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: >>> Op 04-09-17 om 12:22 schreef Stefan Ram: > Rustom Mody writes: >>> Stefan Ram wrote

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 02:51 am, Stefan Ram wrote: > Steve D'Aprano writes: >>Sorry Stefan, that is the same trap that many others fall into. You are >>assuming that there are exactly two evaluation conventions: >>- pass by reference >>- pass by value >>and so if a language doesn't do one, it must do

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 9:13:43 PM UTC+5:30, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > > > Anton gave a picture explaining why/how references are needed and to be > > understood > > Antoon gave a picture demonstrating one model of Python's semantics. > > I

Re: A question on modification of a list via a function invocation

2017-09-04 Thread breamoreboy
On Monday, September 4, 2017 at 3:20:22 AM UTC+1, Chris Angelico wrote: > On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote: > > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote: > > > >> Needless to say, according to the definition in Plotkin's paper, Python > >> is "call-by-value". > > > > A

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > Anton gave a picture explaining why/how references are needed and to be > understood Antoon gave a picture demonstrating one model of Python's semantics. It's a nice model that has a lot going for it, in particular that it matches the most obviou

  1   2   >