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, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,99e73f65ea2533b9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed.r-kom.de!news-nue1.dfn.de!news-lei1.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Sun, 7 Sep 2008 18:36:42 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> <57qdnfULQ9tzKCHVnZ2dnUVZ_tHinZ2d@comcast.com> <48bd0003$1@news.post.ch> <12prmxev8newf.lvc4m055okkb$.dlg@40tude.net> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1220801096 17733 141.54.178.228 (7 Sep 2008 15:24:56 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Sun, 7 Sep 2008 15:24:56 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Xref: g2news1.google.com comp.lang.ada:1954 Date: 2008-09-07T18:36:42+02:00 List-Id: On Fri, 5 Sep 2008, Robert A Duff wrote: > stefan-lucks@see-the.signature writes: > > > 3. I would be willing to pragmatically sacrifice mathematical purity for a > > shortcut rule: If A is false, the expression is false, whatever B does. > > If A raises an exception, of if A is true and B raises an exception, > > the exception is propagated. > > Some more questions about 3. Interesting questions! I like to point out, that I don't actually *propose* something, I just share some unfinished ideas. > Do you want to say that "and" is not a function (just like "and then" is > not a function)? Not quite! > So you can't pass "and" as a generic formal parameter, pass it as a > downward closure to an iterator, or rename it? I think, there are three options: 1. Differentiate between the control flow "and", and the Boolean function "and". The first has the shortcut property, the second doesn't. (This is the worst option, but it would be the easy one.) 2. Define the function "and" to operate over a type "Universal_Boolean", similarly to what Dmitry suggested in another posting. 3. Extend the syntax of Ada subprograms to allow teh specification of parameters in lazy evaluation mode. E.g., the function "and" could be specified as follows: "function and(A: in Boolean; B: lazy in Boolean) return Boolean; Note that A is in eager mode, B in lazy mode. My preferred option would be 3., followed by 2. One reason is that I would like to have lazy evaluation in Ada, anyway. > Or are you saying that if "and" is passed to a generic formal function > called Mumble, then Mumble gets this special property (of not evaluating > its second argument in some cases)? Assuming lazy evaluation in Ada, this would not be a "special property". And to pass the shortcut "and" to "Mumble", the first parameter of "mumble" must be of mode (eager) in, the second of mode lazy in. So there would be no surprise to the programmer. > Do you want that "and" on array-of-Boolean is no longer defined in terms > of "and" on each component pair? (There's no such thing as "and then" > on arrays.) Same question for modular "and". Or maybe just eliminate > these other "and" operators? For heaven's sake, no! > Do believe that "0 * F(X)" should return 0, even if F raises > an exception? Must return 0, or might return 0? Good question! Given lazy evaluation, we *could* implement "*" that way. But the exception could imply that F(X) is infinite, and "0*infinite" is undefined. So I don't think we *should* implement "*" that way. Except, perhaps, modular types. > I'm just trying to explore the consequences of this seemingly-simple > language design choice. It doesn't seem so simple to me. As I wrote before, I wouldn't even think of proposing such things without having a plausible idea how to implement such stuff. -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------