On Sun, Jun 17, 2012 at 10:45 AM, Florian Weimer <[email protected]> wrote:

> * Jonathan S. Shapiro:
>
> > I have been looking at SQLite lately, which is written in C. It
> implements
> > an unusual design pattern. The purpose of this pattern is to allow the
> > library to allocate structures of unknown concrete type (therefore
> unknown
> > size) on the stack.
>
> Ada has the same problem (for arrays and class-wide types).  Some time
> ago, GNAT on MIPS supported a special ABI where an allocating function
> could return with an elevated stack pointer.


My knowledge of Ada was never strong, and what there was has gone very
stale, but I don't see why this is necessary. If the number of elements in
the array is known from its type, then this is not necessary - the caller
can pre-allocate storage on the stack and the returning procedure can copy
the value[s] into the array at a suitable offset from the (known)
post-return stack pointer.

The only cases I can think of where what you say would be necessary are:

  1. Vectors (arrays of variable size) that are stack-allocated
  2. Procedures that are generic over array size in covariant position
     (e.g. at return types)

These are effectively the same thing. Does Ada permit either of these?

Different languages use different terms for arrays (known static size) and
vectors (dynamically sized), so my confusion may be simply a matter of
terminology.


Jonathan
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to