comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: Generic Package
Date: Mon, 30 Apr 2007 12:30:29 +0200
Date: 2007-04-30T12:24:48+02:00	[thread overview]
Message-ID: <1177929029.6111.34.camel@localhost> (raw)
In-Reply-To: <1woad6hn9idy2$.6otnwphc1o0h$.dlg@40tude.net>

On Sun, 2007-04-29 at 10:19 +0200, Dmitry A. Kazakov wrote:

> > my containers would be providing iteration if they can do one of
> > 
> > - take a subprogram (e.g.) and call it for each of a collection
> >   of elements
> > 
> > - provide access to an element and then the next if any where the
> >   meaning of "next" is specified in the collection's contract 
> >
> > The amount of determinism need not be 100%. E.g., the post-condition
> > if Iterate that each element is visited once, in no particular order,
> > seems reasonable to me.
> 
> Consider the precondition of the code performed for each element. It is
> "here is an unvisited element" You can easily state it for the second case,
> because you have the iterator's value. For the former case you have a
> problem, because the precondition of the subprogram cannot be formulated
> and hence verified in any way. 

Iteration in For_Each is controlled by the iterator For_Each, hence
the iterator will make sure that the subprogram passed to For_Each
will see each element once; that's a condition entirely outside
the reach of my generic actual subprogram (or subprogram pointer).
But so what? That's desirable.
My subprogram can hardly be arranged to be called with an element
more than once by For_Each, or not at all (instantiation not
being recursive in Ada):
"your subprogram is called with each element once" is part of the
contract of For_Each.

So it is not a question of trusting the iterator but rather
a mere consequence of trust in the iterator being defined
as required by the specification of iterator.


> > Is there iteration in the following SETL expression?
> > 
> >   Result := { x : x in {1, 3, 24, 17, 11} | P(x) };
> 
> Iteration in what? In the language construct? In Result? Consider a
> possibility that Result were computed at compile time. Would it still be
> iteration?

That's the point, there is iteration in this set former, but it
happens behind the scene: on an AS-IF basis, it does not even matter
when (or even if) iteration is happening; all that counts is that
you can explain the meaning of the set former in terms of
iteration. In fact, IIRC, SETL does say that the elements
of {1, 3, 24, 17, 11} are picked in some order and checked
against P.

You build sets and you give estimates of O(f(n)) based on the little
that is know about how iteration is performed in set formers.





  parent reply	other threads:[~2007-04-30 10:30 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-25 22:15 Generic Package andrew.carroll
2007-04-26  0:07 ` Jeffrey R. Carter
2007-04-26  7:46   ` Markus E Leypold
2007-04-26  6:02 ` Martin Krischik
2007-04-26  7:57 ` Dmitry A. Kazakov
2007-04-26 15:31 ` andrew.carroll
2007-04-26 16:07   ` Georg Bauhaus
2007-04-26 19:40     ` andrew.carroll
2007-04-26 20:01       ` Georg Bauhaus
2007-04-26 18:54   ` Dmitry A. Kazakov
2007-04-26 21:52     ` Simon Wright
2007-04-27  9:00       ` Dmitry A. Kazakov
2007-04-27 11:11         ` Georg Bauhaus
2007-04-27 12:06           ` Dmitry A. Kazakov
2007-04-27 12:52             ` Markus E Leypold
2007-04-27 14:10             ` Georg Bauhaus
2007-04-27 14:16               ` Dmitry A. Kazakov
2007-04-27 21:44                 ` Georg Bauhaus
2007-04-28  7:38                   ` Dmitry A. Kazakov
2007-04-28 17:50                     ` Simon Wright
2007-04-28 21:04                     ` Ray Blaak
2007-04-29 16:33                       ` Markus E Leypold
2007-04-27 19:44             ` Simon Wright
2007-04-27 20:34               ` Dmitry A. Kazakov
2007-04-27 21:16                 ` Simon Wright
2007-04-28  7:36                   ` Dmitry A. Kazakov
2007-04-27 11:43         ` Markus E Leypold
2007-04-28 17:35           ` Dmitry A. Kazakov
2007-04-28 23:06             ` Georg Bauhaus
2007-04-29  8:19               ` Dmitry A. Kazakov
2007-04-29 15:10                 ` (see below)
2007-04-29 17:48                   ` Dmitry A. Kazakov
2007-04-29 22:36                     ` (see below)
2007-04-30  6:58                       ` Dmitry A. Kazakov
2007-04-30  9:59                         ` Markus E Leypold
2007-04-30 10:01                         ` Markus E Leypold
2007-04-30 10:36                         ` Georg Bauhaus
2007-04-30 10:40                           ` Georg Bauhaus
2007-04-30 12:14                           ` Dmitry A. Kazakov
2007-04-30 14:57                         ` (see below)
2007-04-30 10:30                 ` Georg Bauhaus [this message]
2007-04-30 12:16                   ` Dmitry A. Kazakov
2007-04-30 14:48                     ` Georg Bauhaus
2007-04-30 16:29                       ` Dmitry A. Kazakov
2007-04-30 17:24                         ` Georg Bauhaus
2007-04-30 18:54                           ` Dmitry A. Kazakov
2007-04-30 19:29                         ` Simon Wright
2007-04-30 20:04                           ` Dmitry A. Kazakov
2007-05-01  0:11                             ` Markus E Leypold
2007-05-01  9:02                             ` Georg Bauhaus
2007-05-01 10:19                               ` Dmitry A. Kazakov
2007-05-01 13:42                                 ` Georg Bauhaus
2007-05-01 17:16                                   ` Dmitry A. Kazakov
2007-05-01 19:14                                     ` Randy Brukardt
2007-05-01 20:14                                       ` Dmitry A. Kazakov
2007-05-02  7:52                                         ` Markus E Leypold
2007-05-02  8:06                                       ` Markus E Leypold
2007-05-03  0:37                                         ` Randy Brukardt
2007-05-03  8:36                                           ` Markus E Leypold
2007-05-03 23:16                                             ` Randy Brukardt
2007-05-04  0:15                                               ` Markus E Leypold
2007-05-01 21:41                                     ` Georg Bauhaus
2007-05-02  6:57                                       ` Ray Blaak
2007-05-02  8:22                                         ` Markus E Leypold
2007-05-02  8:07                                       ` Markus E Leypold
2007-05-02 10:29                                       ` Dmitry A. Kazakov
2007-05-02 11:48                                         ` Georg Bauhaus
2007-05-02 11:50                                           ` Georg Bauhaus
2007-05-02 13:12                                           ` Dmitry A. Kazakov
2007-05-02 14:21                                             ` Markus E Leypold
2007-05-03 18:27                                             ` Georg Bauhaus
2007-05-03 19:07                                               ` Dmitry A. Kazakov
2007-05-03 19:49                                                 ` Markus E Leypold
2007-04-29 16:26             ` Markus E Leypold
2007-04-26 21:50   ` Simon Wright
2007-04-27  4:45   ` Jeffrey R. Carter
2007-04-27  7:45     ` Martin Krischik
2007-04-27 22:54       ` Georg Bauhaus
2007-04-30 20:13         ` Matthew Heaney
2007-04-26 20:48 ` andrew.carroll
  -- strict thread matches above, loose matches on Subject: below --
2003-12-02 23:15 Mr. J.
2003-12-03  9:31 ` Dmitry A. Kazakov
2003-12-02 23:13 generic package Ratson Janiv
2003-12-03 17:39 ` Stephen Leake
replies disabled

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