July 08, 2005
Anders F Björklund wrote:
> Bruno Medeiros wrote:
> 
>> And if even so, one wanted the objects to behave like basic non-pointer
>> types, then you would have to make it behave consistently, that is,
>> appply it everywere in the language, right? Not just for '=='. 'obj1 =
>> ojb2' would then be a copy operation, (like it is with integers, or C++
>> local objects), and not a pointer assigment.
>>
>> So it seems to me that it is much better to use '==' for identity(equality of pointer) and maybe something like 'eq' and 'neq' for object equality.
> 
> 
> Another suggestion was to switch '==' and 'is' around, so that you
> could use '==' for identity and use 'is' to call upon the opEquals ?
> 
> I always thought that to be rather confusing, especially at the time
> since it was still called '===' back then. Which has a meaning to me.
> 
> And if you are suggesting "this.opEquals(that)", I don't want it :-)
> I know that others do though, and it seems to be working out for Java.
> 
> 
> Having something like 'eq' and 'ne', like Perl does, would be somewhat
> different but could work. It would make you search for all the rest of
> them, though ('lt' 'gt' 'le' 'ge')* and wonder what the difference is ?
> 
> Like it being ok to use "a == b" for two char[], but having to use
> "a eq b" for two String ? Or "x != y" for two int, but "x ne y"
> for two Integer ? (not that wrapper classes are recommended, but...)
> 
> 
> By the way, how *do* you "clone" an object in D ? I know that .dup
> works for the array types, but how to do a shallow copy for objects ?
> 
> It's funny, I thought this was "confusing" enough with '===' and '=='
> without having to drag '=' into it... But the more the merrier ? ;-)
> 
> --anders
> 
> 
> PS. * I would still like to see the starship operator in D ('<=>'),
>     pronounced 'cmp' and calls opCmp - it comes in handy for sorting.

Honestly, I have to say that in most of you post I didnt clearly understand your point. In any case let me just clarify some things up: If "==" were changed to be a reference equality op, then "is" shouldnt be the value equality op (i.e., no swaping). If we wanted an equality op in this case, it should be named "eq" (plus "neq" or "!eq") or something like that.

As for your other post, where you mentioned the thread that Kris started, well, I read a bit of it, but gave up soon. It was too long, had many unrelated posts (such as about isnot and other stuff) and the other ones where often misconstrued or had some incorrectnesses, plus I would had to read the whole thing flated, instead of threaded.


Anyway, I'm gonna postpone this issue for while. I'm busy with my final exams, and when they're finished I'm planing in the summer holidays to investigate and learn D more and do some real work with it. I will try the current "==" design and see if i can acommodate myself with it, though I doubt that. And failing that, there is allway some good ol': sed -e "s/==/is/" -e "s/!=/!is/"   :)


-- 
Bruno Medeiros
Computer Science/Engineering student
July 09, 2005
Bruno Medeiros wrote:

> Honestly, I have to say that in most of you post I didnt clearly understand your point.

That is OK, maybe I was adding too many different things into it...

> In any case let me just clarify some things up: If "==" were changed to be a reference equality op, then "is" shouldnt be the value equality op (i.e., no swaping). If we wanted an equality op in this case, it should be named "eq" (plus "neq" or "!eq") or something like that.

Agreed, and I think the "swapping" idea was just because if you use
identity on primitive types like int - it does fall back to equality ?

I'm certainly not proposing it, and I don't think that D needs any
more compare operators like the ones proposed ("eq"/"neq") either...

BTW; I would prefer "ne" over "neq", but that's just because I'm an
old user of Perl (and even Assembler) where that syntax is being used.

> As for your other post, where you mentioned the thread that Kris started, well, I read a bit of it, but gave up soon. It was too long, had many unrelated posts (such as about isnot and other stuff) and the other ones where often misconstrued or had some incorrectnesses, plus I would had to read the whole thing flated, instead of threaded.

I'm not sure it was that much easier to follow back when it happened :-)
It's a lot easier if you read it in Thunderbird, which does threading ?

To be honest, I'm not sure what came out of - except for the "!is".

> Anyway, I'm gonna postpone this issue for while. I'm busy with my final exams, and when they're finished I'm planing in the summer holidays to investigate and learn D more and do some real work with it. I will try the current "==" design and see if i can acommodate myself with it, though I doubt that. And failing that, there is allway some good ol': sed -e "s/==/is/" -e "s/!=/!is/"   :)

That is what you need to do with most C++/Java code to "port", as well.
Especially since the construct "object == null" is likely to segfault ?

But for the time being, I don't think that there'll be any more changes.

--anders
1 2
Next ›   Last »