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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6bf9d4ba0cfd8cb6 X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Announce: OpenToken 2.0 released Date: 2000/02/01 Message-ID: #1/1 X-Deja-AN: 580503637 Sender: hymie@calumny.jyacc.com References: <3890C62B.18309585@telepath.com> <876unj$jcs$1@nnrp1.deja.com> <87799k$aai1@news.cis.okstate.edu> X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 949439481 14476 209.49.126.226 (1 Feb 2000 21:11:21 GMT) Organization: PANIX Public Access Internet and UNIX, NYC NNTP-Posting-Date: 1 Feb 2000 21:11:21 GMT Newsgroups: comp.lang.ada Date: 2000-02-01T21:11:21+00:00 List-Id: Brian Rogoff writes: > (1) Exceptions: raise a Not_Found when input is exhausted. Some people > hate this because "Exceptions are only for error handling, not > control flow!". OCaml (and SML too I think) use exceptions for this, > and Ada sometimes does (try reading a file stream without using > File_Type...) I don't like this much. Exceptions are for error handling, not control flow :-) > (2) Provide a query on the sequence, like in Java, so you have code like > while Has_More_Elements(Seq) loop > Char := Get_Next_Element(Seq); > ... > end loop; > I find this very readable. Unfortunately, when it comes to input, it is impossible on most systems to divorce a test for end of input from the attempt to read the input. This is the classic Pascal file input problem that made I/O in that language so despised. > (3) Provide an option type like in (OCa|S)ML which wraps returned elements > and forces the reader to unwrap them, like this This is the integer/character thing dressed up in high-falutin' clothes. It probably adds more overhead than people would want. But it's a fine technique. I think the approach best suited for Ada is a procedure with two out parameters, a boolean for end-of-file, and a character for the data.