Re: Array of Strings



On Sep 23, 7:30 am, mockturtle <framefri...@xxxxxxxxx> wrote:
On Sep 23, 4:07 pm, jedivaughn <jedivaugh...@xxxxxxxxx> wrote:



If I wanted to make a package that made the array generic how would I
go about doing this. this is what I have which isn't working.

generic

type Element_Type is (<>);
type range1 is (<>);

package list is
type letters is private;

private
type letters is array (range1) of Element_Type;

end list;

and then in the main program I want

subtype range2 is integer range 1..25;
subtype str_length is string (1..25);

package List1 is new List(Element_Type => str_length, range1 =>
range2 );

when I try to compile the main program I get "expect discrete type in
instantiation of "Element_Type""

what am I doing wrong?

According to RM 12.5.2 "type Element_Type is (<>);" means that
Element_Type
is a discrete type. I guess that you want something like
"type Element_Type is private;" (I did not check)

Yes, that's right. When you declare a generic formal type (a "type"
declaration between the keyword "generic" and the beginning of the
package or procedure declaration), there are several ways to declare
the type, and the different ways control what sorts of types you can
use to instantiate the generic. Here's an incomplete rundown:

type T is private; -- T can be any nonlimited type except an
-- unconstrained type
type T(<>) is private; -- T can be any nonlimited type
type T is (<>); -- T must be discrete, i.e. integer or
-- enumeration
type T is range <>; -- T must be a signed (non-modular) integer
type
type T is mod <>; -- T must be a modular type
type T is digits <>; -- T must be a floating-point type
type T is delta <>; -- T must be a fixed-point type, not decimal
fixed
type T is delta <> digits <>; -- T must be a decimal fixed-point type

You can also declare formal array types, access types, and derived
types. Also, the "private" generic formal declarations can have
"tagged" and/or "limited" keywords applied. See the manual (12.5) for
more information.

-- Adam


.



Relevant Pages

  • Re: Array of Strings
    ... type letters is private; ... type letters is array of Element_Type; ... I presume you're doing this to learn about generics, since what you have here doesn't do anything worthwhile. ... There is also a way to define your component type as an array type: ...
    (comp.lang.ada)
  • Re: sharing variables and arrays in different comboboxes in a form
    ... If I declare a private array in the forms load or init method - can I use ... > Make the array a Form property or possibly a property of a combobox. ...
    (microsoft.public.fox.helpwanted)
  • Re: Passing an array of structuresfrom a pointer?
    ... to only declare structs in headers and then define the ... the struct should be declared ... what if you have a simple array like this: ... In the header we would declare? ...
    (microsoft.public.vc.language)
  • Re: Trigger CAPS LOCK ON When Wk Bk is Opened?
    ... Private Type OSVERSIONINFO ... Private Declare Function GetVersionEx Lib "kernel32" _ ... Public Sub CapsOn() ... Dim ScrollLockState As Boolean ...
    (microsoft.public.excel.programming)
  • Re: cant use udt in a class?
    ... Private Sub Command1_Click ... Another quirk is that you can declare Properties in a .BAS module, ... So you could actually expose functions from modules and hide the ... This would be essential when you went to exposing these modules in libraries ...
    (microsoft.public.vb.general.discussion)

Loading