comp.lang.ada
 help / color / mirror / Atom feed
* Scope of vector
@ 2006-02-08  9:13 rashmi
  2006-02-08  9:42 ` Martin Dowie
  2006-02-08 10:59 ` Alex R. Mosteo
  0 siblings, 2 replies; 4+ messages in thread
From: rashmi @ 2006-02-08  9:13 UTC (permalink / raw)



dear all

I am repeatedly looking-up from and appending to a float vector as
shown below. I wish to lookup the new appended vector at the end of
each loop as shown below. But the visibilty of the new appended vector
is limited to the inner Decl-Begin-End block. So kindly help me solve
this problem.

I get the feeling that if visibility is possible then vector size
cannot be updated and vice versa.


for ... loop

_______________
|             |
|    decl.    |
|             |
        <-------- existing Vector is defined here (LI)
|             |
_______________
|             |
|    Begin    |
|             |
|       <-------- Vector to be appended will be got here (LU)
|             |
  __________
| |        |  |
| |  decl. |  |
| |    <--------- new appended Vector is defined here (LF:=LI+LU)
  __________
| |        |  |
| |  Begin |  |
| |        |  |
| |      <------- existing Vector is to be appended here (LF)
| |        |  |
| |  End   |  |
| |        |  |
  __________
|             |
|        <------- How do I lookup the new appended vector here ?
|             |
|    End      |
_______________

end loop;




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scope of vector
  2006-02-08  9:13 Scope of vector rashmi
@ 2006-02-08  9:42 ` Martin Dowie
  2006-02-08 10:59 ` Alex R. Mosteo
  1 sibling, 0 replies; 4+ messages in thread
From: Martin Dowie @ 2006-02-08  9:42 UTC (permalink / raw)


rashmi wrote:
[snip]
> end loop;

Sorry but you need to provide /way/ more information than that! Are you
trying to use the new Ada.Containers.* packages for this? Could you send a
/complete/ copy of the code or at least a compiling minimal subset of it?

Cheers

-- Martin





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scope of vector
  2006-02-08  9:13 Scope of vector rashmi
  2006-02-08  9:42 ` Martin Dowie
@ 2006-02-08 10:59 ` Alex R. Mosteo
  2006-02-08 13:28   ` Ludovic Brenta
  1 sibling, 1 reply; 4+ messages in thread
From: Alex R. Mosteo @ 2006-02-08 10:59 UTC (permalink / raw)


rashmi wrote:
> dear all
> 
> I am repeatedly looking-up from and appending to a float vector as
> shown below. I wish to lookup the new appended vector at the end of
> each loop as shown below. But the visibilty of the new appended vector
> is limited to the inner Decl-Begin-End block. So kindly help me solve
> this problem.
> 
> I get the feeling that if visibility is possible then vector size
> cannot be updated and vice versa.
> 
> 
> for ... loop
> 
> _______________
> |             |
> |    decl.    |
> |             |
>         <-------- existing Vector is defined here (LI)
> |             |
> _______________
> |             |
> |    Begin    |
> |             |
> |       <-------- Vector to be appended will be got here (LU)
> |             |
>   __________
> | |        |  |
> | |  decl. |  |
> | |    <--------- new appended Vector is defined here (LF:=LI+LU)
>   __________
> | |        |  |
> | |  Begin |  |
> | |        |  |
> | |      <------- existing Vector is to be appended here (LF)
> | |        |  |
> | |  End   |  |
> | |        |  |
>   __________
> |             |
> |        <------- How do I lookup the new appended vector here ?
 > |             |
 > |    End      |
 > _______________
 >
 > end loop;
 >

If I understand you correctly, you're attempting to reference a variable 
that is already out of scope. That's basically impossible. You should 
move your look-up inside the inner block.

declare
    LI : constant Float_Array := Some_Initializer;
begin
    declare
       LF : constant Float_Array := LI & Function_Giving_LU;
    begin
       --  Here you can use LF
    end;
    --  Here you can't use LF anymore, if you are asking that.
end;



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scope of vector
  2006-02-08 10:59 ` Alex R. Mosteo
@ 2006-02-08 13:28   ` Ludovic Brenta
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Brenta @ 2006-02-08 13:28 UTC (permalink / raw)


As Alex said, the precise answer to your question (if we
understand your question well) is: you can't access LF
outside of the inner block.

But you can store the appended array in a separate
constant, which you can assess thus:

declare
    LI : constant Float_Array := Some_Initializer;
    LU : constant Float_Array := Function_Giving_LU;
begin
    declare
       LF : constant Float_Array := LI & LU;
    begin
       --  Here you can use all of LI, LU and LF
    end;
    --  Here you can use LU if you want to, but not LF.
end;

-- 
Ludovic Brenta.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-02-08 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-08  9:13 Scope of vector rashmi
2006-02-08  9:42 ` Martin Dowie
2006-02-08 10:59 ` Alex R. Mosteo
2006-02-08 13:28   ` Ludovic Brenta

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