comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Dowie <martin.dowie@btopenworld.com>
Subject: Re: expect procedure name in procedure call(newbie)
Date: Wed, 29 Dec 2004 12:32:09 +0000 (UTC)
Date: 2004-12-29T12:32:09+00:00	[thread overview]
Message-ID: <cqu849$8e1$1@sparta.btinternet.com> (raw)
In-Reply-To: <1104316623.493536.111460@f14g2000cwb.googlegroups.com>

R wrote:
> Hello.
> 
> I've got 'expect procedure name in procedure call' warning but
> I think my code is good
> Inside testclass.adb I have Create function and when I'm trying to call
> it from
> main.adb unit I receive that error.
> 
> Below are full codes of my Ada units.
> 
> And by the way - how can I dynamically allocate memory for e.g. 10
> elements(array of Floats)?
> How can I reallocate them to 20 elements or 4?
> How can I free the memory?

In Ada you don't need to play around with memory 
allocation/reallocation/deallocation as much in other lower level 
languages. If you know in advance the maximum number you are going to 
have then you could use a discriminated array, e.g.

    type Number_Of_Floats is range 0 .. 20;
    --  Never going to be more than 20.

    type Array_Of_Floats is array (Number_Of_Floats range <>) of Float;

    type Group_Of_Floats (Length : Number_Of_Floats := 0) is record
       F : Array_Of_Floats (1 .. Length);
    end record;

    My_Floats : Group_Of_Floats;
begin
    ...

If you really don't know the number of items you are going to have then 
use one of the many container libraries available - you wouldn't 
re-invent the wheel and re-code the STL if you were using C++ would you?

Here is a link to a page of such libraries:

http://www.adapower.com/index.php?Command=Class&ClassID=AdaLibs&Title=Ada+Libraries

Look under "Data Types".

Cheers

-- Martin



  parent reply	other threads:[~2004-12-29 12:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-29 10:37 expect procedure name in procedure call(newbie) R
2004-12-29 12:07 ` Florian Weimer
2004-12-29 13:03   ` R
2004-12-29 13:24     ` Mark Lorenzen
2004-12-29 12:32 ` Martin Dowie [this message]
2004-12-29 12:34   ` Martin Dowie
2004-12-29 18:46 ` Martin Krischik
replies disabled

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