comp.lang.ada
 help / color / mirror / Atom feed
From: stefan-lucks@see-the.signature
Subject: Re: and then... (a curiosity)
Date: Sun, 7 Sep 2008 18:36:42 +0200
Date: 2008-09-07T18:36:42+02:00	[thread overview]
Message-ID: <Pine.LNX.4.64.0809071758170.2848@medsec1.medien.uni-weimar.de> (raw)
In-Reply-To: <wcc3akesmqw.fsf@shell01.TheWorld.com>

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!  ------




  parent reply	other threads:[~2008-09-07 16:36 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-29 21:06 and then... (a curiosity) mockturtle
2008-08-29 21:47 ` Samuel Tardieu
2008-08-30 21:28   ` Maciej Sobczak
2008-08-31  8:28     ` Georg Bauhaus
2008-08-31 23:21       ` Ray Blaak
2008-09-01  8:05     ` Martin Krischik
2008-09-01 17:56       ` Ray Blaak
2008-09-02  6:53         ` Martin Krischik
2008-09-02 14:56           ` Adam Beneschan
2008-09-02 16:28             ` Ray Blaak
2008-09-02 16:26           ` Ray Blaak
2008-09-02 20:50             ` Robert A Duff
2008-09-03 12:35               ` Brian Drummond
2008-09-03 15:56                 ` Robert A Duff
2008-09-04 22:09                   ` Brian Drummond
2008-09-03 21:01               ` Vinzent Hoefler
2008-09-02 14:50     ` Adam Beneschan
2008-08-29 22:28 ` Adam Beneschan
2008-08-30  1:06   ` Jeffrey R. Carter
2008-08-30 11:21   ` Dmitry A. Kazakov
2008-08-30 15:35     ` Peter C. Chapin
2008-09-02 15:06       ` Adam Beneschan
2008-09-02  3:41 ` Steve
2008-09-02  7:48   ` stefan-lucks
2008-09-02  8:57     ` Martin Krischik
2008-09-02 10:50       ` stefan-lucks
2008-09-02 10:33         ` Ludovic Brenta
2008-09-02 13:32           ` stefan-lucks
2008-09-02 12:53             ` Ludovic Brenta
2008-09-02 17:32               ` Georg Bauhaus
2008-09-03 13:14               ` stefan-lucks
2008-09-03 12:44                 ` Dmitry A. Kazakov
2008-09-02 13:39             ` stefan-lucks
2008-09-02 13:40             ` stefan-lucks
2008-09-02 16:48             ` Dmitry A. Kazakov
2008-09-02 17:00             ` Keith Thompson
2008-09-02 19:15               ` Simon Wright
2008-09-02 20:37               ` Robert A Duff
2008-09-02 20:58                 ` Jeffrey R. Carter
2008-09-02 21:08                   ` Robert A Duff
2008-09-03 12:24                     ` Pascal Obry
2008-09-02 22:34                   ` Santiago Urueña
2008-09-03  5:56                     ` Robert A Duff
2008-09-03  6:55                       ` Santiago Urueña
2008-09-03 14:14                       ` Adam Beneschan
2008-09-03  0:11                 ` Randy Brukardt
2008-09-02 17:20             ` Georg Bauhaus
2008-09-04  1:05         ` Stephen Leake
2008-09-04  6:45           ` stefan-lucks
2008-09-04  7:35             ` Dmitry A. Kazakov
2008-09-04 12:04               ` stefan-lucks
2008-09-04 13:00                 ` Dmitry A. Kazakov
2008-09-04 19:05                   ` stefan-lucks
2008-09-04 20:28                     ` Dmitry A. Kazakov
2008-09-05  6:57                       ` stefan-lucks
2008-09-05  6:34                         ` Ray Blaak
2008-09-05 14:14                     ` Robert A Duff
2008-09-05 15:04                       ` Dmitry A. Kazakov
2008-09-07 16:45                         ` stefan-lucks
2008-09-05 15:14                       ` Hyman Rosen
2008-09-05 15:59                         ` Adam Beneschan
2008-09-05 16:10                           ` Hyman Rosen
2008-09-07 16:36                       ` stefan-lucks [this message]
2008-09-07 16:08                         ` Gautier
2008-09-04  7:39             ` Karel Th�nissen
2008-09-04 12:12               ` stefan-lucks
2008-09-04 15:13                 ` Georg Bauhaus
2008-09-04 15:16                 ` Karel Th�nissen
2008-09-04 15:42                   ` Dmitry A. Kazakov
2008-09-04 19:27                   ` stefan-lucks
2008-09-04 19:43                     ` stefan-lucks
2008-09-04 19:40                       ` Georg Bauhaus
2008-09-05  7:00                         ` stefan-lucks
2008-09-05  6:35                           ` Ray Blaak
2008-09-04 20:06                       ` Karel Th�nissen
2008-09-05  7:44                         ` stefan-lucks
2008-09-05  6:41                           ` Vinzent Hoefler
2008-09-04 20:09                     ` Karel Th�nissen
2008-09-05  7:25                       ` stefan-lucks
2008-09-05  6:37                         ` Ray Blaak
2008-09-05  8:20                           ` stefan-lucks
2008-09-05 13:57                         ` Robert A Duff
2008-09-04 16:33                 ` Dmitry A. Kazakov
2008-09-04 19:31                   ` stefan-lucks
2008-09-04 19:59                     ` Karel Th�nissen
2008-09-05  7:27                       ` stefan-lucks
2008-09-05  8:38                         ` Ludovic Brenta
2008-09-04 20:17                     ` Dmitry A. Kazakov
2008-09-05 13:26                 ` Robert A Duff
2008-09-05 13:49                   ` Robert A Duff
2008-09-03  1:24     ` Stephen Leake
2008-09-03  3:31       ` tmoran
2008-09-03 13:22       ` stefan-lucks
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox