comp.lang.ada
 help / color / mirror / Atom feed
From: briot.emmanuel@gmail.com
Subject: Re: Traits and iterators (was: Mixing operators and dot notation)
Date: Wed, 8 Jun 2016 00:31:04 -0700 (PDT)
Date: 2016-06-08T00:31:04-07:00	[thread overview]
Message-ID: <7d9aaa87-1dd2-4432-a958-aaa98125a01f@googlegroups.com> (raw)
In-Reply-To: <nj6ati$nij$1@dont-email.me>

> generic
>     with package Elements is new Elements_Policy (<>);
>     type Container is private;
>     type Cursor is private;
>     with function First (Self : Container) return Cursor is <>;
>     with function Has_Element
>        (Self : Container; C : Cursor) return Boolean is <>;
>     with function Element (C : Cursor) return Elements.Element is <>;
>     with procedure Next (C : in out Cursor) is <>;
> package Forward_Cursors_Policy is
> end Forward_Cursors_Policy;
> 
> That, in itself, I don't think will give the ability to use "of" in 
> iterations, although it enables one to iterate over an unknown type.


Indeed, this signature package allows you to write an explicit iteration loop, where
you manipulate cursors explicitly. I don't know, and I don't think it is doable, how to
pass a formal type and mention that it should be iterable in the sense of the "for..of"
loop.
That means that any generic algorithm we write will take the above Policy package,
but will not be able to use "for..of". That's a bit more work to write, but just as
efficient in the end, but perhaps a limitation in the language.

  reply	other threads:[~2016-06-08  7:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 21:38 Mixing operators and dot notation Alejandro R. Mosteo
2016-06-02 21:42 ` Alejandro R. Mosteo
2016-06-02 22:28 ` Robert A Duff
2016-06-02 23:26   ` Randy Brukardt
2016-06-03 11:09     ` Alejandro R. Mosteo
2016-06-03 12:19       ` Dmitry A. Kazakov
2016-06-03 14:45       ` G.B.
2016-06-03 17:31       ` Shark8
2016-06-03 20:41         ` Alejandro R. Mosteo
2016-06-06  8:14           ` briot.emmanuel
2016-06-06 13:51             ` Alejandro R. Mosteo
2016-06-07 11:24             ` Traits and iterators (was: Mixing operators and dot notation) Alejandro R. Mosteo
2016-06-08  7:31               ` briot.emmanuel [this message]
2016-06-08 11:18                 ` Traits and iterators Alejandro R. Mosteo
2016-06-06  8:10       ` Mixing operators and dot notation briot.emmanuel
2016-06-06 13:58         ` Alejandro R. Mosteo
2016-06-02 23:05 ` Jeffrey R. Carter
replies disabled

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