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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cbb87dd49168c396 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-31 13:50:13 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!solaris.cc.vt.edu!news.vt.edu!msunews!not-for-mail From: "Chad R. Meiners" Newsgroups: comp.lang.ada Subject: Re: Get_Line Date: Thu, 31 Oct 2002 16:46:42 -0500 Organization: Michigan State University Message-ID: References: <3DBF3659.30709@acm.org> <4dRv9.46453$wm6.7691@nwrddc01.gnilink.net> <3DC0204E.4050203@acm.org> Reply-To: "Chad R. Meiners" NNTP-Posting-Host: arctic.cse.msu.edu X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Xref: archiver1.google.com comp.lang.ada:30270 Date: 2002-10-31T16:46:42-05:00 List-Id: "Robert A Duff" wrote in message news:wccd6prv3mk.fsf@shell01.TheWorld.com... > Why not, given that beginners have trouble with all that buffer > management? In fact, so do experts! I have never had trouble with Ada.Text_IO. It was rarely the cause of confusion with students I tutored in an introductory programming course. In fact when I began TA'ing for an introductory programming course that used c++, the students had more problems which were rooted in a misunderstanding of c++'s stream I/O operators. > How does one choose the correct buffer size? :-) Well you look at your problem requirements and derive a number that is suitable for most cases and deal with larger strings in a well defined manner. That sort of answer is something that is addressed in a second semester computer science course. :-) > Whether or not you like my Get_Line idea, surely you must admit that > beginners and experts are troubled by the current Text_IO interface. I am neither for or against using a Get_Line function. I have used similar functions myself in various cases. I will admit that people like to expect more from Ada.Text_IO then is reasonable. Ada.Text_IO could benefit from some extension, and perhaps a sister package that allows the character based I/O John English mention (although Stream_IO should do in a pinch). However I would not go so far as saying troubled. Does Ada.Text_IO's design cause angst among the general Ada community? I don't think so. > > Yes, given that that's the usual way in Ada to return an > arbitrary-length string. But this is a case where the side effect is of crucial importance! Warren's suggestion to build a Get_Line for Unbounded_Strings is a much better way to handle the side effect on the I/O buffer. > > Put_Line (Get_Line & Get_Line); -- Do you want to encourage this in the > > standard? > > I don't think a Get_Line function *encourages* that. I just want to > allow: > > X: constant String := Get_Line... > > ---- Yes it does, see below. > By the way, if you're phobic of side effects, why do we have "X := new > T;" (in Ada) instead of "new(X);" (as a statement in Pascal)? You do realize you are begging the question. For instance, if you wanted to defame my character a little more, you could have written, "By the way, if you've finished beating your dog, why do we have ..." > The "new" > clearly affects (or causes side-effects upon) the heap. > > Does this "encourage" things like "if new T = new T then.."? Commutative operators are a bad example. I am not against the use of side-effect when they don't lead to nasty surprises. It is obvious that the Get_Line function is the type a function where the side-effect leads to nasty surprises. Do_Something (new T, new T, new T); raises a mental alert, but Do_Something (Get_Line, Get_Line, Get_Line); does not. The horrible tragedy is that the first example is more likely to not depend on the order in which the parameters are allocated while the second example will very likely carry some dependence on the order the functions are called. -CRM