comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <nholsti@icon.fi>
Subject: Re: Generic package exporting a type with a rep spec
Date: 1998/05/14
Date: 1998-05-14T00:00:00+00:00	[thread overview]
Message-ID: <355B5569.EDBDF09B@icon.fi> (raw)
In-Reply-To: 6j9b0i$m2a$1@nnrp1.dejanews.com


"Bob Mikkelsen" <bobmik@access.digex.net> wrote:
>
> Is there any good way to construct a generic package which exports a data
> structure whose rep spec may vary on separate instantiations?
>
> We are trying to solve a problem where we have data coming in from various
> sources.  All the data requires similar processing when it gets to us, but
> when it is imported or exported to the sources, it may have slightly
> different forms: sometimes 7 bytes, sometimes 11.
>
> We are trying to generalize the representation of the data in the generic by
> bringing the data size into the generic with a generic formal parameter, but
> when we try to use this value in the rep spec, the complier gets very fussy
> (a static value is required).
>
> Any solution not requiring C will be welcomed.

Perhaps you could replace the "size" formal parameter with two generic
formal subprogram parameters, one to convert data from the external
form to the internal form, and the other to convert from internal form
to external form.

The generic would define the internal form without a rep spec; the user
who instantiates the generic would define an external form with the
particular rep spec needed, and provide the internal/external
converters.

I'm assuming that the structure of the type "exported" by the generic is
public, so that the user can write the conversion subprograms.




      reply	other threads:[~1998-05-14  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-11  0:00 Generic package exporting a type with a rep spec Bob Mikkelsen
1998-05-11  0:00 ` Matthew Heaney
1998-05-12  0:00 ` david.c.hoos.sr
1998-05-14  0:00   ` Niklas Holsti [this message]
replies disabled

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