From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,98adf46b4f219ef7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!17g2000prr.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Newbie question: Binary operator expected? Date: Fri, 13 May 2011 10:14:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <7aed288d-b5eb-428d-8a6a-0e7739e80c78@f15g2000pro.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1305306858 1262 127.0.0.1 (13 May 2011 17:14:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 May 2011 17:14:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 17g2000prr.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19251 Date: 2011-05-13T10:14:17-07:00 List-Id: On May 13, 9:05=A0am, Geoffrey Laval wrote: > Hi everybody, > I'm fairly new to Ada and I've tried different ways, even switching > from Bounded_Strings to standard strings, I don't know what I do > wrong! > > eightball.adb:8:60: binary operator expected > > Here is my source code: > > =A0 5 procedure eightball is > =A0 6 =A0 =A0 =A0 =A0 rep : integer range 1 .. 3; > =A0 7 =A0 =A0 =A0 =A0 touche : character; > =A0 8 =A0 =A0 =A0 =A0 package BS_Length is new > Generic_Bounded_Length(300'Length); > =A0 9 =A0 =A0 =A0 =A0 use BS_Length; > =A010 =A0 =A0 =A0 =A0 question : bounded_string; > =A011 =A0 =A0 =A0 =A0 question : To_Bounded_String; > =A012 =A0 =A0 =A0 =A0 subtype reponse is integer range 1 .. 3; > =A013 =A0 =A0 =A0 =A0 package reponseAlea is new > Ada.Numerics.Discrete_Random(reponse); > =A014 =A0 =A0 =A0 =A0 use reponseAlea; > =A015 =A0 =A0 =A0 =A0 G : Generator; > =A016 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 :=3D "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 =3D> 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