* Record comparision ?
@ 1998-06-04 0:00 Prateek S Fulzele
1998-06-03 0:00 ` Mark Fisher
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Prateek S Fulzele @ 1998-06-04 0:00 UTC (permalink / raw)
Hi everybody!
Here I have some doubts regarding record comparisions done in ADA.
Read this code sample:
type REC_TYPE;
type REC_PTR_TYPE is access REC_TYPE;
type REC_TYPE is
record
INT1 : INTEGER;
INT2 : INTEGER;
end record;
-- now I declare two variables of REC_PTR_TYPE
REC_PTR1, REC_PTR2 : REC_PTR_TYPE;
-- then, assign some values to the record members of
-- REC_PTR1, REC_PTR2.
....
-- now I say:
if REC_PTR1 < REC_PTR2 then
-- do so and so ..
end if;
What is this signify ?
Does it mean that REC_PTR1.INT1 < REC_PTR2.INT1 or else ?
Please clarify.
Thanks in advance!
Prateek
--
-------------------------------------------------------------------
Prateek S Fulzele
Telecom Development Center,
Digital Equipment India Ltd,
Bangalore
-------------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Record comparision ?
1998-06-04 0:00 Record comparision ? Prateek S Fulzele
@ 1998-06-03 0:00 ` Mark Fisher
1998-06-05 0:00 ` Niklas Holsti
1998-06-08 0:00 ` John English
2 siblings, 0 replies; 4+ messages in thread
From: Mark Fisher @ 1998-06-03 0:00 UTC (permalink / raw)
What your example actually does is compare the addresses of REC_PTR1
and REC_PTR2.
In order to compare the contents use
if REC_PTR1.all = REC_PTR2.all
then
.........
or refer to the components you wish to compare indiviudally.
Prateek S Fulzele <prateek@adca01.enet.dec.com> wrote in article
<3576214E.E7814E6B@adca01.enet.dec.com>...
> Hi everybody!
>
> Here I have some doubts regarding record comparisions done in ADA.
>
> Read this code sample:
>
> type REC_TYPE;
> type REC_PTR_TYPE is access REC_TYPE;
> type REC_TYPE is
> record
> INT1 : INTEGER;
> INT2 : INTEGER;
> end record;
>
> -- now I declare two variables of REC_PTR_TYPE
> REC_PTR1, REC_PTR2 : REC_PTR_TYPE;
>
> -- then, assign some values to the record members of
> -- REC_PTR1, REC_PTR2.
> ....
>
> -- now I say:
> if REC_PTR1 < REC_PTR2 then
> -- do so and so ..
> end if;
>
> What is this signify ?
> Does it mean that REC_PTR1.INT1 < REC_PTR2.INT1 or else ?
>
> Please clarify.
>
> Thanks in advance!
>
> Prateek
> --
> -------------------------------------------------------------------
> Prateek S Fulzele
> Telecom Development Center,
> Digital Equipment India Ltd,
> Bangalore
> -------------------------------------------------------------------
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Record comparision ?
1998-06-04 0:00 Record comparision ? Prateek S Fulzele
1998-06-03 0:00 ` Mark Fisher
@ 1998-06-05 0:00 ` Niklas Holsti
1998-06-08 0:00 ` John English
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Holsti @ 1998-06-05 0:00 UTC (permalink / raw)
Prateek S Fulzele wrote:
>
> Hi everybody!
>
> Here I have some doubts regarding record comparisions done in ADA.
>
> Read this code sample:
>
> type REC_TYPE;
> type REC_PTR_TYPE is access REC_TYPE;
> type REC_TYPE is
> record
> INT1 : INTEGER;
> INT2 : INTEGER;
> end record;
>
> -- now I declare two variables of REC_PTR_TYPE
> REC_PTR1, REC_PTR2 : REC_PTR_TYPE;
>
> -- then, assign some values to the record members of
> -- REC_PTR1, REC_PTR2.
> ....
>
> -- now I say:
> if REC_PTR1 < REC_PTR2 then
> -- do so and so ..
> end if;
>
> What is this signify ?
The ordering operators "<" etc. are not predefined for access types
such as REC_PTR_TYPE (nor for record types such as REC_TYPE),
therefore the above has no significance in Ada and any Ada compiler
should
reject it with an error message.
If you want to, you can define "<" for REC_PTR_TYPE or REC_TYPE to
have any meaning you like, by writing your own function with the profile
function "<" (Left, Right: REC_PTR_TYPE)
return boolean
or using REC_TYPE, respectively.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Record comparision ?
1998-06-04 0:00 Record comparision ? Prateek S Fulzele
1998-06-03 0:00 ` Mark Fisher
1998-06-05 0:00 ` Niklas Holsti
@ 1998-06-08 0:00 ` John English
2 siblings, 0 replies; 4+ messages in thread
From: John English @ 1998-06-08 0:00 UTC (permalink / raw)
Prateek S Fulzele (prateek@adca01.enet.dec.com) wrote:
: type REC_TYPE;
: type REC_PTR_TYPE is access REC_TYPE;
: type REC_TYPE is
: record
: INT1 : INTEGER;
: INT2 : INTEGER;
: end record;
: REC_PTR1, REC_PTR2 : REC_PTR_TYPE;
: if REC_PTR1 < REC_PTR2 then
This compares the access values (pointers). If you want to compare
the components, use Rec_Ptr1.Int1 < Rec_Ptr2.Int2, and if you want
to compare the complete records, use Rec_Ptr1.all < Rec_Ptr2.all
(but then you'll have to define your own "<" operator for Rec_Types,
as for Rec_Ptr_Type).
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-06-08 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-04 0:00 Record comparision ? Prateek S Fulzele
1998-06-03 0:00 ` Mark Fisher
1998-06-05 0:00 ` Niklas Holsti
1998-06-08 0:00 ` John English
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox