Re: Pascal program file parameter to Ada translation (Was: Re: Is GPC dead?)

Peter <[email protected]> Thu, 5 Jan 2017 17:04:31 +0000
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>
On 04/01/17 22:26, Kevan Hashemi wrote:

> 
> My main concern is whether I can implement the following dynamic
> allocation of memory space for graphs, images, and matrices.
> 
> type
>   graph_type(num_points:integer)=array [0..num_points-1] of real;
>   graph_ptr=^graph_type;
> var
>   xg:graph_ptr;
>   i:integer;
> begin
>   for i:=100 to 200 do begin
>     new(xg,i);
>     dispose(xg,i);
> end;
> 
> Here we are creating arrays of integers of increasing size and disposing
> of them. I started moving to FPC a few years back, only to find that
> this dynamic functionality is not available. 

Hi Kevan,

Dynamic arrays are available in FPC.
http://wiki.freepascal.org/Dynamic_array


I would have thought that your program stub above could be written for
FPC something like;-


program A;

type
  graph_type = array of real;

var
  xg:graph_type;
  i:integer;

begin
  for i:=100 to 200 do
  begin
    setlength(xg,i);
    xg := nil;
  end;
end.


Regards,
Peter


_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc