* Unexpected language detail
@ 1998-11-26 0:00 James S. Rogers
0 siblings, 0 replies; only message in thread
From: James S. Rogers @ 1998-11-26 0:00 UTC (permalink / raw)
At work we were designing a generic bounded queue package
indexed by a modular type. One of our requirements for this queue
package is that it be able to correctly work with any modular type
as the index.
We encountered a problem when the queue contained a single
element. This condition occurs when someone instantiates the
package with a type defined as
type Index is mod 1;
Of course, the only valid value in this type is 0. The iterator for a
queue with this type cannot use arithmetic. You cannot add 1 to
the current value to get 0 because 1 is out of the range of the type.
The solution we found was to use the 'SUCC attribute for the index
type. This produced a correct iterator for all possible modular index
types.
Jim Rogers
Colorado Springs, Colorado
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-11-26 0:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-26 0:00 Unexpected language detail James S. Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox