From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Traits and iterators
Date: Wed, 8 Jun 2016 13:18:41 +0200
Date: 2016-06-08T13:18:41+02:00 [thread overview]
Message-ID: <nj8uvp$a0g$1@dont-email.me> (raw)
In-Reply-To: <7d9aaa87-1dd2-4432-a958-aaa98125a01f@googlegroups.com>
On 08/06/16 09:31, briot.emmanuel@gmail.com wrote:
>> 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.
Thanks for the confirmation. Sometimes I miss interfaces for these
things in the language.
Álex.
next prev parent reply other threads:[~2016-06-08 11:18 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
2016-06-08 11:18 ` Alejandro R. Mosteo [this message]
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