comp.lang.ada
 help / color / mirror / Atom feed
* First and Next vs Has_Element
@ 2016-11-17 14:35 Victor Porton
  2016-11-17 21:43 ` Randy Brukardt
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Porton @ 2016-11-17 14:35 UTC (permalink / raw)


Why in "5.5.1 User-Defined Iterator Types" First and Next are regular 
routines but Has_Element is generic formal parameter?

-- 
Victor Porton - http://portonvictor.org


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

* Re: First and Next vs Has_Element
  2016-11-17 14:35 First and Next vs Has_Element Victor Porton
@ 2016-11-17 21:43 ` Randy Brukardt
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Brukardt @ 2016-11-17 21:43 UTC (permalink / raw)



"Victor Porton" <porton@narod.ru> wrote in message 
news:o0kf8e$pct$1@gioia.aioe.org...
> Why in "5.5.1 User-Defined Iterator Types" First and Next are regular
> routines but Has_Element is generic formal parameter?

Has_Element is strictly a function of the Cursor type (it serves the same 
purpose as comparing a pointer to null). First and Next are functions of the 
iterator - that is the state of the iterator can have an effect on their 
results. (Typically, in fact, the iterator will contain a reference to the 
container being iterated, so such state is necessary).

We could have included Has_Element in the interfaces, but that would have 
been artifical, as it should not reference the iterator state at all.

Note that there aren't any "regular routines" here; First and Next are 
abstract routines that have to be implemented by the type derived from the 
interface.

Also, as a practical matter, we wanted the Has_Element here to match the 
profile of the one in each of the container's packages. And those only take 
a cursor parameter.

                              Randy.


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

end of thread, other threads:[~2016-11-17 21:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 14:35 First and Next vs Has_Element Victor Porton
2016-11-17 21:43 ` Randy Brukardt

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