comp.lang.ada
 help / color / mirror / Atom feed
* Concatenation and Characters
@ 2002-10-10 14:50 Justin Birtwell
  2002-10-10 14:55 ` Preben Randhol
  0 siblings, 1 reply; 72+ messages in thread
From: Justin Birtwell @ 2002-10-10 14:50 UTC (permalink / raw)


Hi,

Another Newbie question.  I"m having trouble understanding concatenation in
Ada with its unbounded strings, and the difference between Character arrays
and String arrays.

If I concatenate two Bounded Strings

S:String(1..4):="ABCD";
T:String(1..2):="EF";
U:String(1..N);
Begin
    U(1..6):=S&T;     --Constraint Error!! Why?
or...
    U:=S&T;   ---Constraint Error!  Why?

    Put(U);
end;
Also If I have an array of Characters

Chars:array range(1..3) of Characters:=('a','b','c');

How can I convert it to a string?

Put(Chars) --Compile Error:Invalid param list!

I look forward to getting answers to these pesky problems.

Thanks as always,

Justin












^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: Concatenation and Characters
@ 2002-10-11  5:04 Grein, Christoph
  2002-10-11 10:30 ` Preben Randhol
  0 siblings, 1 reply; 72+ messages in thread
From: Grein, Christoph @ 2002-10-11  5:04 UTC (permalink / raw)


>    First_Name : String (1 .. 6) := "Preben";
>    Sirname    : String (1 .. 7) := "Randhol";
> 
>    -- Defining a String with fixed length
>    Full_Name : String (1 .. 14);
> 
>    Variable  : Unbounded_String;
> begin
>    
>    Full_Name := First_Name & " " & Sirname;

Preben, have you been raised to the peerage? But then your name is
Sir Preben 
:-)



^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: Concatenation and Characters
@ 2002-10-23  5:15 Grein, Christoph
  2002-10-23 13:19 ` Matthew Heaney
  0 siblings, 1 reply; 72+ messages in thread
From: Grein, Christoph @ 2002-10-23  5:15 UTC (permalink / raw)


> It really is a language design flaw that you can't have a zero-length
> positional aggregate.

with Ada.Text_IO;
use  Ada.Text_IO;

procedure Xxx is

  type Empty is range 1 .. 0;
  type Array_Type is array (Positive range <>) of Empty;

  function F return Array_Type is
  begin
    return (5 .. 4 => 0);
  end;

  Nothing: Array_Type := F;

begin

  Put_Line (Boolean'Image (Nothing = (7..4 => Empty'First)));
  Put_Line (Boolean'Image (Nothing = (0..-1 => Empty'Last)));

end Xxx;


try to run this. No value can fulfil the range constraint of Empty, but it does 
not matter, since the range is empty and the value is not evaluated.

(I'm not so sure that the range 0..-1 is legal, but my compiler accepts it and 
prints True twice, and I 
just do not feel like searching the RM :-(



^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: Concatenation and Characters
@ 2002-10-24  5:53 Grein, Christoph
  2002-10-24 14:04 ` Matthew Heaney
  0 siblings, 1 reply; 72+ messages in thread
From: Grein, Christoph @ 2002-10-24  5:53 UTC (permalink / raw)


> Many Ada83 programmers made the same mistake: assuming that there's an
> automatic check when indexing an array.  There was not, in Ada83.  There is
> now, in Ada95.

RM83 4.1.1(4)
... The exception CONSTRAINT_ERROR is raised if an index value does not belong 
to the range of the corresponding index of the prefixing array ...


A: array (Some_Range) of Something;

I: Some_Range;
J: Integer;

A (I) - the range check can be omitted
A (J) - the range check cannot be omitted if Some_Range is smaller than Integer



^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2002-10-24 14:13 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10 14:50 Concatenation and Characters Justin Birtwell
2002-10-10 14:55 ` Preben Randhol
2002-10-10 15:04   ` Justin Birtwell
2002-10-10 15:22     ` Preben Randhol
2002-10-10 15:30       ` Justin Birtwell
2002-10-10 16:05         ` Georg Bauhaus
2002-10-10 16:07         ` Preben Randhol
2002-10-10 17:45         ` Robert A Duff
2002-10-10 15:32       ` Justin Birtwell
2002-10-10 15:36         ` Preben Randhol
2002-10-10 16:44         ` Mark Biggar
2002-10-10 17:45           ` Stephen Leake
2002-10-10 21:53             ` Mark Biggar
2002-10-18 17:03           ` Programmer Dude
2002-10-18 18:13             ` Preben Randhol
2002-10-18 18:36             ` Wes Groleau
2002-10-21 15:16               ` Georg Bauhaus
2002-10-18 21:33             ` Mark Biggar
2002-10-20  2:01               ` Dmitry A.Kazakov
2002-10-21 14:13                 ` Wes Groleau
2002-10-21 15:22                   ` Dmitry A. Kazakov
2002-10-21 19:38                     ` Georg Bauhaus
2002-10-22 22:15                       ` Dmitry A.Kazakov
2002-10-22 12:05                         ` Georg Bauhaus
2002-10-22 12:19                           ` Lutz Donnerhacke
2002-10-22 14:43                             ` Georg Bauhaus
2002-10-23  8:39                           ` Dmitry A. Kazakov
2002-10-23 14:39                             ` Georg Bauhaus
2002-10-24  8:18                               ` Dmitry A. Kazakov
2002-10-21 16:50                   ` Warren W. Gay VE3WWG
2002-10-21 15:20             ` Georg Bauhaus
2002-10-21 17:51               ` Programmer Dude
2002-10-21 18:48                 ` Jim Rogers
2002-10-21 19:44                   ` tmoran
2002-10-21 20:42                   ` Programmer Dude
2002-10-22  1:42                     ` Jeffrey Carter
2002-10-22 14:37                       ` Robert A Duff
2002-10-22 18:51                         ` Jeffrey Carter
2002-10-23  7:01                         ` Pascal Obry
2002-10-22 14:45                       ` Matthew Heaney
2002-10-22 18:47                         ` Jeffrey Carter
2002-10-22 21:31                         ` Robert A Duff
     [not found]                         ` <3DB59D75.20609 <wccd6q29n3l.fsf@shell01.TheWorld.com>
2002-10-23  2:02                           ` Jeffrey Carter
2002-10-23 13:16                             ` Matthew Heaney
2002-10-23 19:11                               ` Jeffrey Carter
2002-10-23 15:24                             ` Robert A Duff
2002-10-23 19:24                               ` Jeffrey Carter
2002-10-24  0:33                                 ` Robert A Duff
2002-10-22  3:46                     ` Jim Rogers
2002-10-22 14:48                       ` Robert A Duff
2002-10-22 15:02                         ` Fraser Wilson
2002-10-22 15:38                           ` David C. Hoos
2002-10-22 15:44                             ` Fraser Wilson
2002-10-22 16:13                         ` Robert A Duff
2002-10-23  8:58                           ` Dmitry A. Kazakov
2002-10-23  9:08                             ` Lutz Donnerhacke
2002-10-23  9:34                               ` Dmitry A. Kazakov
2002-10-23 10:10                                 ` Lutz Donnerhacke
2002-10-23 17:15                                 ` Frank J. Lhota
2002-10-24  8:41                                   ` Dmitry A. Kazakov
2002-10-24  9:25                                   ` Fraser Wilson
2002-10-24 14:13                                     ` Matthew Heaney
     [not found]                         ` <un <wcc7kgazc20.fsf@shell01.TheWorld.com>
2002-10-22 16:46                           ` David C. Hoos
2002-10-22  8:51                   ` Stuart Palin
2002-10-22 18:56                     ` Programmer Dude
2002-10-21 19:42                 ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2002-10-11  5:04 Grein, Christoph
2002-10-11 10:30 ` Preben Randhol
2002-10-23  5:15 Grein, Christoph
2002-10-23 13:19 ` Matthew Heaney
2002-10-24  5:53 Grein, Christoph
2002-10-24 14:04 ` Matthew Heaney

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