comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Beginners question: Compound types, how-to?
Date: Wed, 03 Nov 2010 21:44:49 +0100
Date: 2010-11-03T21:44:49+01:00	[thread overview]
Message-ID: <op.vll3wz2eule2fv@garhos> (raw)
In-Reply-To: 4cd19583$0$6977$9b4e6d93@newsspool4.arcor-online.net

Le Wed, 03 Nov 2010 18:01:55 +0100, Georg Bauhaus  
<rm.dash-bauhaus@futureapps.de> a écrit:

> On 03.11.10 17:56, Warren wrote:
>
>> There is a good practical case for _Type, IMO. If Buffer_Type is defined
>> simply as Buffer, then we develop an inconvenient name clash:
>>
>>>     subtype Buffer is
>>>        System.Storage_Elements.Storage_Array (1..Buffer_Size);
>>
>> In use now:
>>
>> declare
>>    Buffer : Buffer;   -- hmmmm
>> begin
>
> What role does the object named Buffer play?
>
> It is a buffer, yes. Is it different from other buffers?
> How?  What lives in it?  How does the program use it?
>
> I believe answering these questions leads to a better name.

Please, read all, up to the end (I am not totally contracting what I reply  
to, that is all about covering all cases).

It may be any Buffer : it is variable, not a constant (the buffer is not  
the better example here, but let go on with here)

Practical view : this buffer may (let imagine) be used consecutively for  
different things, and the analysis may say this is OK to have one buffer  
because of use always comes after the other (and the buffer may be big so  
we have to declare only one, to reach some specifications).

Abstract view : a Buffer_Type defines something. Right ? Now, what is a  
variable declared of type Buffer ? It is what is defined by the type  
Buffer, right ? (if this would be something different, then language or  
the compiler is really broken). Then, if you've named Buffer as Buffer,  
how will you name a variable of the same type without more (see later for  
the more) ? Use a different name ? But if you use a different name,  
doesn't that mean the name of the type could be different or is ambiguous  
? The good word to say what the type is, will be the same to say what the  
variable is (but there is one difference, see later).

First part of my agreement : I fully agree with the point “what is special  
with that buffer ?”. Ex. you have two buffers, one for input, one for  
output : “Input_Buffer : Buffer; Output_Buffer : Buffer;”. That sounds  
natural, OK. But some other times this is not feasible, because the entity  
declared of the type is simply fully generic (you can give it a tricky  
name, which will not sound natural, as the natural word is the one of the  
type, or else, the type does not hold the good name or holds an ambiguous  
name).

About the more : think about an inventory machine in a library, it has a  
method named Run_Inventory, and inside this, a loop and a book variable.  
This book has nothing special at all, as it is by definition, to hold any  
what book you may imagine. This variable, here, is, simply what the Book  
type, is. So your question is indeed very good : what is different ? The  
answer : one is a type, the other is an instance  So how do you name it ?  
With a name which expose the difference
  Either Book_Instance and Book or
else Book and Book_Type or even, if you like it Book_Instance and  
Book_Type. Book_Instance is the place for different name : A_Book,  
Any_Book, Current_Book, etc. What ever, you will add to the instance name,  
something which you reject for the type name (paradox ?).


Sometime it is possible to get ride of _Type, but sometime it is not  
always, and this is not predictable, and your design should cover the  
“always” otherwise it will hold a bug. If you decide it for the user, this  
is not good : premature decision. You cannot assert the user will never  
define very generic instance of that type (and there are common, see later  
[*]).

Now, how much or what is the average occurrence of generic use instance ?  
I would say, many (near to third or half, my experience says), at least  
with function and procedure parameters (especially when there is a single  
parameter of the same type, which is a common case), iterators, persistent  
storage, streams, intermediate expression, temporary variables, an so on;  
or else, simply the role is indicated by the outer scope and this is  
redundancy to add a mark for it to the variable. About the latter, what  
about “Inventored_Book” or “Current_Book” in the loop of the above  
inventory machine ? Is it worth to repeat it every where ? Does it really  
offers something to the reader ? (think of it in context)


You idea is good, but it does not cover all the range, and you are right,  
sometime, but not all the time. If an entity does not have enough thing  
special, you are not to invent it just to name it (this would not be to  
design anymore), you are to name it for what it is (that is design). And  
what if this has nothing special or else what is special with it, is  
already expressed in the direct outer context or what it is attached to  
(case of records or subprogram parameters) ?


Another alternative for people who do not like _Type and feels hurt with  
it, could be to serve each type declaration, with a name to be used for  
instances-without special identity.

    type Book is private; -- Typical instance name: Set_Of_Written_Sheets.
                          -- Sorry, I do not know a good English synonym.
                          -- Note: some API do something a bit similar, when
                          -- they define common abbreviations for variables
                          -- of a type.


[*] When I read sources which does not use the “_Type” convention (or  
something similar, there are multiple choice, and either on the variable  
or on the type), including some part of the ARM, there are tricky names  
(which are disturbing for the reader) or hard game to find synonyms, which  
makes me wonder what the next will be (funny game) or if the type was  
really given the good name. That is funny in literature to play with  
multiple synonymous of a word or close-meaning words; but although I enjoy  
the concept of Literate Programming, computer language source is not  
literature (the expression Literate Programming is only partly related to  
literature), it is not the same kind of entertainment. When a name does  
not sound natural and like to play the “guess what next” game with you,  
this is not good for readability (the reader has some other priorities).


P.S. For reader of this news-group: this only applies to languages which  
are case insensitive, as as-you know, there is a common convention in  
language with case sensitivity, to use a capital letter (like natural  
language when it needs to distinguish proper names) which plays the same  
role as _Type here.


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.



  parent reply	other threads:[~2010-11-03 20:44 UTC|newest]

Thread overview: 190+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31 22:00 Beginners question: Compound types, how-to? Mart van de Wege
2010-10-31 22:36 ` Vinzent Hoefler
2010-10-31 23:27   ` Yannick Duchêne (Hibou57)
2010-11-01  7:14     ` Mart van de Wege
2010-11-01 19:22       ` Jeffrey Carter
2010-11-02  9:38     ` J-P. Rosen
2010-11-01  3:55 ` Jeffrey Carter
2010-11-01  7:12   ` Mart van de Wege
2010-11-01 15:04     ` Shark8
2010-11-01 17:06       ` Mart van de Wege
2010-11-01 17:39         ` Yannick Duchêne (Hibou57)
2010-11-01 17:58           ` Mart van de Wege
2010-11-01 19:19         ` Jeffrey Carter
2010-11-01 19:41           ` Yannick Duchêne (Hibou57)
2010-11-01 20:56             ` Jeffrey Carter
2010-11-01 21:05               ` Yannick Duchêne (Hibou57)
2010-11-03 16:56             ` Warren
2010-11-03 17:01               ` Georg Bauhaus
2010-11-03 17:42                 ` Vinzent Hoefler
2010-11-04  5:23                   ` Stephen Leake
2010-11-04  9:41                     ` Georg Bauhaus
2010-11-06 16:49                       ` Stephen Leake
2010-11-06 18:43                         ` Jeffrey Carter
2010-11-06 19:35                         ` Georg Bauhaus
2010-11-12 20:17                       ` Randy Brukardt
2010-11-12 21:25                         ` Jeffrey Carter
2010-11-04 10:09                     ` Georg Bauhaus
2010-11-06 16:53                       ` Stephen Leake
2010-11-06 19:24                         ` Georg Bauhaus
2010-11-04 17:46                     ` Jeffrey Carter
2010-11-03 20:38                 ` Warren
2010-11-03 20:50                   ` Yannick Duchêne (Hibou57)
2010-11-03 22:32                   ` Georg Bauhaus
2010-11-04 13:59                     ` Warren
2010-11-04 20:57                       ` Martin
2010-11-05 20:43                         ` Warren
2010-11-03 20:44                 ` Yannick Duchêne (Hibou57) [this message]
2010-11-03 20:45                   ` Yannick Duchêne (Hibou57)
2010-11-03 21:27                   ` Simon Wright
2010-11-03 22:44                   ` Georg Bauhaus
2010-11-04  1:19                     ` Yannick Duchêne (Hibou57)
2010-11-04  5:18                       ` Shark8
2010-11-04  6:30                         ` Yannick Duchêne (Hibou57)
2010-11-04 14:23                           ` Warren
2010-11-04 10:29                       ` Georg Bauhaus
2010-11-04 11:06                         ` Yannick Duchêne (Hibou57)
2010-11-04 12:56                           ` Georg Bauhaus
2010-11-01 19:59           ` Shark8
2010-11-01 20:43             ` Yannick Duchêne (Hibou57)
2010-11-01 21:54               ` Shark8
2010-11-01 21:01             ` Jeffrey Carter
2010-11-01 21:49               ` Shark8
2010-11-02  0:07           ` Adam Beneschan
2010-11-02  8:17           ` Stephen Leake
2010-11-02  8:29             ` Yannick Duchêne (Hibou57)
2010-11-02  8:50               ` Dmitry A. Kazakov
2010-11-03 12:02               ` Searching for "_Type" discussions Stephen Leake
2010-11-02 19:02             ` Beginners question: Compound types, how-to? Jeffrey Carter
2010-11-02 19:22               ` Yannick Duchêne (Hibou57)
2010-11-02 20:24                 ` Simon Wright
2010-11-03 12:14                   ` _Type vs no _Type Stephen Leake
2010-11-03 21:16                     ` Yannick Duchêne (Hibou57)
2010-11-03 21:19                       ` Yannick Duchêne (Hibou57)
2010-11-04  5:37                         ` Stephen Leake
2010-11-04  5:29                       ` Stephen Leake
2010-11-03 21:29                     ` Simon Wright
2010-11-04  5:28                       ` Nasser M. Abbasi
2010-11-04  6:06                         ` Yannick Duchêne (Hibou57)
2010-11-04  6:40                         ` Shark8
2010-11-05 17:49                           ` Florian Weimer
2010-11-05 18:18                             ` Georg Bauhaus
2010-11-04 18:29                         ` Britt Snodgrass
2010-11-04 19:08                           ` Nasser M. Abbasi
2010-11-04 19:47                             ` Britt Snodgrass
2010-11-04 19:59                             ` Simon Wright
2010-11-04 22:38                               ` Yannick Duchêne (Hibou57)
2010-11-05  7:05                               ` Florian Weimer
2010-11-05  8:48                                 ` Yannick Duchêne (Hibou57)
2010-11-05 16:01                                   ` Dmitry A. Kazakov
2010-11-05 19:26                                     ` Jeffrey Carter
2010-11-05 19:34                                       ` Dmitry A. Kazakov
2010-11-05 19:35                                       ` Florian Weimer
2010-11-05 20:08                                         ` Dmitry A. Kazakov
2010-11-05 20:14                                           ` Florian Weimer
2010-11-05 21:01                                             ` Dmitry A. Kazakov
2010-11-05 20:45                                         ` Warren
2010-11-05 22:59                                           ` Brian Drummond
2010-11-09 20:29                                             ` Warren
2010-11-05 21:37                                         ` Jeffrey Carter
2010-11-05  3:10                             ` Georg Bauhaus
2010-11-05  6:54                             ` J-P. Rosen
2010-11-05 16:39                               ` Robert A Duff
2010-11-05 23:32                                 ` J-P. Rosen
2010-11-06  0:55                                   ` Yannick Duchêne (Hibou57)
2010-11-06 13:40                                     ` Simon Wright
2010-11-05 17:29                             ` Robert A Duff
2010-11-05 19:28                               ` Jeffrey Carter
2010-11-05 23:09                                 ` Robert A Duff
2010-11-06  0:44                                   ` Jeffrey Carter
2010-11-06 21:10                                     ` Robert A Duff
2010-11-07  0:01                                       ` Brian Drummond
2010-11-07 20:41                                       ` Jeffrey Carter
2010-11-07 21:03                                         ` Yannick Duchêne (Hibou57)
2010-11-05  6:49                           ` J-P. Rosen
2010-11-05  7:05                           ` Florian Weimer
2010-11-05  7:20                             ` J-P. Rosen
2010-11-05 17:39                               ` Florian Weimer
2010-11-05 18:08                                 ` Georg Bauhaus
2010-11-05 23:36                                 ` J-P. Rosen
2010-11-06  1:05                                 ` Yannick Duchêne (Hibou57)
2010-11-05 10:58                             ` Georg Bauhaus
2010-11-05 16:31                               ` Dmitry A. Kazakov
2010-11-05 17:38                                 ` Georg Bauhaus
2010-11-05 17:31                               ` Florian Weimer
2010-11-05 18:02                                 ` Georg Bauhaus
2010-11-05 23:29                               ` J-P. Rosen
2010-11-06  0:00                                 ` Robert A Duff
2010-11-06  0:12                                   ` Simon Wright
2010-11-06 11:34                                   ` J-P. Rosen
2010-11-06  0:01                                 ` Georg Bauhaus
2010-11-09 20:43                             ` Warren
2010-11-05 17:24                         ` Robert A Duff
2010-11-05 20:05                           ` Vinzent Hoefler
2010-11-05 22:28                             ` Robert A Duff
2010-11-04 17:40                     ` Jeffrey Carter
2010-11-05 17:15                       ` Robert A Duff
2010-11-05 19:24                         ` Jeffrey Carter
2010-11-05 22:52                           ` Robert A Duff
2010-11-06  0:40                             ` Jeffrey Carter
2010-11-06  7:12                               ` Dmitry A. Kazakov
2010-11-06 10:13                                 ` Yannick Duchêne (Hibou57)
2010-11-06 11:00                                 ` Georg Bauhaus
2010-11-06 11:35                                   ` Dmitry A. Kazakov
2010-11-06 13:34                                     ` Simon Wright
2010-11-06 14:53                                       ` Dmitry A. Kazakov
2010-11-06 20:52                                   ` Shark8
2010-11-06 21:58                                     ` Yannick Duchêne (Hibou57)
2010-11-07  2:57                                       ` Shark8
2010-11-07  3:12                                         ` Yannick Duchêne (Hibou57)
2010-11-07  6:37                                         ` J-P. Rosen
2010-11-06 17:10                                 ` (see below)
2010-11-06 22:08                                   ` Niklas Holsti
2010-11-06 22:24                                     ` Yannick Duchêne (Hibou57)
2010-11-06  0:42                             ` Shark8
2010-11-06 13:24                               ` Robert A Duff
2010-11-06 21:20                                 ` Shark8
2010-11-06 22:12                                   ` Yannick Duchêne (Hibou57)
2010-11-16 20:33                                     ` Randy Brukardt
2010-11-06  1:33                             ` Yannick Duchêne (Hibou57)
2010-11-04 17:49                     ` Jeffrey Carter
2010-11-02 20:38                 ` Beginners question: Compound types, how-to? Jeffrey Carter
2010-11-02 20:59               ` Britt Snodgrass
2010-11-03  0:46                 ` Georg Bauhaus
2010-11-03  1:59                   ` Yannick Duchêne (Hibou57)
2010-11-03 12:59                     ` Georg Bauhaus
2010-11-03 15:28                       ` Georg Bauhaus
2010-11-03  8:58                   ` Dmitry A. Kazakov
2010-11-03 12:31                     ` Georg Bauhaus
2010-11-03 12:18                   ` Stephen Leake
2010-11-03 13:12                     ` Georg Bauhaus
2010-11-04  0:55                     ` Yannick Duchêne (Hibou57)
2010-11-03 17:35                   ` Vinzent Hoefler
2010-11-03 21:19                     ` Simon Wright
2010-11-03 21:31                       ` Vinzent Hoefler
2010-11-04  5:25                         ` Stephen Leake
2010-11-04 17:47                           ` Jeffrey Carter
2010-11-04  6:11                         ` Yannick Duchêne (Hibou57)
2010-11-04 19:30                           ` Vinzent Hoefler
2010-11-04 17:42                         ` Jeffrey Carter
2010-11-03 12:06               ` Stephen Leake
2010-11-04  1:04                 ` Yannick Duchêne (Hibou57)
2010-11-04 17:11                 ` Jeffrey Carter
2010-11-04 13:47               ` Peter C. Chapin
2010-11-04 14:30                 ` Warren
2010-11-01 17:24     ` Yannick Duchêne (Hibou57)
2010-11-01 21:31       ` Simon Wright
2010-11-01 19:05     ` Jeffrey Carter
2010-11-01 11:50   ` (see below)
2010-11-01 17:16     ` Yannick Duchêne (Hibou57)
2010-11-01 17:27       ` Georg Bauhaus
2010-11-01 17:41         ` Yannick Duchêne (Hibou57)
2010-11-01 17:55           ` Yannick Duchêne (Hibou57)
2010-11-01 18:12       ` Adam Beneschan
2010-11-01 19:25     ` Jeffrey Carter
2010-11-01 12:03 ` Brian Drummond
2010-11-01 12:17   ` Florian Weimer
2010-11-01 13:05   ` Mart van de Wege
2010-11-01 22:45     ` Brian Drummond
2010-11-01 23:17       ` Yannick Duchêne (Hibou57)
2010-11-02  8:32         ` Dmitry A. Kazakov
replies disabled

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