From: johnherro@aol.com (John Herro)
Subject: Re: Array Literals?
Date: 1996/08/14
Date: 1996-08-14T00:00:00+00:00 [thread overview]
Message-ID: <4utj7m$21o@newsbf02.news.aol.com> (raw)
In-Reply-To: 4uquru$jrq@Masala.CC.UH.EDU
cosc19z5@Bayou.UH.EDU (Spasmo) writes:
> What exactly is the difference between using
> Int_Array' ( ), and Int_Array ( )?
The ' with ( ) indicates *qualification*. That is, you're telling
the compiler what the type is, because, perhaps, it's not obvious from the
literal or the aggregate. The ( ) without the ' indicates *conversion*
from one type to another.
For example, suppose your Ada compiler implements type Long_Integer,
and you have
J : Integer;
procedure Display(Item : in Integer);
procedure Display(Item : in Long_Integer);
Then writing Display(3); is ambiguous, so you would *qualify* the literal
and write Display(Long_Integer'(3));. On the other hand, if you want to
*convert* J to Long_Integer, you use ( ) without the ' and write, for
example, Display(Long_Integer(J));
Sometimes you need to qualify an enumeration literal. This example
is from my Ada Tutor program (available for download at the Web and FTP
sites below my signature):
type Rainbow_Color is (Red, Orange, Yellow, Green, Blue, Indigo,
Violet);
type Traffic_Light Color is (Red, Amber, Green);
procedure Display(Item : in Rainbow_Color);
procedure Display(Item : in Traffic_Light_Color);
Now the compiler can handle Display(Violet); and Display(Amber);, but
requires the qualification in Display(Rainbow_Color'(Red));. I hope this
helps.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor
A doctor, a civil engineer, and a software engineer were arguing
about who has the oldest profession. The doctor said, "God made Eve from
the rib of Adam, a surgical operation." The civil engineer said, "Before
He did that, God made order from chaos and put the planets in motion, a
feat of civil engineering." The software engineer replied, "Wait a
minute! Where do you think the chaos came from?"
next prev parent reply other threads:[~1996-08-14 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-12 0:00 Array Literals? Spasmo
1996-08-13 0:00 ` John Herro
1996-08-13 0:00 ` Spasmo
1996-08-14 0:00 ` John Herro [this message]
1996-08-14 0:00 ` Robert I. Eachus
1996-08-13 0:00 ` Jon S Anthony
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox