From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c31acc89d296bc62 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!news.netfront.net!not-for-mail From: Marek Janukowicz Newsgroups: comp.lang.ada Subject: Re: Design problem: generic package vs tagged subtype Followup-To: comp.lang.ada Date: Thu, 01 Jul 2010 00:33:40 +0200 Organization: Starware Message-ID: References: NNTP-Posting-Host: 89.174.12.152 Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: adenine.netfront.net 1277937218 47734 89.174.12.152 (30 Jun 2010 22:33:38 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Wed, 30 Jun 2010 22:33:38 +0000 (UTC) User-Agent: KNode/4.4.3 Xref: g2news1.google.com comp.lang.ada:12062 Date: 2010-07-01T00:33:40+02:00 List-Id: Simon Wright wrote: >> For Model I use a tagged type wrapped into generic package: >> generic >> Tbl_Name : String; >> type Attribute_Type is (<>); >> type Attribute_Type_Array is array (Attribute_Type range <>) of > > Does this have to be an unconstrained array? If it wasn't, you wouldn't > need to worry about whether Attribute_Types covered the range of > Attribute_Type. The only reason it was an unconstrained array is that my Ada skills are extremely poor and I didn't know it would work this way :) I'm a bit lost in this subject in general: could anyone tell me the exact difference between: - array (Attribute_Type) - array (Attribute_Type range <>) - array (Attribute_Type'Range) >> Attribute_Type_Type; >> Attribute_Types : Attribute_Type_Array; >> package Dar.Models.Base is >> >> type Model is abstract tagged limited record > > type Model is new Abstract_Base with ... > >> ... >> >> For associations I also use a generic package: >> generic >> with package Source_Model is new Dar.Models.Base(<>); >> with package Target_Model is new Dar.Models.Base(<>); >> Foreign_Key : String; >> package Dar.Models.Associations is >> function Find >> ... > > ... then the association can be between objects of type > Abstract_Base_Class'Class (though I don't see how you'd express the > actual relationship, not clear how Foreign_Key enters the picture). That's how I really have it implemented, didn't want to go that much into the details. Generally, I need to figure out what's really my problem here and then ask again :) >> 2. I have a type Attribute_Type_Type used to specify types of attributes >> (Integer, Date, String etc.). I then have a variant record: >> type Attribute_Value( Attr_Type : Attribute_Type_Type ) is >> record >> case Attr_Type is >> when Attr_Date => >> Date_Value : APQ_Date; >> when Attr_Time => >> Time_Value : APQ_Time; >> ... >> Is there any way to use builtin types here instead of Attr_Date, >> Attr_Integer, etc? Note that I need to specify type of each attribute in >> one array. > > I don't believe so. > > As a side note I really dislike the name Attribute_Type_Type. It seems > to me that what you've called Attribute_Type is much more like a Name > than a Type. Yeah, you might be right on that. I still need to find out what a good naming convention would be. I wouldn't like to use: type Attribute_Name_Type is (Id, Username, ...) but if I call the type Attribute_Name I'll have problems naming variables of that type (because Attribute_Name seems to be the best name for them as well). That's one of the things I dislike in Ada - everything (types, variables, packages, operations) follows exactly the same naming convention and doesn't use any special character/whatever to distinguish between them, so you run out of good names in no time... -- Marek Janukowicz --- news://freenews.netfront.net/ - complaints: news@netfront.net ---