comp.lang.ada
 help / color / mirror / Atom feed
* What's wrong with this picture?
@ 1988-10-21 12:57 Greg
  1988-10-24 13:58 ` Alan Kaminsky
  0 siblings, 1 reply; 4+ messages in thread
From: Greg @ 1988-10-21 12:57 UTC (permalink / raw)



What's wrong with this picture.  The below package Data does not compile.  
It looks fine to me, but there must be something I'm missing.  Does 
anyone see what I've overlooked.  The with'd source, Data package, error 
listing and generic are all listed below.

From my understanding, the LRM says the code is correct.   LRM section 
12.3.2(3) last statement, says:

  "(If, on the other hand, the formal type has no discriminants, the 
    actual type is allowed to have discriminants.)"

Thanks in advance for any help,


Greg Gicca
Sanders Associates
Nashua, N.H.
    
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
--Dynamic_String_Definition_.Ada
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
package Dynamic_String_Definition is

   type Dynamic_String(Maximum_Length : Positive) is
      record
         Value  : String(1..Maximum_Length);
         Length : Natural := 0;
      end record;

end Dynamic_String_Definition;
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
--Single_List_Utility_.Ada
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
generic
   type Element_Type is private;
package Single_List_Utility is

   type List_Type is private;

   .........

end Single_List_Utility;
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
--Data.Ada
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
with Single_List_Utility;
with Dynamic_String_Definition;
use  Dynamic_String_Definition;

package Data is new Single_List_Utility(Element_Type => 
   Dynamic_String(Maximum_Length => 132) );

--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
--Compiler.Errors
--:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Data     19-Oct-1988 13:31:50    VAX Ada V1.4-33                     Page   1
01       19-Oct-1988 13:22:31    DATA_.ADA;1                              (1)

    1 	with Single_List_Utility;
    2 	with Dynamic_String_Definition;
    3 	use  Dynamic_String_Definition;
    4 	
    5 	package Data is new Single_List_Utility(Element_Type => 
    6 	   Dynamic_String(Maximum_Length => 132) );
...........1.............2...............3
(3) A named association is not a form of expression [LRM 4.4(2)]
(2) A type conversion is not a form of name [LRM 4.1(2)]
(1)     For Dynamic_String the meaning is record type Dynamic_String in 
        Dynamic_String_Definition at line 3
(2) Error occurs in actual corresponding to generic formal type Element_Type 
        in Single_List_Utility at line 2
------------------------------------------------------------------------------

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

* Re: What's wrong with this picture?
  1988-10-21 12:57 What's wrong with this picture? Greg
@ 1988-10-24 13:58 ` Alan Kaminsky
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Kaminsky @ 1988-10-24 13:58 UTC (permalink / raw)


> What's wrong with this picture.  The below package Data does not compile.  
> It looks fine to me, but there must be something I'm missing.  Does 
> anyone see what I've overlooked.  The with'd source, Data package, error 
> listing and generic are all listed below.
> . . .
> --:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> --Data.Ada
> --:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> with Single_List_Utility;
> with Dynamic_String_Definition;
> use  Dynamic_String_Definition;
> 
> package Data is new Single_List_Utility(Element_Type => 
>    Dynamic_String(Maximum_Length => 132) );

Summarizing the original posting:  We are trying to instantiate a generic
package, Single_List_Utility, which has a single generic formal parameter,
Element_Type, that was declared to be a private type.  In the instantiation,
we are trying to match this generic formal parameter with an actual type,
Dynamic_String, that has a discriminant, Maximum_Length.  We are trying to
supply a value for the discriminant as we instantiate the generic package.
The goal is to instantiate a version of Single_List_Utility that works on
Dynamic_Strings of length 132.  The compiler does not like this generic
instantiation.

The problem is simply one of Ada syntax.  A generic_actual_parameter must
be a type_mark [ALRM 12.3] if the actual parameter is a data type.  A
type_mark must be a type_name or subtype_name [ALRM 3.3.2].  Thus, the
generic actual parameter must be simply a name, not a name followed by a
discriminant.

Here is how to get what we want:

	with Single_List_Utility;
	with Dynamic_String_Definition;
	use  Dynamic_String_Definition;
	
	subtype String_132 is Dynamic_String (Maximum_Length => 132);

	package Data is new Single_List_Utility
		(Element_Type => String_132);

-- 
Alan Kaminsky                           P. O. Box 9887
School of Computer Science              Rochester, NY  14623
Rochester Institute of Technology       716-475-5255
ark@cs.rit.edu

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

* What's wrong with this picture?
@ 1991-08-29 11:33 SAHARBAUGH
  0 siblings, 0 replies; 4+ messages in thread
From: SAHARBAUGH @ 1991-08-29 11:33 UTC (permalink / raw)


Is this a typo?
      I am preparing a critique of the Mosemann studies on Ada and C++
(unfortunately without seeing the text, just comments). 
sam harbaugh saharbaugh@ROO.FIT.EDU        
-----------

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

* Re: What's wrong with this picture?
@ 1991-08-30 17:07 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.e
  0 siblings, 0 replies; 4+ messages in thread
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.e @ 1991-08-30 17:07 UTC (permalink / raw)


In article <9108291135.AA06638@ajpo.sei.cmu.edu> SAHARBAUGH@ROO.FIT.EDU writes:
>Is this a typo?
>      I am preparing a critique of the Mosemann studies on Ada and C++
>(unfortunately without seeing the text, just comments). 
>sam harbaugh saharbaugh@ROO.FIT.EDU        
>-----------

I think he said what he meant Sam.  I think I'll critique his critique 
but, I'm far too busy to read it myself.  Besides the last few postings
to this newsgroup have given me enough ammunition!

Ken McCook

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

end of thread, other threads:[~1991-08-30 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1988-10-21 12:57 What's wrong with this picture? Greg
1988-10-24 13:58 ` Alan Kaminsky
  -- strict thread matches above, loose matches on Subject: below --
1991-08-29 11:33 SAHARBAUGH
1991-08-30 17:07 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.e

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