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: g2news2.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Design problem: generic package vs tagged subtype Date: Thu, 01 Jul 2010 06:57:37 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 1 Jul 2010 05:57:38 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="KCXegvZb5vh43D+f3BR6Ew"; logging-data="10843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TjVeWYADfkRG5uIBHAhmQx0WnTQOTUzY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:gP8nCw2G0vnx11bTpEiOZRNaiOI= sha1:JyTcz8Dq7d8Mm5L7abc5u72DLnU= Xref: g2news2.google.com comp.lang.ada:13044 Date: 2010-07-01T06:57:37+01:00 List-Id: Marek Janukowicz writes: > Simon Wright wrote: > I'm a bit lost in > this subject in general: could anyone tell me the exact difference between: > - array (Attribute_Type) This is an array indexed by the full range of the index type. > - array (Attribute_Type range <>) This is an array indexed by some contiguous subset of the full index type. If Attribute_Type was (A, B, C) any particular array could have no elements or elements (A), (B), (C), (A, B), (B, C), (A, B, C) .. but not elements (A, C). > - array (Attribute_Type'Range) This isn't allowed in a generic formal part. >> 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). Maybe inserting another concept would help? Tables have Attributes. If you have table names, why not column names? Could Column or perhaps Component be described by a record structure (name, kind, ...)? > 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... Kind and Sort can help, though (a) a bit English, maybe, (b) you'd still need some convention about which is the more abstract. Grady Booch used to use The_ for variables, which can get rather ugly. Use context -- I'd much rather write procedure Send (M : Message); than procedure Send (The_Message : Message); or, much worse, procedure Send (Message_To_Send : Message);