comp.lang.ada
 help / color / mirror / Atom feed
* container cursor type cannot be tagged
@ 2014-08-28 19:21 Stephen Leake
  2014-08-28 20:25 ` Randy Brukardt
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Leake @ 2014-08-28 19:21 UTC (permalink / raw)


In trying to build my own container package, I ran into a problem; the
Cursor type cannot be tagged. Which means we can't use "Cursor.op"
notation, which I've grown to really like.

The reason it can't be tagged is these two functions defined by
Ada.Iterator_Interfaces (and similar ones for reverse iteration):

   overriding function First (Object : Iterator) return Cursor;
   overriding function Next
     (Object   : Iterator;
      Position : Cursor)
     return Cursor;

Iterator is a tagged type, so Cursor can't be; Ada 2012 doesn't support
dispatching on multiple tagged types (LRM 3.9.3 12).

One solution to this is to define a new aspect Controlling_Type:

   overriding function First (Object : Iterator) return Cursor
   with Controlling_Type => Iterator;

which says to not use Cursor to dispatch calls to this subprogram. That
would be useful in other similar situations. I didn't find an AI on this
issue; would this be worth a proposal?

Another solution would be to provide another version of
Ada.Iterator_Interfaces, where Cursor is explicitly tagged, and these
functions use Cursor'Class. That seems more of a kludge.

-- 
-- Stephe


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-08-30 15:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-28 19:21 container cursor type cannot be tagged Stephen Leake
2014-08-28 20:25 ` Randy Brukardt
2014-08-29  7:28   ` Dmitry A. Kazakov
2014-08-29  7:59     ` J-P. Rosen
2014-08-29  8:46       ` Dmitry A. Kazakov
2014-08-29 23:08     ` Randy Brukardt
2014-08-29 14:50   ` Stephen Leake
2014-08-29 23:00     ` Randy Brukardt
2014-08-30 15:16       ` Stephen Leake

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