comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Design problem: generic package vs tagged subtype
Date: Thu, 01 Jul 2010 06:57:37 +0100
Date: 2010-07-01T06:57:37+01:00	[thread overview]
Message-ID: <m2oceryca6.fsf@pushface.org> (raw)
In-Reply-To: i0ggo1$1ejm$1@adenine.netfront.net

Marek Janukowicz <marek@janukowicz.net> 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 Columns which>
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_<type_name> 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);



  parent reply	other threads:[~2010-07-01  5:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-30 17:52 Design problem: generic package vs tagged subtype Marek Janukowicz
2010-06-30 19:23 ` Simon Wright
2010-06-30 22:33   ` Marek Janukowicz
2010-07-01  4:13     ` naming, was " tmoran
2010-07-01  9:49       ` J-P. Rosen
2010-07-01 15:48         ` Marcelo Coraça de Freitas
2010-07-01  5:57     ` Simon Wright [this message]
2010-07-01 18:30       ` Jeffrey R. Carter
2010-07-01 19:28         ` Simon Wright
2010-07-01 19:59           ` Jeffrey R. Carter
2010-07-01 21:14             ` Per Sandberg
2010-07-02  9:25         ` Stephen Leake
2010-07-02 10:50           ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox