eightball.adb:8:60: binary operator expected
Here is my source code:
5 procedure eightball is
6 rep : integer range 1 .. 3;
7 touche : character;
8 package BS_Length is new
Generic_Bounded_Length(300'Length);
9 use BS_Length;
10 question : bounded_string;
11 question : To_Bounded_String;
12 subtype reponse is integer range 1 .. 3;
13 package reponseAlea is new
Ada.Numerics.Discrete_Random(reponse);
14 use reponseAlea;
15 G : Generator;
16 begin
I've changed it several times, and the error is still around the
length attribute. I think in the course of changing it, I even
worsened the wrongness of the code. I'm also confused as I've stumbled
upon different websites and everybody seems to have its own manner to
use strings. Some use these like I did and others do Sname :
bounded_string := "something"; so what is the right way?
I've tried to find out where I was wrong by searching about binary
operators, but it didn't worked out, so I thought I'd progress easier
on this if I asked here even if most questions asked are one level or
a thousand higher than mine. Also, the compiler I'm using is Gnat.
(Gnat is the compiler, right, and GPS the IDE?)
Thanks in advance,
Geoffrey Laval.
300'Length is not Ada syntax. 'Length is an attribute that you can
apply to an *array* or an *array type* to get its length. If A is a
one-dimensional array, A'Length is its length. But 300 isn't an
array, it's a number. If you want to specify *that* the length of
something is 300, this isn't the right syntax for that.
Generic_Bounded_Length(Max => 300) or just Generic_Bounded_Length(300)
will work.
If, on the other hand, you wanted to indicate the length of the
*movie* 300, the Ada language can't be expected to know that. (It's
117 minutes. I looked it up.)
-- Adam
Welcome!
> (Gnat is the compiler, right, and GPS the IDE?)
Yes and yes.
Adam already answered your other questions.
Personally, I think it is a bad idea to mix French identifiers with
English keywords. Even though I am French, the effort required to
switch languages on the fly distracts me from understanding of the
program text. With experience you will probably end up thinking the
same.
--
Ludovic Brenta.