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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-18 11:49:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed.stueberl.de!proxad.net!usenet-fr.net!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: Fri, 18 Jul 2003 13:48:31 -0500 Organization: ENST, France Message-ID: References: <1ec946d1.0307150715.4ba69f85@posting.google.com><3F149243.80304@attbi.com><3F15930C.2070907@attbi.com> NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1058554143 6779 137.194.161.2 (18 Jul 2003 18:49:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 18 Jul 2003 18:49:03 +0000 (UTC) To: "Robert Spooner" , Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:40483 Date: 2003-07-18T13:48:31-05:00 Interesting... It looks like a GNAT bug to me. With 3.15p, the message about line 8 occurs twice, apparently meaning that it couldn't decide on a call to Get_Line with or without an actual parameter. I say this, because without the default parameter declaration (i.e., always requiring a parameter, there is no ambiguity; Also, changing your conditional doce to the following also removes the ambiguity, as far as GNAT is concerned: if Last < Buffer'Last then return Buffer(1..Last); else declare Temp : String := Get_Line (2*Buffer_Size); begin return Buffer & Temp; end; end if; This should be reported to GNAT as a bug. ----- Original Message ----- From: "Robert Spooner" Newsgroups: comp.lang.ada To: Sent: Friday, July 18, 2003 1:04 PM Subject: Re: Computer Language Shootout > Robert A Duff wrote: > > "Jean-Pierre Rosen" writes: > > > > > >>This one reads a line with no length limit: > >> > >>function Get_Line return String is > >> Buffer : String (1..500); -- or whatever > >> Last : Natural; > >>begin > >> Get_Line (Buffer, Last); > >> if Last < Buffer'Last then > >> return Buffer (1..Last); > >> else > >> return Buffer & Get_Line; > >> end if; > >>end Get_Line; > >> > >>In most cases, there will be only one call, while having no upper limit. > >>The size of the buffer is just a matter of optimization. > > > > > > This is a nice trick, but I suggest you grow the buffer exponentially, > > in case lines are very long. Like, double it on each recursion level. > > > > Too bad this was not included in Text_IO itself. It would save > > beginners a lot of trouble. Sigh. > > > > - Bob > I tried this using the following program and gnat version 3.13p on > windows professional 2000 with the following result: > > with Ada.Text_IO; > > procedure No_String_Length_Limit_Test is > > package Tio renames Ada.Text_IO; > > > function Get_Line (Buffer_Size : Positive := 1) return String is > Buffer : String (1..Buffer_Size); > Last : Natural; > begin > Tio.Get_Line (Buffer, Last); > if Last < Buffer'Last then > return Buffer(1..Last); > else > return Buffer & Get_Line (2*Buffer_Size); > end if; > end Get_Line; > > > begin -- No_String_Length_Limit_Test > > loop > Tio.Put ("Enter a message, to exit: "); > declare > The_Message : String := Get_Line; > begin > exit when The_Message'Length = 0; > Tio.Put_Line ("The message is " & The_Message); > end; > end loop; > > end No_String_Length_Limit_Test; > > no_string_length_limit_test.adb:16:26: ambiguous operand for concatenation > no_string_length_limit_test.adb:16:26: possible interpretation at line 8 > Done--error detected. > > Can someone tell me why the operand is ambiguous? > > Bob > -- > Robert L. Spooner > Registered Professional Engineer > Associate Research Engineer > Intelligent Control Systems Department > > Applied Research Laboratory Phone: (814) 863-4120 > The Pennsylvania State University FAX: (814) 863-7841 > P. O. Box 30 > State College, PA 16804-0030 rls19@psu.edu > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >