[Bluej-discuss] confusion over = (and == ?)

Louise Laforest laforest.louise at uqam.ca
Fri Nov 30 20:44:57 GMT 2007


And also in C++, he can write p -> next to get the field "next" in a  
struct pointed to by p wich would be confusing if we had the operator  
"->" for the assignment statement as it was suggested earlier (ok,  
just for C++ programmers !).  Why they get rid of the ":=" for the  
assignment statement ?  I think it would be more uniform with the  
other assigments operators +=, -=, *=, and so on.

I've taught lots of languages and students had no problems with ":="

Louise


Le 07-11-30 à 14:53, Paul McCard a écrit :

> Of course, in C++ the programmer can define additional overloadings  
> of operators to make everything even clearer!  ;-)
>
> Paul.
>
> Ian Barland wrote:
>>
>> Carl Alphonce writes:
>>>
>>> "==" is not overloaded. "==" does the same thing in both cases.
>> I'd argue that == is overloaded, and even mention in CS1: == :  
>> int, int --> boolean == : double, double --> boolean == : Object,  
>> Object --> boolean (once we have talked about references) / :  
>> double, double --> double / : int, int --> int // named "quotient"  
>> in some languages Yes, like any good overloaded method, each  
>> version of == does a similar task (unlike "/"). [True, these  
>> different overloaded methods for == might each compile to the same  
>> op code, but at the high-level of Java syntax == must be  
>> overloaded so that the auto-casting rules for 0==0.0, etc, can be  
>> invoked. Also note that Double.NaN == Double.NaN, so the == for  
>> doubles requires an extra check which the other overloaded  
>> versions don't.] Is it worth *teaching* that even operators have  
>> signatures? I've found so; it helps reinforce that "==" returns a  
>> result which is usable, it also helps explain why "/" seems to  
>> give different answers, and overall it just helps unify the whole  
>> idea of calling functions. (And while you might sigh that it's a  
>> whole second syntax for calling a function, at least it's not as  
>> (b)ad hoc as the syntax for casting primitives.) --Ian B.  
>> _______________________________________________ mailing list bluej- 
>> discuss at bluej.org To unsubscribe or change your preferences, go to  
>> http://lists.bluej.org/mailman/listinfo/bluej-discuss
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss


-----------------------------------------
Louise Laforest, Ph.D.
Professeure
Université du Québec à Montréal
Département d'informatique
téléphone (514) 987-3000 poste 7790
fax (514) 987-8477
laforest.louise at uqam.ca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.tiff
Type: image/tiff
Size: 25512 bytes
Desc: not available
Url : http://lists.bluej.org/pipermail/bluej-discuss/attachments/20071130/592a357c/attachment-0001.tiff 
-------------- next part --------------








More information about the bluej-discuss mailing list