comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: pointers and genericity
Date: 16 Feb 2005 10:00:12 -0500
Date: 2005-02-16T10:00:12-05:00	[thread overview]
Message-ID: <wccsm3wo8hv.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 344d0fee.0502160127.432c8614@posting.google.com

xavier.serrand@free.fr (Xavier Serrand) writes:

> ==============Error messages for source file:
> test/test_gen_pk_user.adb
>     30.          U.Rec.Next := Proc_Suiv'access;
>                                |
>         >>> access type must not be outside generic body

If the access type is outside the generic body, then it's illegal
to take 'Access of a procedure declared inside the generic body.
The workaround is to declare the procedure in the generic
package spec.  If you don't want to export it, put it in
the private part.

I think the reason for this rule has something to do with making it
easier to implement code sharing of generic bodies.

I didn't look at your code carefully, but sometimes it's cleaner to use
a tagged type with a dispatching procedure, rather than an
access-to-procedure, because then you can easily package up
some data with the procedure.

- Bob



  parent reply	other threads:[~2005-02-16 15:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-15 12:10 pointers and genericity Xavier Serrand
2005-02-15 13:12 ` Dmitry A. Kazakov
2005-02-16  9:27   ` Xavier Serrand
2005-02-16  9:35     ` Martin Dowie
2005-02-16  9:53     ` Egil H. H�vik
2005-02-16 15:00     ` Robert A Duff [this message]
2005-02-17 22:50       ` Xavier Serrand
2005-02-17 23:11       ` Randy Brukardt
replies disabled

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