comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 10:26:24 +0200	[thread overview]
Message-ID: <s82i3g$el$1@dont-email.me> (raw)
In-Reply-To: <s82e2r$81l$1@dont-email.me>

Den 2021-05-19 kl. 09:17, skrev J-P. Rosen:
> Le 18/05/2021 à 22:39, Simon Wright a écrit :
>> so as well as the current ARM 13.13.2(4), for subtype S of type T
>>
>>     procedure S'Write(
>>        Stream : not null access Ada.Streams.Root_Stream_Type'Class;
>>        Item : in T)
>>
>> one could have for an object O
>>
>>     procedure O'Write(
>>        Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>>
>> but we don't, not even in Ada 202x.
> For what benefit? Saving a few keystrokes?
> 

The Integer'Image(An_Integer) changed to An_Integer'Image

the Verb(Object, Parameter) changed to Object.Verb(Parameter)


It does not have to save keystrokes, but it has to be more readable.
More readable is of course in the eye of the beholder.


package Coded_Values is

type WCS_Next_Location_Type_Type is (
   Reject_Position,
   Selection_Point,
   Transfer_Unit);

end Coded_Values;



with Coded_Values;
with Text_Io;

package Test is

   Next_Location : Coded_Values.WCS_Next_Location_Type_Type := 
Coded_Values.Selection_Point;


Given the above I do prefer


Text_IO.Put_Line ("Next is " & Next_Location'Image);

over

Text_IO.Put_Line ("Next is " & 
Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));


or when a use clause is in effect
Text_IO.Put_Line ("Next is " & 
WCS_Next_Location_Type_Type'Image(Next_Location));


even with a use clause I prefer the 'image on the variable.
In my eyes

Text_IO.Put_Line ("Next is " & Next_Location'Image);

Is the better and more readable choice.


That is likely the case of the analog stream discussion above.


Syntax matter. If Ada is to grow it has to have a pleasant syntax,
that is not perceived as clumsy or overly wordy.


-- 
Björn

  reply	other threads:[~2021-05-19  8:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 18:44 Better way to fill Storage_IO? Michael Hardeman
2021-05-17 19:14 ` Simon Wright
2021-05-17 19:23   ` Michael Hardeman
2021-05-18 20:39     ` Simon Wright
2021-05-19  6:24       ` Dmitry A. Kazakov
2021-05-19  7:17       ` J-P. Rosen
2021-05-19  8:26         ` Björn Lundin [this message]
2021-05-19 19:25           ` J-P. Rosen
2021-05-19 19:58             ` Dmitry A. Kazakov
2021-05-19 20:18             ` Björn Lundin
2021-05-20  5:38               ` Niklas Holsti
2021-05-20  6:50                 ` J-P. Rosen
2021-05-20 22:24                   ` Randy Brukardt
2021-05-19 15:39         ` Simon Wright
2021-05-17 20:20   ` Dmitry A. Kazakov
2021-05-17 20:48     ` Michael Hardeman
2021-05-18 14:00       ` Per Sandberg
2021-05-18  9:08     ` J-P. Rosen
2021-05-18 10:10       ` Jeffrey R. Carter
2021-05-18 16:50 ` Shark8
replies disabled

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