D - Array comparisons
- Walter (7/7) Mar 26 2002 I've been reading all the messages on string comparisons, and propose th...
- Russell Borogove (4/12) Mar 26 2002 I'd strongly prefer the other way around -- use value semantics
- Juarez Rudsatz (5/14) Mar 26 2002 2 votes.
- Pavel Minayev (6/9) Mar 26 2002 references.
- Walter (6/14) Mar 26 2002 are
- Pavel Minayev (6/8) Mar 27 2002 comparison
- Immanuel Scholz (9/23) Mar 27 2002 those
- Sean L. Palmer (4/7) Mar 27 2002 I would rather just write "&x == &y". It's explicit. It's easy.
- Pavel Minayev (9/12) Mar 27 2002 with
- Sean L. Palmer (6/19) Mar 28 2002 ==,
- Pavel Minayev (7/14) Mar 28 2002 it
- Gary (6/13) Mar 26 2002 are
- Juarez Rudsatz (5/8) Mar 26 2002 I dont know why ?
- Pavel Minayev (4/9) Mar 26 2002 Array _references_, not contents.
- Roberto Mariottini (24/31) Mar 27 2002 are
- Walter (4/20) Mar 27 2002 I was thinking of a dup() method in Object.
- Pavel Minayev (4/14) Mar 27 2002 The default version (straight copy all members) will be generated
- Roberto Mariottini (5/21) Mar 27 2002 The default version should call dup() on every object-type member
- Pavel Minayev (4/6) Mar 27 2002 In fact, most languages have two versions - one that simply copies
- Walter (3/18) Apr 12 2002 Yes.
- Immanuel Scholz (4/12) Mar 27 2002 name it clone()
- Sean L. Palmer (4/9) Mar 27 2002 Yeah, dup is so FORTH. ;)
- Pavel Minayev (3/4) Mar 27 2002 And it is a standard de facto.
- Juarez Rudsatz (14/25) Mar 27 2002 How about the Barry solution :
- Walter (7/8) Mar 27 2002 a
- Barry Pederson (15/26) Mar 28 2002 If I understand correctly, you mean the compiler would treat all these t...
- Walter (5/15) Apr 13 2002 Yes.
- Russ Lewis (12/19) Mar 27 2002 What about multidimensional arrays? When you use the === operator, are ...
- Richard Krehbiel (20/27) Mar 27 2002 are
- Pavel Minayev (6/12) Mar 27 2002 Comparing references is, in fact, more frequent than comparing values,
- Sean L. Palmer (3/4) Mar 28 2002 Good for you. That will help all the people who do confuse them.
- Pavel Minayev (4/5) Mar 28 2002 And who does? I've never seen === in any language other than JavaScript,
- Rchard Krehbiel (9/17) Mar 28 2002 want
- Walter (5/14) Apr 16 2002 I use it often when, for example, doing a reverse lookup on an array. I ...
- Richard Krehbiel (13/27) Apr 16 2002 as
- Walter (9/15) Apr 16 2002 How
- Russell Borogove (2/11) Apr 16 2002 Ewwwww.
-
Walter
(3/6)
Apr 16 2002
I guess that settles it - Robert W. Cunningham (6/12) Apr 16 2002 Well, how about: "if (a is b)"?
- Roberto Mariottini (3/15) Apr 17 2002 How about a GIF of a cat that eats a mouse? :-)
- Karl Bochert (6/12) Apr 16 2002 if ( a := b )
- Stephen Fuld (18/29) Apr 17 2002 wrote:
- Pavel Minayev (5/8) Apr 16 2002 semantically
- Sean L. Palmer (16/31) Apr 17 2002 I don't see what the problem is. The reference should be a basically hi...
- Pavel Minayev (8/11) Apr 17 2002 hidden
-
OddesE
(20/25)
Mar 27 2002
"Richard Krehbiel"
wrote in message - Pavel Minayev (5/13) Mar 27 2002 Hm, I've always thought that := is a standard math assignment?
- Stephen Fuld (10/17) Mar 27 2002 are
- Pavel Minayev (7/10) Mar 27 2002 contents
- Stephen Fuld (7/17) Mar 27 2002 are
- OddesE (46/53) Mar 27 2002 are
I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, those are by value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != will compare the references, and === and !== will call the equals() function in the Object base class.
Mar 26 2002
Walter wrote:I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, those are by value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != will compare the references, and === and !== will call the equals() function in the Object base class.I'd strongly prefer the other way around -- use value semantics for == and !=, and reference semantics for === and !==. -Russell B
Mar 26 2002
Russell Borogove <kaleja estarcion.com> wrote in news:3CA124F2.1010802 estarcion.com:Walter wrote:I've been reading all the messages on string comparisons, and propose the following:I'd strongly prefer the other way around -- use value semantics for == and !=, and reference semantics for === and !==. -Russell B2 votes. Programmer will need much more comparating values of arrays than references. Compare the statistics of use and choose the implementation.
Mar 26 2002
"Juarez Rudsatz" <juarez correio.com> wrote in message news:Xns91DDEEB1A3B8Ejuarezcom 63.105.9.61...2 votes. Programmer will need much more comparating values of arrays thanreferences.Compare the statistics of use and choose the implementation.Agreed (so 3 already). However, I wouldn't really mind if it was vice versa. I just like comparison by value to be default more.
Mar 26 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3CA124F2.1010802 estarcion.com...Walter wrote:areSince <, <=, >, >= make little sense on dynamic array references, thosecompareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willThat idea has great merit, but I worry that == being a reference comparison for, say, Object references, would just cause too much confusion.the references, and === and !== will call the equals() function in the Object base class.I'd strongly prefer the other way around -- use value semantics for == and !=, and reference semantics for === and !==.
Mar 26 2002
"Walter" <walter digitalmars.com> wrote in message news:a7rq5c$1s0b$2 digitaldaemon.com...That idea has great merit, but I worry that == being a referencecomparisonfor, say, Object references, would just cause too much confusion.Yep, you are right... and making semantics different for objects and arrays is probably not the best idea... Okay, then let it be ===.
Mar 27 2002
"Walter" <walter digitalmars.com> schrieb im Newsbeitrag news:a7rq5c$1s0b$2 digitaldaemon.com..."Russell Borogove" <kaleja estarcion.com> wrote in message news:3CA124F2.1010802 estarcion.com...thoseWalter wrote:Since <, <=, >, >= make little sense on dynamic array references,arecomparisoncompareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willThat idea has great merit, but I worry that == being a referencethe references, and === and !== will call the equals() function in the Object base class.I'd strongly prefer the other way around -- use value semantics for == and !=, and reference semantics for === and !==.for, say, Object references, would just cause too much confusion.You can resolve the confusion by making == a value-comparation for objects too :-) "x === y" can become the meaning of "&x == &y" in general, so this is not confusing too... Imi
Mar 27 2002
I would rather just write "&x == &y". It's explicit. It's easy. === is too easy to confuse with == which is already too easy to confuse with =. Sean"x === y" can become the meaning of "&x == &y" in general, so this is not confusing too... Imi
Mar 27 2002
"Sean L. Palmer" <spalmer iname.com> wrote in message news:a7t5g6$2k4k$1 digitaldaemon.com...I would rather just write "&x == &y". It's explicit. It's easy. === is too easy to confuse with == which is already too easy to confusewith=.All C/C++/D programmers should have natural immunity to confusing = with ==, and thus == and === won't be confused either =) Seriously speaking, since === will be used on arrays, I don't see why it can't be used on objects as well. Also, & is an "address of" operator, so &x will be of type Object*, and you will in fact compare addresses of references...
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tds3$2o9l$1 digitaldaemon.com..."Sean L. Palmer" <spalmer iname.com> wrote in message news:a7t5g6$2k4k$1 digitaldaemon.com...==,I would rather just write "&x == &y". It's explicit. It's easy. === is too easy to confuse with == which is already too easy to confusewith=.All C/C++/D programmers should have natural immunity to confusing = withand thus == and === won't be confused either =) Seriously speaking, since === will be used on arrays, I don't see why it can't be used on objects as well.So it's already been decided then? Well what the hell are we discussing it for?Also, & is an "address of" operator, so &x will be of type Object*, and you will in fact compare addresses of references...Implementation detail. It will work.
Mar 28 2002
"Sean L. Palmer" <spalmer iname.com> wrote in message news:a7ungk$bp0$1 digitaldaemon.com...itSeriously speaking, since === will be used on arrays, I don't see why it can't be used on objects as well.So it's already been decided then? Well what the hell are we discussingfor?Walter decided to use it for arrays. I thought we were discussing, how to apply it to objects as well?... by banning pointers to references (because & won't work on references as expected).Also, & is an "address of" operator, so &x will be of type Object*, and you will in fact compare addresses of references...Implementation detail. It will work.
Mar 28 2002
Walter <walter digitalmars.com> wrote in message news:a7r7ok$1ing$2 digitaldaemon.com...I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, thoseareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willcomparethe references, and === and !== will call the equals() function in the Object base class.Sounds great... when do you expect we may see it in action? Gary.
Mar 26 2002
"Walter" <walter digitalmars.com> wrote in news:a7r7ok$1ing$2 digitaldaemon.com:Since <, <=, >, >= make little sense on dynamic array references, those areI dont know why ? Strings comparation dont is a good example ? J.
Mar 26 2002
"Juarez Rudsatz" <juarez correio.com> wrote in message news:Xns91DDEEF3F4733juarezcom 63.105.9.61...Array _references_, not contents. When you compare strings, you compare contents.Since <, <=, >, >= make little sense on dynamic array references, those areI dont know why ? Strings comparation dont is a good example ?
Mar 26 2002
"Walter" <walter digitalmars.com> ha scritto nel messaggio news:a7r7ok$1ing$2 digitaldaemon.com...I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, thoseareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willcomparethe references, and === and !== will call the equals() function in the Object base class.Two questions: 1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment? 2 - What about integrating this syntax with pointers? Like this: int *p; int *q; ... ---- if (p === q) ... ---- is the same as : ---- if (*p == *q) ... ---- Ciao
Mar 27 2002
"Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a7rutn$1va1$1 digitaldaemon.com...1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment?I was thinking of a dup() method in Object.2 - What about integrating this syntax with pointers? Like this: int *p; int *q; ... ---- if (p === q) ... ---- is the same as : ---- if (*p == *q)Yes, that would be consistent.
Mar 27 2002
"Walter" <walter digitalmars.com> wrote in message news:a7s4ag$223b$1 digitaldaemon.com..."Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a7rutn$1va1$1 digitaldaemon.com...The default version (straight copy all members) will be generated automatically?1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment?I was thinking of a dup() method in Object.
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> ha scritto nel messaggio news:a7sdik$270c$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a7s4ag$223b$1 digitaldaemon.com...The default version should call dup() on every object-type member instead of doing a memcpy. Ciao"Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a7rutn$1va1$1 digitaldaemon.com...The default version (straight copy all members) will be generated automatically?1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment?I was thinking of a dup() method in Object.
Mar 27 2002
"Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a7sfup$285c$1 digitaldaemon.com...The default version should call dup() on every object-type member instead of doing a memcpy.In fact, most languages have two versions - one that simply copies object bit-by-bit, another which does the deep copy.
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7sdik$270c$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a7s4ag$223b$1 digitaldaemon.com...Yes."Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a7rutn$1va1$1 digitaldaemon.com...The default version (straight copy all members) will be generated automatically?1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment?I was thinking of a dup() method in Object.
Apr 12 2002
name it clone() dup is somewhat.....somewhat..... clone() is better, I think ;-) Imi1 - Waht about assignment? Object1 a; Object1 b; a = b; // by-reference assignment ???? // by-value assignment?I was thinking of a dup() method in Object.
Mar 27 2002
Yeah, dup is so FORTH. ;) Sean "Immanuel Scholz" <digital-mars kutzsche.net> wrote in message news:a7t3cs$2it9$1 digitaldaemon.com...I was thinking of a dup() method in Object.name it clone() dup is somewhat.....somewhat..... clone() is better, I think ;-) Imi
Mar 27 2002
"Immanuel Scholz" <digital-mars kutzsche.net> wrote in message news:a7t3cs$2it9$1 digitaldaemon.com...clone() is better, I think ;-)And it is a standard de facto.
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdm2$2o86$1 digitaldaemon.com..."Immanuel Scholz" <digital-mars kutzsche.net> wrote in message news:a7t3cs$2it9$1 digitaldaemon.com...Agreed. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mailclone() is better, I think ;-)And it is a standard de facto.
Mar 27 2002
Pavel Minayev wrote:"Immanuel Scholz" <digital-mars kutzsche.net> wrote in message news:a7t3cs$2it9$1 digitaldaemon.com...And more fun ... Sheep aSheep = new Sheep(); Sheep dolly = aSheep.clone(); :-) C 2002/3/28clone() is better, I think ;-)And it is a standard de facto.
Mar 28 2002
"Walter" <walter digitalmars.com> wrote in news:a7r7ok$1ing$2 digitaldaemon.com:I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, those are by value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != will compare the references, and === and !== will call the equals() function in the Object base class.How about the Barry solution :I'm curious now ... what about array slicing threw a wrench in the works? if (a[] == b) if (a[w..x] == b) if (a[] == b[y..z]) if (a[w..x] == b[y..z]) seem ok to me at first glance (of somebody not actually implementing the dang thing), unless you really wanted to compare-by-reference and not by- contents, in the 2nd and 4th cases. Barry
Mar 27 2002
"Juarez Rudsatz" <juarez correio.com> wrote in message news:Xns91DE7FB166B28juarezcom 63.105.9.61...I'm curious now ... what about array slicing threw a wrench in the works?a a[] a[0..a.length] all semantically mean the same thing as rvalues. Hence, no way to distinguish. As lvalues, I *can* distinguish them.
Mar 27 2002
Walter wrote:"Juarez Rudsatz" <juarez correio.com> wrote in message news:Xns91DE7FB166B28juarezcom 63.105.9.61...If I understand correctly, you mean the compiler would treat all these the same way: if (b[] == a) if (b[] == a[]) if (b[] == a[0..a.length]) which sounds good to me. As a D end-user, that's what I would have expected I guess. So I'm still scratching my head over this, and curious as to why it's a problem. Not so much to press the point of advocating that particular syntax, but mainly because it's kind if enlightening to be observing the beginning of a new language and pick up little tidbits here and there from Walter as to why things are or aren't workable for a compiler. BarryI'm curious now ... what about array slicing threw a wrench in the works?a a[] a[0..a.length] all semantically mean the same thing as rvalues. Hence, no way to distinguish. As lvalues, I *can* distinguish them.
Mar 28 2002
"Barry Pederson" <barryp yahoo.com> wrote in message news:3CA35185.1070805 yahoo.com...If I understand correctly, you mean the compiler would treat all these the same way: if (b[] == a) if (b[] == a[]) if (b[] == a[0..a.length])Yes.So I'm still scratching my head over this, and curious as to why it's a problem. Not so much to press the point of advocating that particular syntax, but mainly because it's kind if enlightening to be observing the beginning of a new language and pick up little tidbits here and there from Walter as to why things are or aren't workable for a compiler.The problem is how do you say you want to compare the contents of the array instead of the reference to the array?
Apr 13 2002
Walter wrote:I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, those are by value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != will compare the references, and === and !== will call the equals() function in the Object base class.What about multidimensional arrays? When you use the === operator, are you comparing the second, third, (and so on) dimensions by value or by reference? I'm still kind of partial to the (a[] == b[]) syntax, particularly if the number of []'s represents the depth of compare-by-value (any deeper and it's compare by reference). -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Mar 27 2002
"Walter" <walter digitalmars.com> wrote in message news:a7r7ok$1ing$2 digitaldaemon.com...I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, thoseareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willcomparethe references, and === and !== will call the equals() function in the Object base class.IMHO: For dynamic arrays, a = b should make b be a reference to a, a[] = b[] should copy the values from b to a, and == and != should do value comparisons. Similarly, for objects, a = b should make a reference, a = b.clone() wil ask b to make a copy of itself, and == and != should call .equals(). (IOW I think Java does this okay.) Comparing references is so frequently a mistake, that I'm inclined to want it to be difficult. If you simply must know, maybe do it by casting the object or array to void* (that .pointer property was also a good idea) and compare those. Dealing with = vs == is enough, thank you. Please don't add any such operators as === and !==. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)
Mar 27 2002
"Richard Krehbiel" <rich kastle.com> wrote in message news:a7t1n7$2i4a$1 digitaldaemon.com...Comparing references is so frequently a mistake, that I'm inclined to want it to be difficult. If you simply must know, maybe do it by casting the object or array to void* (that .pointer property was also a good idea) and compare those.Comparing references is, in fact, more frequent than comparing values, for objects.Dealing with = vs == is enough, thank you. Please don't add any such operators as === and !==.They are already in JavaScript, and I'd say they work rather good. I haven't _ever_ confused == with ===.
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdul$2oan$1 digitaldaemon.com...I haven't _ever_ confused == with ===.Good for you. That will help all the people who do confuse them.
Mar 28 2002
"Sean L. Palmer" <spalmer iname.com> wrote in message news:a7unkc$bpm$1 digitaldaemon.com...Good for you. That will help all the people who do confuse them.And who does? I've never seen === in any language other than JavaScript, and I've never heard of any JS programmer who confuses == with ===.
Mar 28 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdul$2oan$1 digitaldaemon.com..."Richard Krehbiel" <rich kastle.com> wrote in message news:a7t1n7$2i4a$1 digitaldaemon.com...wantComparing references is so frequently a mistake, that I'm inclined toandit to be difficult. If you simply must know, maybe do it by casting the object or array to void* (that .pointer property was also a good idea)I don't think this is correct. The only time I can imagine caring if Object a refers to the same thing as Object b is when I'm writing the "element delete" function for a singly-linked list. And with with decent collection class libraries, I shouldn't be needing to do that.compare those.Comparing references is, in fact, more frequent than comparing values, for objects.
Mar 28 2002
"Rchard Krehbiel" <krehbiel3 comcast.net> wrote in message news:a802rh$13io$1 digitaldaemon.com..."Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdul$2oan$1 digitaldaemon.com...I use it often when, for example, doing a reverse lookup on an array. I use it in the thread package to determine if the 'this' refers to the currently executing thread or not.Comparing references is, in fact, more frequent than comparing values, for objects.I don't think this is correct. The only time I can imagine caring if Object a refers to the same thing as Object b is when I'm writing the "element delete" function for a singly-linked list. And with with decent collection class libraries, I shouldn't be needing to do that.
Apr 16 2002
"Walter" <walter digitalmars.com> wrote in message news:a9hp9p$12cf$1 digitaldaemon.com..."Rchard Krehbiel" <krehbiel3 comcast.net> wrote in message news:a802rh$13io$1 digitaldaemon.com...as"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdul$2oan$1 digitaldaemon.com...Comparing references is, in fact, more frequent than comparing values, for objects.I don't think this is correct. The only time I can imagine caring if Object a refers to the same thinguseObject b is when I'm writing the "element delete" function for a singly-linked list. And with with decent collection class libraries, I shouldn't be needing to do that.I use it often when, for example, doing a reverse lookup on an array. Iit in the thread package to determine if the 'this' refers to thecurrentlyexecuting thread or not.But, do you compare references *more* *often* than you compare content? How often would a reference comparison be a mistake rather than the intent? I think content comparison is much more likely to be a programmer's intent, so when he codes "if(objA == objB)", do a content comparison. When he intends reference comparison, he can code "if(&objA == &objB)". -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)
Apr 16 2002
"Richard Krehbiel" <rich kastle.com> wrote in message news:a9hq7r$1385$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message But, do you compare references *more* *often* than you compare content?Howoften would a reference comparison be a mistake rather than the intent?Hard to say. With string arrays, I compare content. With objects, I compare references.I think content comparison is much more likely to be a programmer'sintent,so when he codes "if(objA == objB)", do a content comparison. When he intends reference comparison, he can code "if(&objA == &objB)".&x means the address of the reference. I don't think that will semantically work. Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.
Apr 16 2002
Walter wrote:Ewwwww.so when he codes "if(objA == objB)", do a content comparison. When he intends reference comparison, he can code "if(&objA == &objB)".&x means the address of the reference. I don't think that will semantically work. Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.
Apr 16 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3CBCCA22.9030407 estarcion.com...Walter wrote:<cough cough> I guess that settles it <g>Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.Ewwwww.
Apr 16 2002
Walter wrote:"Russell Borogove" <kaleja estarcion.com> wrote in message news:3CBCCA22.9030407 estarcion.com...Well, how about: "if (a is b)"? Yes, YAKW (Yet Another KeyWord). But it does flow, doesn't it? We could always FORTRAN-ize it: "if (a .IS. b)" How about a trigraph? -BobCWalter wrote:<cough cough> I guess that settles it <g>Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.Ewwwww.
Apr 16 2002
In article <3CBCEF97.FCCDA985 acm.org>, Robert W. Cunningham says...Walter wrote:How about a GIF of a cat that eats a mouse? :-) Ciao"Russell Borogove" <kaleja estarcion.com> wrote in message news:3CBCCA22.9030407 estarcion.com...Well, how about: "if (a is b)"? Yes, YAKW (Yet Another KeyWord). But it does flow, doesn't it? We could always FORTRAN-ize it: "if (a .IS. b)" How about a trigraph?Walter wrote:<cough cough> I guess that settles it <g>Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.Ewwwww.
Apr 17 2002
On Tue, 16 Apr 2002 12:21:21 -0700, "Walter" <walter digitalmars.com> wrote:&x means the address of the reference. I don't think that will semantically work. Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.if ( a := b ) if ( a === b ) // my favorite -- they are really, really the same if ( a <eq> b ) if ( identical ( a, b ) ) Karl Bochert
Apr 16 2002
"Karl Bochert" <kbochert ix.netcom.com> wrote in message news:1103_1019015587 bose...On Tue, 16 Apr 2002 12:21:21 -0700, "Walter" <walter digitalmars.com>wrote:semantically&x means the address of the reference. I don't think that willAs someone posted before, why not use the notion of properties of an object with the dot notation? This meakes things really clear, i.e. prevents confusion. For example if (a.id == b.id) // where id is a property of the object - its unique identity, probably its address. or converesly if (a.content == b.content) // clearly not the address comprisons Chose whatever key words you want, etc. but why do we need confusing special character sequences when short words convey what is going on so much better and thus avoid confusion? Surely we are past the days when C was designed to minimize keystrokes because they were done on a KSR 33 teletype at 110 baud. -- - Stephen Fuld e-mail address disguised to prevent spamwork. Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.if ( a := b ) if ( a === b ) // my favorite -- they are really, really the same if ( a <eq> b ) if ( identical ( a, b ) )
Apr 17 2002
"Walter" <walter digitalmars.com> wrote in message news:a9i80p$1v5a$1 digitaldaemon.com...&x means the address of the reference. I don't think that willsemanticallywork.Yep, right.Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.I remember you proposed === for arrays, maybe the same for objects?
Apr 16 2002
I don't see what the problem is. The reference should be a basically hidden thing anyway, acting for all intents and purpose like it actually *is* the object it refers to. You've seen references in C++... the following C++ code is completely legal (and I use stuff like this on a regular basis): class Foo { }; Foo a; Foo& aref = a; Foo* arefptr = &aref; assert(arefptr == &a); Sean "Walter" <walter digitalmars.com> wrote in message news:a9i80p$1v5a$1 digitaldaemon.com..."Richard Krehbiel" <rich kastle.com> wrote in message news:a9hq7r$1385$1 digitaldaemon.com...compare"Walter" <walter digitalmars.com> wrote in message But, do you compare references *more* *often* than you compare content?Howoften would a reference comparison be a mistake rather than the intent?Hard to say. With string arrays, I compare content. With objects, Ireferences.semanticallyI think content comparison is much more likely to be a programmer'sintent,so when he codes "if(objA == objB)", do a content comparison. When he intends reference comparison, he can code "if(&objA == &objB)".&x means the address of the reference. I don't think that willwork. Hmm, maybe "if (a [==] b)" ?? I have to think about this some more.
Apr 17 2002
"Sean L. Palmer" <spalmer iname.com> wrote in message news:a9jh6h$2vb3$1 digitaldaemon.com...I don't see what the problem is. The reference should be a basicallyhiddenthing anyway, acting for all intents and purpose like it actually *is* the object it refers to. You've seen references in C++... the following C++This understanding of reference I've only seen in C++ so far. Ask any Delphi, or VB, or Java programmer, they tell you that reference is practically just a pointer that doesn't support pointer arithmetic. This comes from the fact that C++ references are constant, while in D they change.
Apr 17 2002
"Richard Krehbiel" <rich kastle.com> wrote in message news:a7t1n7$2i4a$1 digitaldaemon.com... <SNIP>Dealing with = vs == is enough, thank you. Please don't add any such operators as === and !==. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)The reason == and = are often mistaken (IMHO) is that for lots of people = means equals. Certainly it usually means that in math... :) Assignment in math is not a standard operation, they use let? (let a = 10)... Also Pascal uses := for assignment and = for comparison. === on the other hand is not a standard symbol in math and people already (must) know that there is a difference between = and ==, so learning === should be easy. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail
Mar 27 2002
"OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a7tl44$2s36$1 digitaldaemon.com...Assignment in math is not a standard operation, they use let? (let a = 10)... Also Pascal uses := for assignment and = for comparison.Hm, I've always thought that := is a standard math assignment? At least MathCAD uses it for that purpose...=== on the other hand is not a standard symbol in math and people already (must) know that there is a difference between = and ==, so learning === should be easy.Yes, right.
Mar 27 2002
"Walter" <walter digitalmars.com> wrote in message news:a7r7ok$1ing$2 digitaldaemon.com...I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, thoseareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willcomparethe references, and === and !== will call the equals() function in the Object base class.Does this imply that equality comparisons will be supported on the contents of "strings", but not greater than or less than? That seems like a bad idea, as such comparisons are often quite usefull. -- - Stephen Fuld e-mail address disguised to prevent spam
Mar 27 2002
"Stephen Fuld" <s.fuld.pleaseremove att.net> wrote in message news:a7t4ch$2jfd$3 digitaldaemon.com...Does this imply that equality comparisons will be supported on thecontentsof "strings", but not greater than or less than? That seems like a bad idea, as such comparisons are often quite usefull.From the very first post in the thread: "Since <, <=, >, >= make little sense on dynamic array references, those are by value." So you will be able to perform comparisons on strings and other arrays.
Mar 27 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a7tdof$2o8r$1 digitaldaemon.com..."Stephen Fuld" <s.fuld.pleaseremove att.net> wrote in message news:a7t4ch$2jfd$3 digitaldaemon.com...areDoes this imply that equality comparisons will be supported on thecontentsof "strings", but not greater than or less than? That seems like a bad idea, as such comparisons are often quite usefull.From the very first post in the thread: "Since <, <=, >, >= make little sense on dynamic array references, thoseby value." So you will be able to perform comparisons on strings and other arrays.Thanks. I guess I had a brain glitch. :-( -- - Stephen Fuld e-mail address disguised to prevent spam
Mar 27 2002
"Walter" <walter digitalmars.com> wrote in message news:a7r7ok$1ing$2 digitaldaemon.com...I've been reading all the messages on string comparisons, and propose the following: Since <, <=, >, >= make little sense on dynamic array references, thoseareby value. Introduce two new operators, === and !==, to do a by-value comparison for arrays. Similarly, for class objects, == and != willcomparethe references, and === and !== will call the equals() function in the Object base class.I love it! I would like it vice versa, so == is by value in all situations (base type, array, object, struct), and === by reference, but that's nitpicking and it would break a lot of existing code. I read your posts on dup() and equals(). Basically you are doing a lot of what I was hoping for with my request for standard interfaces for operators in the thread "Operator overloading, a way to make everybody happy?", but instead of using interfaces, you are placing the functions directly in Object. It doesn't really matter, it's the end result that counts! This way is probably a lot more efficient? Let me get it straight: MyObject a = new MyObject, b = new MyObject; ... if (a === b) // will translate to if (a.equals (b)) ? if (a !== b) // will translate to if (! a.equals (b)) ? if (a > b) // will translate to if (a.cmp (b) > 0) ? if (a >= b) // will translate to if (a.cmp (b) >= 0) ? if (a < b) // will translate to if (a.cmp (b) < 0) ? if (a <= b) // will translate to if (a.cmp (b) <= 0) ? a = b // will translate to a.dup (b) ? If this is true, I'm sold! I would love that! Now building on this you might implement addition, subtraction, multiplication and division in much the same way. The default implementation of add() etc in object would just throw an OperatorNotSupported exception, but descendant classes could override them to do some serious work! Ofcourse, functionality to check what operators a class supports would also be very welcome: if (a.supportsop (Operator.PLUS)) // .... Sorry for grabbing the hand as soon as you give me a finger, but I love the concept of operator overloading, and this would make it fairly transparent to implement. Also, operator overloading haters could always directly call the normal functions. Thanks Walter, great! -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Mar 27 2002
"OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a7tk0m$2rgu$1 digitaldaemon.com...Sorry for grabbing the hand as soon as you give me a finger, but I love the concept of operator overloading, and this would make it fairly transparent to implement. Also, operator overloading haters could always directly call the normal functions.It does seem like I've fallen backwards into supporting operator overloading <g>.
Apr 17 2002
"Walter" <walter digitalmars.com> wrote in message news:a9j73p$2mhs$1 digitaldaemon.com..."OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a7tk0m$2rgu$1 digitaldaemon.com...overloadingSorry for grabbing the hand as soon as you give me a finger, but I love the concept of operator overloading, and this would make it fairly transparent to implement. Also, operator overloading haters could always directly call the normal functions.It does seem like I've fallen backwards into supporting operator<g>.I'd rather call it jumping forwards ;) But what about it? Any plans on add, subtract, divide and multiply? (Sorry, gotta ask :) ) -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail
Apr 18 2002
"OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a9n0gm$2vvl$1 digitaldaemon.com...Right now I want to finish what I've got, and ship it. There's always 2.0!It does seem like I've fallen backwards into supporting operatoroverloading<g>.I'd rather call it jumping forwards ;) But what about it? Any plans on add, subtract, divide and multiply? (Sorry, gotta ask :) )
Apr 18 2002