comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Textedit and txt
Date: Wed, 6 May 2015 16:23:35 -0500
Date: 2015-05-06T16:23:35-05:00	[thread overview]
Message-ID: <mie0on$39l$1@loke.gir.dk> (raw)
In-Reply-To: 51c639dd-a48c-4130-becd-750cb23094da@googlegroups.com

<brbarkstrom@gmail.com> wrote in message 
news:51c639dd-a48c-4130-becd-750cb23094da@googlegroups.com...
On Sunday, April 26, 2015 at 7:52:05 AM UTC-4, Laurent wrote:
>> Thanks for the hint. Why hide that in the preferences? Apple has 
>> sometimes strange ideas. Terminal an pico works too. Not really a fan of 
>> emacs/aquamacs. Tried once to learn mozart oz as language and they used 
>> emacs as ide. Didn't really work for me so I gave up.

>I'd suggest taking a look at the Reference Manual section on
>the Bounded_Strings package.  You can create a default Bounded_String
>length in a package (say named Common_Defs.ads) using
>
>  Std_Vstring_Length  : constant :=  256;
>  package VString     is new
>    Ada.Strings.Bounded.Generic_Bounded_Length(Std_Vstring_Length);

On top of this suggestion, I'd suggest defining the conversion operator (AKA 
unary plus) appropriately:

   function "+" (Right : VString.Bounded_String) return String renames 
VString.To_String;
   function "+" (Right : String) return VString.Bounded_String renames 
VString.To_Bounded_String;

Then you can write:

         Ada.Text_IO.Put_Line ("read code: "
                               & (+Temp_Record.Code_SIL));

instead of:

         Ada.Text_IO.Put_Line ("read code: "
                               & Codes.To_String (Temp_Record.Code_SIL));

Note that some people hate using "+" this way, because they think it has 
something to do with numerics. We really should have something non-specific 
(say an operator "#"), but the ARG is always split between people that think 
we already have such an operator ("+") and thus we don't need another one 
and those that are repulsed by using "+" this way. (Getting these put into 
the packages themselves failed for similar reasons. Grumble.)

In any case, I think Bounded_String and Unbounded_String are unusable 
without these definitions. So you either have to swallow "+" or forget the 
packages altogether. Neither is appealing. (I'd prefer a completely 
different design for both of these packages, so we could add some mechanism 
to allow direct conversions, but that's likely too radical.)

                                   Randy.


  reply	other threads:[~2015-05-06 21:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 21:40 Annoying behavior Laurent
2015-04-25  4:31 ` gautier_niouzes
2015-04-25  6:51   ` Laurent
2015-04-25  4:50 ` Niklas Holsti
2015-04-25  7:15   ` Laurent
2015-04-25  8:10     ` Niklas Holsti
2015-04-25 15:37       ` Laurent
2015-04-25 13:54 ` Stephen Leake
2015-04-25 15:46   ` Laurent
2015-04-25 17:02     ` Simon Wright
2015-04-25 17:41     ` Niklas Holsti
2015-04-25 18:58       ` Laurent
2015-04-25 19:30         ` Georg Bauhaus
2015-04-25 20:13           ` Laurent
2015-04-25 21:46             ` Laurent
2015-04-25 23:16           ` Bob Duff
2015-04-26 10:38     ` Jedi Tek'Unum
2015-04-26 11:52       ` Textedit and txt Laurent
2015-04-26 13:21         ` brbarkstrom
2015-05-06 21:23           ` Randy Brukardt [this message]
2015-05-07 21:12             ` Laurent
2015-05-07 21:48               ` Simon Wright
2015-05-07 22:24                 ` Laurent
2015-05-08  5:50                   ` Simon Wright
2015-05-08  7:35                     ` Laurent
2015-05-08 23:35               ` Randy Brukardt
2015-05-09 19:25                 ` Laurent
2015-05-09 21:36                   ` Anh Vo
2015-05-11 17:00                 ` Shark8
2015-05-11 17:49                   ` Dmitry A. Kazakov
2015-05-09 15:23               ` brbarkstrom
2015-05-12  1:10                 ` Randy Brukardt
2015-05-12 12:44                   ` brbarkstrom
2015-05-12 21:57                     ` Randy Brukardt
2015-05-13 12:07                       ` brbarkstrom
replies disabled

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