comp.lang.ada
 help / color / mirror / Atom feed
* GNAT error messages, strange generic construction
@ 1995-04-06  0:00 Anders H Johansson
  1995-04-07  0:00 ` Robert Dewar
  1995-04-07  0:00 ` Jan Kok
  0 siblings, 2 replies; 3+ messages in thread
From: Anders H Johansson @ 1995-04-06  0:00 UTC (permalink / raw)


Hi!

I'm compiling my Ada code with the GNAT 2.04 compiler. I've got
two questions:

1. I have got a compiler one-liner error message that I don't
   understand. If I want further information about this error,
   where can I get it? The message, if anyone's interested:
   "controlling argument is not dynamically tagged".

2. What's the point of this generic package construction (mentioned 
   e.g. in J.G.P Barnes "Programming in Ada", p. 447-448):

   with Generic_Elementary_Functions;
   with Generic_Complex_Numbers;
   generic
     with package Elementary_Functions is
       new Generic_Elementary_Functions(<>);
     with package Complex_Numbers is
       new Generic_Complex_Numbers(Elementary_Functions.Float_Type);
   package xxx is
   .
   .
I think it would be more reasonable to transform the generic package parameter
Complex_Numbers into an ordinary instantiation, placed inside the package
xxx. Since it is already decided how it will be instantiated, the genericity
fills no function?!

package xxx is
   package Complex_Numbers is
      new Generic_Complex_Numbers(Elementary_Functions.Float_Type);

---------
Tomas Lindh
erelih@ereyc.ext.ericsson.se





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

* Re: GNAT error messages, strange generic construction
  1995-04-06  0:00 GNAT error messages, strange generic construction Anders H Johansson
  1995-04-07  0:00 ` Robert Dewar
@ 1995-04-07  0:00 ` Jan Kok
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kok @ 1995-04-07  0:00 UTC (permalink / raw)


In article <3m10hi$eu0@nyheter.chalmers.se> m88asjn@mtek.chalmers.se (Anders H Johansson) writes:
>   ...
>
>2. What's the point of this generic package construction (mentioned 
>   e.g. in J.G.P Barnes "Programming in Ada", p. 447-448):
>
>   with Generic_Elementary_Functions;
>   with Generic_Complex_Numbers;
>   generic
>     with package Elementary_Functions is
>       new Generic_Elementary_Functions(<>);
>     with package Complex_Numbers is
>       new Generic_Complex_Numbers(Elementary_Functions.Float_Type);
>   package xxx is
>   .
>   .
>I think it would be more reasonable to transform the generic package parameter
>Complex_Numbers into an ordinary instantiation, placed inside the package
>xxx. Since it is already decided how it will be instantiated, the genericity
>fills no function?!
>
>package xxx is
>   package Complex_Numbers is
>      new Generic_Complex_Numbers(Elementary_Functions.Float_Type);
>
>---------

My short answer to this question is: it is a simple and legal way to
make sure that the user of xxx can use the same type (for complex numbers)
that the package xxx is using internally.

I can elaborate:
1. A possible reason that I will not discuss: as this is a text book,
   the example serves to illustrate some language features.

2. We may expect that a package (like xxx) that does complex arithmetic
   (through the instance Complex_Numbers) is used by someone who has
   complex_type data.
   a) If the instantiation of Generic_Complex_Numbers is made inside xxx,
      then the user could have obtained a type for his/her complex data
      through a separate instantiation of Generic_Complex_Numbers.
      The types will not be the same, so what can one do to make the
      external complex data available to xxx. Several solutions (component
      wise, for example) but not attractive.
   b) Or: xxx is providing a type Complex whose declaration is derived
      from the instance Complex_Numbers. If another package yyy is also
      using complex arithmetic, it will have to repeat the instantiation
      and also make a type yyy.Complex available. How does the user convert
      from xxx.Complex to yyy.Complex? Again not nice.
It is true that the user has to do the instantiation of
Generic_Complex_Numbers, but that is what gives the type Complex.

I prefer Barnes' design. This example does not allow a user-made package
for complex arithmetic to be imported in xxx, but that is fine with me.
-- 
 --Jan Kok                                  |    =#===-=========##=
 Mail: CWI (dpt. NW)                        |    --   ,___@
       P.O.Box 94079/NL-1090 GB Amsterdam   |  --   __/\
 E-mail: Jan.Kok@cwi.nl                     |      '   /_




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

* Re: GNAT error messages, strange generic construction
  1995-04-06  0:00 GNAT error messages, strange generic construction Anders H Johansson
@ 1995-04-07  0:00 ` Robert Dewar
  1995-04-07  0:00 ` Jan Kok
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1995-04-07  0:00 UTC (permalink / raw)


Tomas asks where to get information on GNAT error messages, and as usual
I post the reply so that more and more people are aware of it! Sorry agin
to those for whom this repeated for the Nth time.

Tomas, in the documentation for GNAT is one important line you missed,
namely the suggestion to send all questions, complaints etc to
gnat-report@cs.nyu.edu, where you will reach the gnat team.





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

end of thread, other threads:[~1995-04-07  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-04-06  0:00 GNAT error messages, strange generic construction Anders H Johansson
1995-04-07  0:00 ` Robert Dewar
1995-04-07  0:00 ` Jan Kok

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