comp.lang.ada
 help / color / mirror / Atom feed
* Record comparison special case
@ 1999-12-03  0:00 keniwasa
  1999-12-05  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 4+ messages in thread
From: keniwasa @ 1999-12-03  0:00 UTC (permalink / raw)




I have a record made up of records in which only small parts (a few
fields) are usually significant.

The point is that I would like to compare two such records and determine
whether the parts that both records consider to be significant are the
same.  The easiest way I could see to handle this is to have an
"insignificant" value in every enumeration and have some "insignificant"
coding for real values, but that's not an option since the types cannot
be modified.

The records themselves that comprise my big record also cannot be
modified.

While I could have a boolean "significant" field associated with every
field of all my comprising records, it seems to me that there ought to
be a better way.

I'd like to store the 'Position and 'Size of the elements that I
consider significant into a queue which would be associated with a big
record, but I'm not exactly sure how I should go about doing the
comparison if I'm given only the big records and a list of 'Positions
and 'Sizes (other than having a huge case selection based on 'Position
which I would like to avoid).  I'm not even sure that 'Position will
give me the values I want as far as a direct bit comparison.

Thanks in advance,

Ken


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Record comparison special case
  1999-12-03  0:00 Record comparison special case keniwasa
@ 1999-12-05  0:00 ` Matthew Heaney
  1999-12-06  0:00   ` keniwasa
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Heaney @ 1999-12-05  0:00 UTC (permalink / raw)


In article <829bp3$oba$1@nnrp1.deja.com> , keniwasa@my-deja.com  wrote:

> I have a record made up of records in which only small parts (a few
> fields) are usually significant.
>
> The point is that I would like to compare two such records and determine
> whether the parts that both records consider to be significant are the
> same.  The easiest way I could see to handle this is to have an
> "insignificant" value in every enumeration and have some "insignificant"
> coding for real values, but that's not an option since the types cannot
> be modified.

What's wrong with simply redefining the equality operation of the record
type?

  type RT is tagged record ... end record;

  function "=" (L, R : RT) return Boolean;

Now you can implement "=" so that just the "small parts" of the L and R
records are compared.

--
Time and again the nation's courts have ruled that creationism, as a
religious dogma, cannot be taught in science classes. Now, creationists
are advancing a new tactic: eliminating the teaching of evolution and
other sciences that complement evolution, such as geology, paleontology,
and biological anthropology. By doing so, they are not only endangering
church-state separation but also seriously jeopardizing the science
education of future generations.

http://www.campusfreethought.org/sos/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Record comparison special case
  1999-12-05  0:00 ` Matthew Heaney
@ 1999-12-06  0:00   ` keniwasa
  1999-12-06  0:00     ` Matthew Heaney
  0 siblings, 1 reply; 4+ messages in thread
From: keniwasa @ 1999-12-06  0:00 UTC (permalink / raw)


In article <384a1027_2@news1.prserv.net>,
  "Matthew Heaney" <matthew_heaney@acm.org> wrote:
> In article <829bp3$oba$1@nnrp1.deja.com> , keniwasa@my-deja.com
wrote:
>
> > I have a record made up of records in which only small parts (a few
> > fields) are usually significant.
> >
> > The point is that I would like to compare two such records and
determine
> > whether the parts that both records consider to be significant are
the
> > same.  The easiest way I could see to handle this is to have an
> > "insignificant" value in every enumeration and have some
"insignificant"
> > coding for real values, but that's not an option since the types
cannot
> > be modified.
>
> What's wrong with simply redefining the equality operation of the
record
> type?
>
>   type RT is tagged record ... end record;
>
>   function "=" (L, R : RT) return Boolean;
>
> Now you can implement "=" so that just the "small parts" of the L and
R
> records are compared.

Is tagged part of Ada95?  I'm using Ada83.

The problem I had was that the "small parts" are not necessarily the
same for all records.  I also wanted to be able to merge records whose
"small parts" did not conflict and identify records whose "small
parts" did conflict.

>
> --
> Time and again the nation's courts have ruled that creationism, as a
> religious dogma, cannot be taught in science classes. Now,
creationists
> are advancing a new tactic: eliminating the teaching of evolution and
> other sciences that complement evolution, such as geology,
paleontology,
> and biological anthropology. By doing so, they are not only
endangering
> church-state separation but also seriously jeopardizing the science
> education of future generations.
>
> http://www.campusfreethought.org/sos/
>

Ken


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Record comparison special case
  1999-12-06  0:00   ` keniwasa
@ 1999-12-06  0:00     ` Matthew Heaney
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 1999-12-06  0:00 UTC (permalink / raw)


In article <82gqnl$k9c$1@nnrp1.deja.com> , keniwasa@my-deja.com  wrote:

> Is tagged part of Ada95?  I'm using Ada83.

You have to make it clear that you're using Ada83; otherwise, CLA
readers will assume you mean Ada95.

No, you don't need to say tagged; I just did that so predefined equality
wouldn't reemerge.

However, you can't declare your nonprivate record type as limited in
Ada83, and there's no simple way to override the equality operator for a
nonprivate nonlimited type (in Ada83).  You have to take advantage of a
loophole in the language, called the "Goodenough Trick."  See the Ada
FAQ for details.

<http://www.adahome.com/>


> The problem I had was that the "small parts" are not necessarily the
> same for all records.  I also wanted to be able to merge records whose
> "small parts" did not conflict and identify records whose "small
> parts" did conflict.

Simplest way (in Ada83) is to declare a comparison function:

  type T is <whatever>;

  function Is_Equal (L, R : T) return Boolean;

I don't really understand what you mean by "small parts being in
conflict."  Perhaps with more detail about your problem we can provide
more information.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-12-06  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-03  0:00 Record comparison special case keniwasa
1999-12-05  0:00 ` Matthew Heaney
1999-12-06  0:00   ` keniwasa
1999-12-06  0:00     ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox