From: "Rego, P." <pvrego@gmail.com>
Subject: Re: Return unconstrained types in ZFP
Date: Mon, 3 Dec 2012 17:15:18 -0800 (PST)
Date: 2012-12-03T17:15:18-08:00 [thread overview]
Message-ID: <b9667d70-97f9-47f9-9f4b-8f997e202c65@googlegroups.com> (raw)
In-Reply-To: <85boebuxtm.fsf@stephe-leake.org>
> Another alternative is to use a procedure:
> procedure Get
> (Port : in USART_Port_Type;
> Data : out String_U8;
> Data_Last : out Unsigned_8);
> Then the user must allocate space for Data:
> declare
> Data : String_U8 (1 .. Size);
> Data_Last : Unsigned_8;
> begin
> Get (Port, Data, Data_Last);
> ... use Data
> end;
> This way, you don't need to implement the runtime code.
> It is more of a burden for the user, but that's the point of ZFP; it's
> easier to implement, harder to use.
Stephe, you made a very good suggestion. So I don't need to implement the rt code, at least for now (I'm sure I will miss RAM if I do it now). Thanks!
> Is "Size" a maximum here, or is the result expected to be exactly Size
> bytes long?
At first I would put the Size to set the exact size of the output String_U8, but if the user allocate it first, it fits the idea well.
So, I used something like
procedure Get
(Port : in USART_Port_Type;
Data : out String_U8);
...
procedure Get
(Port : in USART_Port_Type;
Data : out String_U8) is
begin
for Index in 1 .. Data'Length loop
Data (Unsigned_8 (Index)) := Get (Port);
end loop;
exception
when others => null; -- no need for this now
end Get;
Thanks again Stephe, Rolf, Luke and Shark8.
next prev parent reply other threads:[~2012-12-04 1:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-02 2:38 Return unconstrained types in ZFP Rego, P.
2012-12-02 3:29 ` Shark8
2012-12-04 1:08 ` Rego, P.
2012-12-02 18:13 ` Luke A. Guest
2012-12-04 0:59 ` Rego, P.
2012-12-02 18:27 ` rrr.eee.27
2012-12-04 0:54 ` Rego, P.
2012-12-03 12:25 ` Stephen Leake
2012-12-04 1:15 ` Rego, P. [this message]
2012-12-04 8:40 ` Stephen Leake
2012-12-04 13:21 ` Britt
2012-12-05 3:34 ` Stephen Leake
2012-12-05 13:48 ` Britt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox