comp.lang.ada
 help / color / mirror / Atom feed
From: Olivier Scalbert <olivier.scalbert@algosyn.com>
Subject: Re: newbie problem
Date: Wed, 13 May 2009 17:20:06 +0200
Date: 2009-05-13T17:20:06+02:00	[thread overview]
Message-ID: <4a0ae524$0$2849$ba620e4c@news.skynet.be> (raw)
In-Reply-To: <bdb1f77b-dff8-4c67-9322-cab13ae8808a@z7g2000vbh.googlegroups.com>

Martin wrote:
>> Problem 1: it does not compile !
>> adasound.ads:23:10: completion of nonlimited type cannot be limited
>> adasound.ads:23:10: component "File_Type" of type "Als_File_T" has
>> limited type
> 
> Store an 'access' to the limited type.
> 
>> Problem 2: how to avoid the first "with Sequential_Io;" ?
> 
> private with Ada.Sequential_IO;  -- I always prefer the
>                                  -- Ada. prefix just to be clear
>                                  -- it's a standard unit to any
>                                  -- 'casual' reader
> 
> Cheers
> -- Martin

Thanks Martin,

I have modified the specification and it compiles now:

private with Ada.Sequential_Io;

package adasound is

     type Amplitude_T is new Float;
     type Frequency_T is new Float;
     type Time_T      is new Float;

     type Stereo_Amplitude_T is record
         Left : Amplitude_T;
         Right: Amplitude_T;
     end record;

     type Als_File_T is private;

     function  Als_Create(File_Name: String) return Als_File_T;
     procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude: 
Stereo_Amplitude_T);
     procedure Als_Close(Als_File: Als_File_T);

private
     package Stereo_Amplitude_Io is new Ada.Sequential_Io 
(Stereo_Amplitude_T);

     type Als_File_T is record
         File_Type: access Stereo_Amplitude_Io.File_Type;
         -- perhaps more stuff later
     end record;

end adasound;


How can implement the Als_Create function ?
Here is my code, but it does not compile !

package body adasound is

function Als_Create(File_Name: String) return Als_File_T is
     Result : Als_File_T;
     File: Stereo_Amplitude_Io.File_Type; -- Error !!!
begin
     Stereo_Amplitude_Io.Create(File, Stereo_Amplitude_Io.Out_File, 
File_Name);
     Result.File_Type := File; -- Line 10 Error !!!
     return Result;
end Als_Create;
...

gcc-4.3 -c adasound.adb
adasound.adb:10:22: left hand of assignment must not be limited type


Olivier.







  reply	other threads:[~2009-05-13 15:20 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13 14:16 newbie problem Olivier Scalbert
2009-05-13 14:54 ` Martin
2009-05-13 15:20   ` Olivier Scalbert [this message]
2009-05-13 15:14 ` Adam Beneschan
2009-05-13 15:54   ` Olivier Scalbert
2009-05-13 15:44 ` Ludovic Brenta
2009-05-13 16:03   ` Olivier Scalbert
2009-05-13 18:00 ` Olivier Scalbert
2009-05-13 18:51   ` Martin
2009-05-13 19:45     ` sjw
2009-05-13 19:48     ` Olivier Scalbert
2009-05-14 19:41       ` sjw
2009-05-15  5:02         ` Olivier Scalbert
2009-05-15  8:05         ` Jean-Pierre Rosen
2009-05-18 10:23         ` Olivier Scalbert
2009-05-18 10:48           ` Martin
2009-05-18 10:54             ` Olivier Scalbert
2009-05-18 10:52           ` Ludovic Brenta
2009-05-18 11:09             ` Olivier Scalbert
2009-05-14 22:39       ` Jeffrey R. Carter
2009-05-14  2:59 ` anon
  -- strict thread matches above, loose matches on Subject: below --
1998-12-05  0:00 Graeme Wallace
1998-12-04  0:00 ` Simon Bracken
1998-12-04  0:00   ` Marin David Condic
1998-12-04  0:00 ` Marin David Condic
1998-12-04  0:00 ` David Botton
1998-12-04  0:00 ` Gautier.DeMontmollin
1998-12-04  0:00 ` Mats Weber
1998-12-05  0:00   ` Matthew Heaney
1998-12-05  0:00 ` Matthew Heaney
1998-12-07  0:00 ` Jeff Carter
replies disabled

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