|
From: Sébastien Morand on 18 Jun 2008 04:55 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > We can't help you, because you haven't shown us the code for > SCMAL.Tools.Btrees, or even for the specified lines. > > Note that the ordered components of Ada.Containers have a similar data > structure underlying them. Too bad Ada.Containers doesn't follow the Ada > philosophy of providing basic building blocks that would make that data > structure available. > > Of course, Ada compilers have to have unbounded integer and real > packages, and the standard doesn't make them available, either. Actually you are right I could use B-Tree or dynamic structure using internal Ada library. But I'm still learning language and implementing a B-Tree is a good way to learn the language and in the same time, to review the algorithmic main topics (Stack, Queues, Linked List, Sort(s), Base64 encoding, etc.). Sebastien -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) iD8DBQFIWM2L+zV9xm4PlDQRAh86AJ9HVZF+YUccbJw+GPJ+lFyr6/lpqwCfWSLO OmFPkpEDXvnmQXylQ+CUKRo= =uXOI -----END PGP SIGNATURE-----
From: Brian Drummond on 18 Jun 2008 10:16 On Wed, 18 Jun 2008 08:41:31 +0000, S�bastien Morand <seb.morand(a)gmail.com> wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > > >> The problem is here. You instantiate TestGen with Order = 1. So the upper >> bound of Buffer is 2. Therefore the range is 1+2..Index, which should cause >> Constraint_Error in Buffer(I). > >I understand, if Order = 1, then the code could never occur. > >Anyway, There is a test just before in the real code that avoid the >impossible situation (index is between 1 and Order*2 always). (Newbie qiestion, coming from VHDL, halfway through the Barnes book) Can you not create a subtype of Positive to reflect that, and declare both the array and index using that subtype? - Brian
From: Sébastien Morand on 18 Jun 2008 10:32 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > (Newbie qiestion, coming from VHDL, halfway through the Barnes book) > > Can you not create a subtype of Positive to reflect that, and declare > both the array and index using that subtype? I can't create a subtype using a parameter. generic Order: Positive; package Test is -- Can't work since Order is not defined at compile time type MyType is range 1 .. Order; End Test; Sebastien -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) iD8DBQFIWRx8+zV9xm4PlDQRAlB6AJ9darSe1+aMBg1YbbUbilg8mZZ79wCdE/kY bF8Rs7+gGRERMktKnmwp080= =wYbq -----END PGP SIGNATURE-----
From: Ed Falis on 18 Jun 2008 10:39 Try: generic Order: Positive; package Test is subtype MyType is Positive range 1 .. Order; End Test; Subtype ranges based on Order are ok.
From: Dmitry A. Kazakov on 18 Jun 2008 10:42 On Wed, 18 Jun 2008 14:32:28 +0000, S�bastien Morand wrote: >> (Newbie qiestion, coming from VHDL, halfway through the Barnes book) >> >> Can you not create a subtype of Positive to reflect that, and declare >> both the array and index using that subtype? > > I can't create a subtype using a parameter. No, no, you mean a *type*. > generic > Order: Positive; > package Test is > -- Can't work since Order is not defined at compile time > type MyType is range 1 .. Order; This would be a type. But you do can create a subtype: subtype Index is range 1..Order; -- This is OK Subtypes can be dynamically constrained. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Question on initialization of packages Next: gnat GPL 2008 and annex E |