comp.lang.ada
 help / color / mirror / Atom feed
* A question on function calls and defs.
@ 2001-03-08  2:30 mcdoobie
  2001-03-08  2:47 ` Larry Hazel
  2001-03-09  4:55 ` Jeffrey Carter
  0 siblings, 2 replies; 6+ messages in thread
From: mcdoobie @ 2001-03-08  2:30 UTC (permalink / raw)


Alright so I have this code that looks like this...

with Ada.Text_IO, Ada.Float_Text_IO;
use Ada.Text_IO, Ada.Float_Text_IO;

procedure simplemath is

begin
-- The rest of the code to the program would be here --

-- This is the section I have a question on --
if opt_is = 'V'
	then Put( Hi_prompt );
		Get( aHeight );
		the_volume := find_volume( aLength, aWidth, aHeight );  - Trouble here -
		NEW_LINE;
----- Cut to the Function itself -----

function find_volume( aLength, aWidth, aHeight : float ) return float is
	volume : float
	begin
		volume := aLength * aWidth * aHeight;
	return volume;
end find_volume;
end simplemath;

As you can probably tell, this is a pretty damn simple program. I'm
writing it just for practice with Ada95.

Now, the problem I'm having is that when I attempt to compile this code
it tells me that in my call to the "find_volume" function I have too many
arguments in the call. I'm not at all sure what that means. I'm searching
the compiler docs to find out, however a little insight would be
appreciated.

Now, at the function definition I'm getting the error that it's "not type
conformant" with my simplemath.ads file.(I did write an .ads file which I
used to generate a stub file which was then filled in with code. A really
nice touch to the language suite if you ask me. )
Now, I doubt anyone would want me to upload an entire .ads file to the
newsgroup( or would they?) however I'm assuming that the error message
itself is self-revealing to regular Ada programmers. Could someone point
me in the right direction on this one?

Should I upload the entire source to the newsgroup? Or would that be
considered rude?

Thanks in advance.

mcdoobie
mcdoobie@home.com



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

* Re: A question on function calls and defs.
  2001-03-08  2:30 A question on function calls and defs mcdoobie
@ 2001-03-08  2:47 ` Larry Hazel
  2001-03-08  2:55   ` mcdoobie
  2001-03-09  4:55 ` Jeffrey Carter
  1 sibling, 1 reply; 6+ messages in thread
From: Larry Hazel @ 2001-03-08  2:47 UTC (permalink / raw)


mcdoobie wrote:
> 
> Alright so I have this code that looks like this...
> 
> with Ada.Text_IO, Ada.Float_Text_IO;
> use Ada.Text_IO, Ada.Float_Text_IO;
> 
> procedure simplemath is
> 
> begin
> -- The rest of the code to the program would be here --
> 
> -- This is the section I have a question on --
> if opt_is = 'V'
>         then Put( Hi_prompt );
>                 Get( aHeight );
>                 the_volume := find_volume( aLength, aWidth, aHeight );  - Trouble here -
>                 NEW_LINE;
> ----- Cut to the Function itself -----
> 
> function find_volume( aLength, aWidth, aHeight : float ) return float is
>         volume : float
>         begin
>                 volume := aLength * aWidth * aHeight;
>         return volume;
> end find_volume;
> end simplemath;
> 
> As you can probably tell, this is a pretty damn simple program. I'm
> writing it just for practice with Ada95.
> 
> Now, the problem I'm having is that when I attempt to compile this code
> it tells me that in my call to the "find_volume" function I have too many
> arguments in the call. I'm not at all sure what that means. I'm searching
> the compiler docs to find out, however a little insight would be
> appreciated.
> 
> Now, at the function definition I'm getting the error that it's "not type
> conformant" with my simplemath.ads file.(I did write an .ads file which I
> used to generate a stub file which was then filled in with code. A really
> nice touch to the language suite if you ask me. )
> Now, I doubt anyone would want me to upload an entire .ads file to the
> newsgroup( or would they?) however I'm assuming that the error message
> itself is self-revealing to regular Ada programmers. Could someone point
> me in the right direction on this one?
> 
> Should I upload the entire source to the newsgroup? Or would that be
> considered rude?
> 
> Thanks in advance.
> 
> mcdoobie
> mcdoobie@home.com

The function spec in the .ads file must match the function definition in the
body of the package.  Sounds as if the compiler is trying to tell you they don't
match.

Larry



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

* Re: A question on function calls and defs.
  2001-03-08  2:47 ` Larry Hazel
@ 2001-03-08  2:55   ` mcdoobie
  0 siblings, 0 replies; 6+ messages in thread
From: mcdoobie @ 2001-03-08  2:55 UTC (permalink / raw)


In article <3AA6F2AB.A1A12BD5@mindspring.com>, "Larry Hazel"
<lhazel@mindspring.com> wrote:


> 
> The function spec in the .ads file must match the function definition in
> the body of the package.  Sounds as if the compiler is trying to tell
> you they don't match.
> 
> Larry

Hah! Apparently, it seems that's the case. I made a small adjustment to
my .ads spec file and voila, it works.
Now I'm beginning to see why Ada95 is so effective in helping programmers
avoid bugs.

Thanks.

McDoobie
mcdoobie@hotmail.com



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

* Re: A question on function calls and defs.
  2001-03-08  2:30 A question on function calls and defs mcdoobie
  2001-03-08  2:47 ` Larry Hazel
@ 2001-03-09  4:55 ` Jeffrey Carter
  2001-03-09 20:39   ` mcdoobie
  1 sibling, 1 reply; 6+ messages in thread
From: Jeffrey Carter @ 2001-03-09  4:55 UTC (permalink / raw)


The number of actual and formal parameters certainly matches, and you
don't seem to have anything else named Find_Volume. However, your
function body appears to be at the end of the sequence of statements of
your procedure body, and a function body is not allowed there. What are
the exact messages you are getting from the compiler?

-- 
Jeff Carter
"I fart in your general direction."
Monty Python & the Holy Grail



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

* Re: A question on function calls and defs.
  2001-03-09  4:55 ` Jeffrey Carter
@ 2001-03-09 20:39   ` mcdoobie
  2001-03-10 12:12     ` Jeffrey Carter
  0 siblings, 1 reply; 6+ messages in thread
From: mcdoobie @ 2001-03-09 20:39 UTC (permalink / raw)


In article <3AA861ED.B7B53112@acm.org>, "Jeffrey Carter"
<jrcarter@acm.org> wrote:

> The number of actual and formal parameters certainly matches, and you
> don't seem to have anything else named Find_Volume. However, your
> function body appears to be at the end of the sequence of statements of
> your procedure body, and a function body is not allowed there. What are
> the exact messages you are getting from the compiler?
> 

The only error I get is ...

	"array type required in indexed component"

Thats it. The compiler is reporting no other errors, which leads me to
beleive that I made a mistake somewhere specifically related to the
function call.

Perhaps I should post the whole program? It's really short.

McDoobie



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

* Re: A question on function calls and defs.
  2001-03-09 20:39   ` mcdoobie
@ 2001-03-10 12:12     ` Jeffrey Carter
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey Carter @ 2001-03-10 12:12 UTC (permalink / raw)


mcdoobie wrote:
> 
> The only error I get is ...
> 
>         "array type required in indexed component"

This implies that the compiler does not know about a function by that
name at that point. A function must be specified before it is used, and
must be visible at the point of use.

> Perhaps I should post the whole program? It's really short.

If it's really short, that would probably be best.

-- 
Jeff Carter
"You couldn't catch clap in a brothel, silly English K...niggets."
Monty Python & the Holy Grail



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

end of thread, other threads:[~2001-03-10 12:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-08  2:30 A question on function calls and defs mcdoobie
2001-03-08  2:47 ` Larry Hazel
2001-03-08  2:55   ` mcdoobie
2001-03-09  4:55 ` Jeffrey Carter
2001-03-09 20:39   ` mcdoobie
2001-03-10 12:12     ` Jeffrey Carter

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