comp.lang.ada
 help / color / mirror / Atom feed
From: rentmei@asterix.uni-muenster.de (Jahn Rentmeister)
Subject: Re: Ada can't initialize (aggregate) array of length 1?
Date: 13 Dec 1994 17:01:20 GMT
Date: 1994-12-13T17:01:20+00:00	[thread overview]
Message-ID: <3ckk10$1r0a@majestix.uni-muenster.de> (raw)
In-Reply-To: 3chh6i$lp7@cnj.digex.net

Gentle (gentle@cnj.digex.net) wrote:
: On Mon, 12 Dec 94 08:12:30 CET, Dirk Zoller (duz@roxi.rz.fht-mannheim.de) wrote:
: : Simplified I did this:

: :     type stone is array (1..2) of character;
: :     shapes: constant array (1..1) of stone := ("[]");
: :     ____________________________________________^

:   You're trying to squash a string of length 2 into a character space.
: Try initializing like this:

:   shapes: constant array (1..1) of stone := (1 => ('[',']'));

: Although type stone could have been declared as a subtype of STRING of
: length 2, then your initialization would have worked.

I don't think so. (Let's be careful, I did not check it in a reference,
either. But nevertheless, I'm just as sure as you were. :-)

The ""-literals are available for _all_ arrays of characters, not only for
the predefined type string. The ('[',']') aggregate is equivalent (as far as it
matters here) to the "[]" literal.

The reason why your code worked and the code of Dirk Zoller didn't was the
"1 =>". 

For an Ada compiler ("[]") does not look like an array aggregate: It's a
single string. Therefore one has to use named notation like in (1=>"[]") or
(others=>"[]"). The latter works only if the range "others" stands for is
known to the compiler. (in this case, it is).

Declaring stone to be a subtype of STRING would probably be helpful when doing
output, though.

: Too much of a good thing is WONDERFUL.
: 		-- Mae West
Me, too.
-Jahn



  parent reply	other threads:[~1994-12-13 17:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-12  7:12 Ada can't initialize (aggregate) array of length 1? Dirk Zoller
1994-12-12 12:54 ` Gentle
1994-12-12 18:35   ` Bob Duff
1994-12-13 17:01   ` Jahn Rentmeister [this message]
1994-12-14  3:23   ` Robert Dewar
1994-12-12 13:20 ` R. William Beckwith
1994-12-16 13:34   ` gamache
1994-12-14  3:21 ` Robert Dewar
1994-12-16 10:37   ` Dirk Zoller
1994-12-19 14:20     ` Robert Dewar
1994-12-16 16:41   ` Scott Leschke
1994-12-17 17:52     ` Robert Dewar
replies disabled

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