comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Missing in Booch: range operations
Date: 09 Nov 2002 20:00:19 +0000
Date: 2002-11-09T20:00:19+00:00	[thread overview]
Message-ID: <x7vd6pe344s.fsf@smaug.pushface.org> (raw)
In-Reply-To: 3dcd4746$0$301$bed64819@news.gradwell.net

porton@ex-code.com (Victor Porton) writes:

> I don't understand what is "the STL/Charles view of iteration" and

I meant, the idea that two iterators designate a range within a
container over which some algorithm is to be applied.

> why you don't want add my code.

It would help if it compiled ..

> In the first letter I've written just a rough template (for both
> Booch and Charles) which is something like Booch, but not Booch.
> Now the code for Booch (not checked for errors!):
> 
> generic
>   For_Container: in out BC.Containers.Container'Class;
> package BC.Containers.Container_Instance is
>   Container: BC.Containers.Container'Class renames For_Container;
>   type Iterator is new BC.Containers.Iterator;
>   function New_Iterator return Iterator'Class;
> end;
> 
> generic
>   For_Container: in out BC.Containers.Container'Class;
> package body BC.Containers.Container_Instance is
>   function New_Iterator return Iterator'Class is
>   begin
>     return Iterator'Class(BC.Containers.New_Iterator(Container));
>   end;
> end;

The first 2 lines of the package body are clearly wrong.

This modified code nearly compiles:

   with BC.Containers;
   generic
      with package Containers_Base is new BC.Containers (<>);
      For_Container : in out Containers_Base.Container'Class;
   package BC.Containers.Container_Instance is
      Container : Containers_Base.Container'Class renames For_Container;
      type Iterator is new Containers_Base.Iterator with private;
      function New_Iterator return Iterator'Class;
   private
      type Iterator is new Containers_Base.Iterator with null record;
   end BC.Containers.Container_Instance;

   package body BC.Containers.Container_Instance is
      function New_Iterator return Iterator'Class is
      begin
         return Iterator'Class (Containers_Base.New_Iterator (Container));
      end;
   end BC.Containers.Container_Instance;

but fails with

   bc-containers-container_instance.ads:10:09: type must be declared
   abstract or "RESET" overridden

and when you think about it it's hard to see how this type Iterator
could be of any use (the concrete iterators in BCs are derived from
BC.Containers.Iterator, not from this new one).

I suppose it could contain a record with an actual iterator .. but
then that would have to be a Containers_Base.Iterator'Class, and we
know that won't work ..



  reply	other threads:[~2002-11-09 20:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-08 10:09 Missing in Booch: range operations Victor Porton
2002-11-08 15:01 ` Stephen Leake
2002-11-08 21:07 ` Matthew Heaney
2002-11-09 13:56   ` Simon Wright
2002-11-13 20:17     ` Matthew Heaney
2002-11-08 21:35 ` Matthew Heaney
2002-11-09  8:24 ` Victor Porton
2002-11-13 20:22   ` Matthew Heaney
2002-11-13 22:28     ` Stephen Leake
2002-11-09  8:46 ` Victor Porton
2002-11-09 14:12   ` Simon Wright
2002-11-09 14:04 ` Simon Wright
2002-11-09 16:12 ` Victor Porton
2002-11-09 20:00   ` Simon Wright [this message]
2002-11-11  5:41 ` Victor Porton
2002-11-11  6:39   ` Simon Wright
2002-11-11  7:50 ` Victor Porton
2002-11-13 20:26   ` Matthew Heaney
2002-11-13 22:28     ` 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