TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Alan and Carmel Brain <[log in to unmask]>
Wed, 12 Apr 2000 23:27:22 +1000
text/plain (42 lines)
From: "Geoff Bull" <[log in to unmask]>

> >    a = 1;
> >    b = a;
> >    a = a+1;
> >
> > what does b equal?
>
> 1
>
> > In Java:
> > if b is the primitive "int", then b=a-1
> > if b is the class "Integer" then b = a means in Ada terms b renames a.
For which
> > we can thank C.
>
> But b must have been a primitive, because operators only work for
primitives
> (except for "+" for catenating Strings).
>
> Have I missed something?

Of course you're right. As they say in the classics, DOH!

My example was too simple, I was careless,  should have had a = f(a) not a=
a+1.
where the signature of f is not immediately visible (to humans, rather than
the machine).

The problem I was attempting to illustrate is the somewhat counter-intuitive
use of
=, where on a Class it's a rename, on a primitive it's an assignment of
value.

Similarly for a==b, where in java you're saying "are a and b just aliases
for the same object"
rather than comparing their internal values. Which is done with a.equals(b),
assuming
that's defined.

Mea Culpa in any event. Thanks for the correction and peer review.

ATOM RSS1 RSS2