Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 27, 2002 Array comparisons | ||||
---|---|---|---|---|
| ||||
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. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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
|
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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, 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. > > Sounds great... when do you expect we may see it in action? Gary. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | 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 B 2 votes. Programmer will need much more comparating values of arrays than references. Compare the statistics of use and choose the implementation. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in news:a7r7ok$1ing$2@digitaldaemon.com: > Since <, <=, >, >= make little sense on dynamic array references, those are > I dont know why ? Strings comparation dont is a good example ? J. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juarez Rudsatz | "Juarez Rudsatz" <juarez@correio.com> wrote in message news:Xns91DDEEF3F4733juarezcom@63.105.9.61... > > Since <, <=, >, >= make little sense on dynamic array references, those are > > > > I dont know why ? > Strings comparation dont is a good example ? Array _references_, not contents. When you compare strings, you compare contents. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juarez Rudsatz | "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 than references. > 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. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | "Russell Borogove" <kaleja@estarcion.com> wrote in message news:3CA124F2.1010802@estarcion.com... > Walter wrote: > > 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 !==. That idea has great merit, but I worry that == being a reference comparison for, say, Object references, would just cause too much confusion. |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "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, 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. 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 |
March 27, 2002 Re: Array comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "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. |
Copyright © 1999-2021 by the D Language Foundation