comp.lang.ada
 help / color / mirror / Atom feed
From: kst@king.cts.com (Keith Thompson)
Subject: Re: GNAT Limitations?
Date: 1998/01/25
Date: 1998-01-25T00:00:00+00:00	[thread overview]
Message-ID: <885721317.973387@wagasa.cts.com> (raw)
In-Reply-To: 6aesm3$sr6$1@Masala.CC.UH.EDU


wanker@exploited.barmy.army wrote:
> On GNAT 3.09 (Win95) I find two problems that I can't find mentioned
> anywhere in the documentation:
> 	1) GNAT refuses to let me initialize a record with named
> 		fields if I don't initialize every field.  For
> 		example:
> 
> 		type X is
> 		    record
> 			A : Integer := 1;
> 			B : Integer := 2;
> 			C : Integer := 3;
> 		    end record;
> 
> 		A_Rec : X := (A => 5, C => 6);
> 
> 		Gives me an error with something like "No value
> 		provided for B".  However, according to the
> 		"C/C++ to Ada" Guide I am supposed to be able
> 		to do this.  What gives?

It sounds like the "C/C++ to Ada" guide is either wrong or unclear.  In a
subprogram call (which has similar syntax), you can omit some parameters
if they have default values.  You can't do the same for record aggregates.
(Being able to omit components with default initial values would be a
nice feature, by the way.)

> 	2) When I try to instantiate Ada.Unchecked_Deallocation,
> 		GNAT claims that Unchecked_Deallocation is not
> 		in Ada, which contradicts what's in the Language
> 		Referenec Manual and the "C/C++ to Ada Guide".
> 		Again, what gives?

Another poster incorrectly suggested removing "Ada." prefix; that
shouldn't make any difference.  Do you have a "with" clause for
Ada.Unchecked_Deallocation?  Are you sure you spelled it correctly?
Does the following compile?

   with Ada.Unchecked_Deallocation;
   package Foo is
      type Pointer is access Integer;
      procedure Free is new Ada.Unchecked_Deallocation(Integer, Pointer);
   end Foo;

If not, you may have a misconfigured library; post the exact error
message the compiler gives you.

> 	3) GNAT refuses to compile code where I try to find the
> 		range of a particular dimension of a multi-dimensional
> 		array.  I'm using the example in the C/C++ to
> 		Ada Guide:
> 
> 			-- Assuming Matrix is a 2d array type
> 			
> 			for I in Matrix(1)'Range loop
> 			    for J in Matrix(2)'Range loop
> 				Some_Op (Matrix (I, J));
> 		 	    end loop;
> 			end loop;
> 
> 		The compiler complains about using an attribute
> 		and indexing Matrix at the same time.  

If Matrix is a constrained 2d array type, you can use the 'Range
attribute on each of its dimensions, but your syntax is slightly off.
The range of the first dimension is Matrix'Range(1); the range of the
second dimension is Matrix'Range(2).

If Matrix is an unconstrained type (which is more likely), you'll need to
replace Matrix by the name of an object of type Matrix.  It's probably
clearer to do this even if Matrix is constrained.  And, of course,
you'll need to make the same change in Matrix (I, J).

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
San Diego, California, USA
Trying to keep my daily caffeine intake between the RDA and the LD50.




  reply	other threads:[~1998-01-25  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-25  0:00 GNAT Limitations? wanker
1998-01-25  0:00 ` Keith Thompson [this message]
1998-01-25  0:00   ` wanker
1998-01-26  0:00     ` Nick Roberts
1998-01-25  0:00 ` bklungle
1998-01-25  0:00   ` wanker
1998-01-26  0:00     ` Stephen Leake
1998-01-26  0:00       ` Nick Roberts
     [not found]     ` <EnECID.GyI@world.std.com>
     [not found]       ` <EnIJ7B.8CB@world.std.com>
1998-01-29  0:00         ` Nick Roberts
1998-01-29  0:00         ` bklungle
1998-02-18  0:00 ` Ed Colbert
     [not found] <6aesm3$sr6$1@masala.cc.uh.edu>
1998-01-25  0:00 ` wanker
replies disabled

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