From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Q: type ... is new String
Date: Mon, 04 Jun 2012 10:14:55 +0200
Date: 2012-06-04T10:14:55+02:00 [thread overview]
Message-ID: <op.wfdc65awule2fv@douda-yannick> (raw)
In-Reply-To: b66w8qwf7f7.150tb6yam2qgw.dlg@40tude.net
Le Mon, 04 Jun 2012 10:03:12 +0200, Dmitry A. Kazakov
<mailbox@dmitry-kazakov.de> a écrit:
> On Mon, 04 Jun 2012 09:48:07 +0200, Yannick Duchêne (Hibou57) wrote:
>
>> Le Mon, 04 Jun 2012 08:30:14 +0200, J-P. Rosen <rosen@adalog.fr> a
>> écrit:
>>
>>> Le 04/06/2012 07:58, Yannick Duchêne (Hibou57) a écrit :
>>>> Minimum_Length : constant := <platform dependent>;
>>>> Maximum_Length : constant := <platform dependent>;
>>>>
>>>> subtype Index_Type is Natural range Minimum_Length ..
>>>> Maximum_Length;
>>>>
>>>> type Path_Type is new String (Index_Type);
>>>> -- Unfortunately, this freeze the lower and upper bound, and the
>>>> -- declaration below fails.
>>>>
>>>> XYZ_Location : Path_Type := "..................."; -- Will fail.
>>> Why not:
>>> type Path_Type is array (Index_Type range <>) of Character;
>>>
>>> ?
>>> Reminder: There is nothing special to type String, you'll still have
>>> literals etc.
>>
>> Good idea. I did not consider this one, may be due to the natural
>> tendency
>> of deriving from an already existing type with similar meaning.
>
> It is not natural, it is sloppy. You (1) derive when the result type
> shall
> be in the same class [with class-wide objects]. You (2) clone or use
> other
> means to create an independent type when there shall be no class [no
> class-wide objects]. It is a conscious design choice between 1 and 2.
>
>> While I'm OK with this idea and feel it good, I would not apply it,
>> because I would prefer to derive from String. Ada lacks a way to narrow
>> the allowed range of a derived array type.
>
> subtype Punch_Card is String (1..80); -- ?
A path is intently a string is all platform I know, and that's not just a
representation trick. A punch card is not the same, and that would indeed
be an error to derive it from a string. You may find a file path in a text
file, you may not find a punch card in a text file. A string and a file's
path belongs to the same class.
--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
next prev parent reply other threads:[~2012-06-04 8:14 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-30 16:33 Q: type ... is new String tmoran
2012-05-30 17:04 ` Dmitry A. Kazakov
2012-05-31 7:37 ` Maciej Sobczak
2012-06-04 5:58 ` Yannick Duchêne (Hibou57)
2012-06-04 6:30 ` J-P. Rosen
2012-06-04 7:48 ` Yannick Duchêne (Hibou57)
2012-06-04 8:03 ` Dmitry A. Kazakov
2012-06-04 8:14 ` Yannick Duchêne (Hibou57) [this message]
2012-06-04 9:09 ` Dmitry A. Kazakov
2012-06-04 10:35 ` J-P. Rosen
2012-06-04 5:43 ` Yannick Duchêne (Hibou57)
2012-06-04 11:39 ` Brian Drummond
2012-06-04 13:36 ` Maciej Sobczak
2012-06-04 14:58 ` Georg Bauhaus
2012-06-04 15:14 ` Dmitry A. Kazakov
2012-06-04 16:06 ` Georg Bauhaus
2012-06-04 17:05 ` Dmitry A. Kazakov
2012-06-04 20:28 ` Yannick Duchêne (Hibou57)
2012-06-04 20:56 ` Georg Bauhaus
2012-06-05 7:32 ` Dmitry A. Kazakov
2012-06-05 8:40 ` Georg Bauhaus
2012-06-05 9:06 ` Dmitry A. Kazakov
2012-06-05 12:20 ` Georg Bauhaus
2012-06-05 13:14 ` Dmitry A. Kazakov
2012-06-06 4:09 ` Shark8
2012-06-06 8:52 ` Georg Bauhaus
2012-06-06 23:56 ` Randy Brukardt
2012-06-07 11:15 ` Georg Bauhaus
2012-06-06 23:51 ` Randy Brukardt
2012-06-04 20:33 ` Yannick Duchêne (Hibou57)
2012-06-04 21:27 ` Georg Bauhaus
[not found] ` <m9kqs7hgii13e220b1phm46n43d92tu1pj@invalid.netcom.com>
2012-06-05 6:15 ` Georg Bauhaus
2012-06-05 6:36 ` Yannick Duchêne (Hibou57)
2012-06-06 4:14 ` Shark8
2012-06-07 0:01 ` Randy Brukardt
2012-06-07 0:20 ` Adam Beneschan
2012-06-05 12:05 ` Brian Drummond
2012-06-05 14:43 ` Yannick Duchêne (Hibou57)
2012-06-04 15:54 ` Shark8
2012-06-04 22:01 ` Jeffrey Carter
2012-06-05 12:10 ` Brian Drummond
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox