comp.lang.ada
 help / color / mirror / Atom feed
* HELP... Need QUICK answer on package
@ 1997-06-04  0:00 st-denis carole
       [not found] ` <01bc730c$d78439a0$84e2b8cd@p5120>
  0 siblings, 1 reply; 3+ messages in thread
From: st-denis carole @ 1997-06-04  0:00 UTC (permalink / raw)



Hello Guys,

I am a new ada programer and I am need to produce a package
very quickly. My problem is that I don't even know how to
do a Package. I am search in many books but I am still stuck at
the compiling process. You'll find my small program at the end of
this email. Could someone explain me why the compiler is complaining
about the first line and ask for the word "body". As I understood
a package must be build this way:

package MyPack is
   ...
end MyPack;
package body Mypack is
   ...
end MyPack;

And to use it:

with MyPack;
procedure CallMyPack is
begin
   MyPackFunction;
end;

So what's wrong with my program below.

Thanks you very much in advance!

My program:
--
package MyPackage is
	function MyPackageFunction(a:INTEGER;b:INTEGER) return INTEGER;
end MyPackage;
package body MyPack is
	function MyPackFunction(a:INTEGER;b:INTEGER) return Result is
		Result:INTEGER;
	begin
		Result := a+b;
		return Result;
	end MyPackFunction;
end MyPack;

with TEXT_IO;
procedure MyProcedure is
	package MY_INT_IO is new TEXT_IO.INTEGER_IO (INTEGER);
	use TEXT_IO,MY_INT_IO;
	use MyPack;
	somme:INTEGER;
begin
	PUT("La somme est egale a ");
	somme := MyPackFunction(1,2);
	PUT(somme);
	NEW_LINE;
end MyProcedure;




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

* Re: HELP... Need QUICK answer on package
       [not found] ` <01bc730c$d78439a0$84e2b8cd@p5120>
@ 1997-06-07  0:00   ` Robert Dewar
       [not found]     ` <01bc73c7$26ddfda0$33fd1fcc@p5120>
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Dewar @ 1997-06-07  0:00 UTC (permalink / raw)



bklungle says

<<What you supplied is a little confusing. The outline form on top does not
match the naming in the actual which follows. You also didn't say what
compiler you are using. However, with GNAT, the package spec, body, and
procedure must each be in separate files whose names match the
package/procedure name, and end in .ads for the spec and .adb for the
package body. You can't compile them in one file. Also, MyProcedure must
...


This is a common misconception. GNAT places no restrictions at all on the
names of source files. There is a default naming convention, but no requirement
that this default naming convention be used. The Source_File_Name pragma
and the -x switch to gcc provide completely general naming capabilities.





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

* Re: HELP... Need QUICK answer on package
       [not found]     ` <01bc73c7$26ddfda0$33fd1fcc@p5120>
@ 1997-06-08  0:00       ` Robert Dewar
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1997-06-08  0:00 UTC (permalink / raw)



bklungle says

<<What you say is true. However a beginner is very unlikely to be cognizant
of these esoterics. Very few other compilers have such switches hence they
are not obvious to someone just learning.
Sometimes you know too much and assume all others must also.
 >>


That is a good reason for not stating everything right away, it is NOT a good
reason for making false statements. You said that the name MUST match. This
is wrong and causes confusion. Instead you should say something like.
In normal default usage, it is most convenient if the name matches ....

So I am not saying that you have to make beginners cognizant of everything,
but the ability to use file names other than the default ones is by no means
"esoterics", it is easy to do, and many of our customers rely on this
capability.

On the other hand, I often run into people saying that one of the 
disadvantages of GNAT is that it requires fixed file names, and this
is false. That is why I think you should be careful not to make incorrect
statements.

Teaching always involves not revealing the whole truth right away, but as
far as possible it should avoid telling lies :-)

Robert Dewar
Ada Core Technologies





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

end of thread, other threads:[~1997-06-08  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-04  0:00 HELP... Need QUICK answer on package st-denis carole
     [not found] ` <01bc730c$d78439a0$84e2b8cd@p5120>
1997-06-07  0:00   ` Robert Dewar
     [not found]     ` <01bc73c7$26ddfda0$33fd1fcc@p5120>
1997-06-08  0:00       ` Robert Dewar

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