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: Brian Rogoff Subject: Re: Announce: OpenToken 2.0 released Date: 2000/02/01 Message-ID: #1/1 X-Deja-AN: 580543639 References: <3890C62B.18309585@telepath.com> <876unj$jcs$1@nnrp1.deja.com> <87799k$aai1@news.cis.okstate.edu> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 949443678 228 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-02-01T00:00:00+00:00 List-Id: On 1 Feb 2000, Hyman Rosen wrote: > 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 :-) De gustibus non est disputandum. I've gotten used to this technique, and lived to talk about it. > > (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. Exactly true, and as you say unfortunate too. > > (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. True, though the high falutin thing is more general and much less prone to error since it expresses the intent clearly. Its also easily expressible in C++ (your favorite language?) and other languages which have some form of parametric polymorphism and variant types. I suppose you can do it in Eiffel too but faking variants (tagged unions) with classes is an extra level of ugliness IMO. I prefer using exceptions here, but I bet most Ada programmers agree with you and would like a procedure with a two out params. -- Brian