comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Encapsulating Ada.Direct_IO
Date: Wed, 17 Nov 2010 23:32:19 +0100
Date: 2010-11-17T23:32:19+01:00	[thread overview]
Message-ID: <op.vmb575ccule2fv@garhos> (raw)
In-Reply-To: 5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com

Le Wed, 17 Nov 2010 05:44:49 +0100, Bryan <brobinson.eng@gmail.com> a  
écrit:
> Spec file:
> ...
> private
>   package Byte_IO is new Ada.Direct_IO(Character);
>   type File_Type is new Byte_IO.File_Type;
> end Big5_Text_IO;
> ======================
Why did you used a “type new” ? Unless you give some reason, subtype is  
better better here, as this avoid un-meaningful conversions every where.  
If the type was defined in the public part, the type-new would have make  
sense, but here it is defined in the private part, so no need to use  
type-new, unless you want to attach it some special invariants which are  
not part of the invariants of your Byte_IO.File_Type.

When you begin with Ada, you oftenly forget to make a good choice between  
type-new and subtype (probably because there is no such things with any  
other language). Always balance type-new and subtype and don't  
systematically use type-new all the way. Make choices with reasons.

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

“I am fluent in ASCII” [Warren 2010]



  parent reply	other threads:[~2010-11-17 22:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-17  4:44 Encapsulating Ada.Direct_IO Bryan
2010-11-17  5:20 ` Adam Beneschan
2010-11-26 15:31   ` Bryan
2010-11-17 12:25 ` Peter C. Chapin
2010-11-18  1:16   ` Randy Brukardt
2010-11-18  2:21     ` Peter C. Chapin
2010-11-18 16:36       ` Adam Beneschan
2010-11-18 18:21         ` Peter C. Chapin
2010-11-18 18:36           ` Randy Brukardt
2010-11-18 19:48           ` Adam Beneschan
2010-11-18 20:15             ` Dmitry A. Kazakov
2010-11-18  7:39     ` AdaMagica
2010-11-18 18:38       ` Randy Brukardt
2010-11-18  9:46     ` Maciej Sobczak
2010-11-18 16:31     ` Adam Beneschan
2010-11-18 17:05       ` Dmitry A. Kazakov
     [not found]         ` <ENidndoH8qoqjHvRnZ2dnUVZ_j-dnZ2d@earthlink.com>
2010-11-19  8:24           ` Dmitry A. Kazakov
2010-11-19 16:19             ` Adam Beneschan
2010-11-18 18:45       ` Randy Brukardt
2010-11-24 21:31     ` Warren
2010-11-17 22:32 ` Yannick Duchêne (Hibou57) [this message]
2010-11-17 23:03   ` Adam Beneschan
2010-11-17 23:11     ` Yannick Duchêne (Hibou57)
replies disabled

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