comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Formatted IO - Fortran style or similar.
Date: Tue, 31 Jul 2012 10:34:44 -0700 (PDT)
Date: 2012-07-31T10:34:44-07:00	[thread overview]
Message-ID: <d7002f8e-7ee1-411c-a198-a7dafcfc881d@googlegroups.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1207311704160.22686@medsec1.medien.uni-weimar.de>

On Tuesday, July 31, 2012 8:12:37 AM UTC-7, (unknown) wrote:
> On Tue, 31 Jul 2012, Jacob Sparre Andersen wrote:
> 
> 
> 
> > How would you handle translatable user visible strings - such as
> > "Parsing '${file_name}' failed on line ${line_number}." (where "${...}"
> > identifies parameter substitutions) - in Ada?
> 
> Why do you need to *substitute* the parameters in the string at all? 
> 
> Without substitution, the following seems to work fine:

It's not a question of what anyone "needs" or what "works".  Yes, this works, but I can understand why, for some people, it makes things more readable to have the string that represents what the output is going to look like all in once nice place, rather than split up into fragments with expressions in between.  I find that sometimes doing it that way is a bit more readable, although I don't have a strong preference.

In addition, having a "format" specified as a single entity, with something to indicate where other values will be substituted, makes it easier and cleaner to select between different formats--say you have a table of formats where each format pertains to a different error message but many of them have the same types of information substituted in, or a table where each format represents the same message but in a different language.  Representing a format as a string constant with some special characters in it isn't the only way to do this, but it's an easy way that is readable and produces good results if the substitution syntax is simple enough.

                       -- Adam
 


>   Ada.Text_IO.Put_Line("Parsing "         & File_Name &  
>                        " failed on line " & To_String(Line_Number) & 
>                        ".");
>
> Of course, you still have to write your  
> 
>   function To_String(Line_Number: Line_Number_Type) return String; 
> 
> ... or you just use Line_Number'Image. 



  reply	other threads:[~2012-08-07  6:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-30  8:50 Formatted IO - Fortran style or similar Mark Murray
2012-07-30  9:59 ` Ian Clifton
2012-07-30 18:57   ` Michael Rohan
2012-07-30 22:12   ` Mark Murray
2012-07-31  7:17     ` Dmitry A. Kazakov
     [not found]     ` <npbe18d3o3gdc2ut41f1codvv6rhfgidr3@invalid.netcom.com>
2012-07-31 11:56       ` Jacob Sparre Andersen
2012-07-31 15:12         ` stefan-lucks
2012-07-31 17:34           ` Adam Beneschan [this message]
2012-08-01  6:56             ` stefan-lucks
     [not found]           ` <be5g18p0gnf2ocdf3hmgjslgnu0jogrh91@invalid.netcom.com>
2012-08-01  6:48             ` stefan-lucks
2012-08-01  8:09           ` Jacob Sparre Andersen
2012-08-01 10:28             ` Georg Bauhaus
2012-08-01 16:28             ` Simon Wright
2012-08-01 19:14             ` Michael Rohan
replies disabled

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