comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Passing indefinite types
Date: Sun, 03 Feb 2013 17:26:15 -0500
Date: 2013-02-03T17:26:15-05:00	[thread overview]
Message-ID: <85ip696nlk.fsf@stephe-leake.org> (raw)
In-Reply-To: 5262a822-409a-4c79-a842-0e716527cb70@googlegroups.com

sbelmont700@gmail.com writes:

> Does anyone know of a slick way to pass several locally declared,
> indefinite types to a subprogram without resorting to the heap or
> Unchecked_Access? 

Could you show some almost legal code?

> An array of indefinite types is obviously not possible, an array of
> named access types is subject to accessibility problems, and wrapping
> the object in an 'accessor' (i.e. a null record with an access
> discriminant) turns right back into a problem of an array of
> indefinite types. I can always declare a procedure that takes a bunch
> of individual parameters, but this seems like a kludge, and doesn't
> solve the problem if the number of items might vary. It would be nice
> if there was some way to establish that a discriminated record is in
> fact a fixed size, 

Is it fixed, or does it vary? you point out several solutions for fixed.

> or perhaps if an array of anonymous access types had the same
> accessibility as access discriminants. 

I gather the subprogram you are calling is at library level, or at least
at a less deep accessibility level than the objects? While the local
objects are on the stack. 

How is the subprogram declared? If it takes several parameters each of
different indefinite type, then you are fine. If it takes a record of
indefinite types, then they all must be access types, and
Unchecked_Acess is ok, as long as the subprogram promises not to copy
the pointer.

I wonder if it would be possible to write an aspect or other constraint
that asserts "no pointers are copied"?

-- 
-- Stephe



  parent reply	other threads:[~2013-02-03 22:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-02 21:07 Passing indefinite types sbelmont700
2013-02-02 21:31 ` Jeffrey Carter
2013-02-03  0:27   ` sbelmont700
2013-02-03  8:07     ` Dmitry A. Kazakov
2013-02-03 10:22 ` gautier_niouzes
2013-02-03 22:26 ` Stephen Leake [this message]
2013-02-04  1:25   ` sbelmont700
2013-02-04  3:46     ` Shark8
2013-02-05  2:40     ` Randy Brukardt
2013-02-05 13:01     ` Stephen Leake
2013-02-05 20:56       ` Randy Brukardt
2013-02-05 21:16 ` sbelmont700
replies disabled

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