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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cbb87dd49168c396 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-01 09:00:57 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!uunet!sea.uu.net!sac.uu.net!dfw.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Get_Line User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Fri, 1 Nov 2002 16:59:20 GMT Content-Type: text/plain; charset=us-ascii References: <3DBF3659.30709@acm.org> <4dRv9.46453$wm6.7691@nwrddc01.gnilink.net> <3DC0204E.4050203@acm.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30290 Date: 2002-11-01T16:59:20+00:00 List-Id: "Chad R. Meiners" writes: > "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. >... Does Ada.Text_IO's design cause angst among the general > Ada community? I don't think so. Well, maybe your students didn't have trouble. Maybe that means you're a good teacher. But I know I've seen *many* questions about Text_IO.Get_Line and related stuff on c.l.a. over the years. And this stuff *ought* to be simple -- I'm not surprised when a beginner is confused about discriminated tasks or something, but when folks are confused about how to read in a line of text, I think that indicates something wrong with the language. > > 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 ..." Sorry, I didn't mean to defame your character. I was just making an analogy between side-effects in character-stream-reading functions, and allocators, where for the latter we happily use function-call-like notation. > 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. OK, that convinces me that my analogy was poor. Still, the reason "Do_Something (Get_Line, Get_Line, Get_Line);" is wrong is that Ada does not define evaluation order. The mere *existence* of a Get_Line function should not cause people to write that. I actually think that Ada *should* define the evaluation order, precisely because the above example can cause bugs. Alternatively, the language should forbid such examples at compile time, rather than just giving wrong answers. I realize that Ada has no mechanism for having such compile-time checking, because the compiler doesn't know which global variables a given function reads and writes. - Bob