comp.lang.ada
 help / color / mirror / Atom feed
* A big thank you to Bruce or Tracy, Robert  and Ted!!!!!!!
@ 2000-12-30 20:14 Mark Pagdin
  2000-12-30 23:53 ` Bruce or Tracy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mark Pagdin @ 2000-12-30 20:14 UTC (permalink / raw)


Hi guys,

Thank you all for your help. I am meant to attept a pretty graphics addition
to the program, but i won't worry about that until I manage the basics.

I appreciate all your comments. I have been reading about Ada, Arrays etc
but I find i learn from actually doing things, not just reading about them.
I don't really want to lose face with my lecturer/plus he probably has 80
emails from desperate students like me, hence turning to you guys for help.

2 qns, about general Ada:

a) When does one use a function or a Procedure. I know it is to do with one
not giving an output or something but can anyone give an example of when to
use one rather that another?
b)I use Gnat IDE and I was recomended by my lecturer to use packages and
then procedures/functions in that package can be called. So when i want to
write the Main Program (is that what you call it?) i say "with Mark;" if
Mark is the package and then just write a procedure that calls the names of
the procedures and functions from the package?

If you can understand what i just wrote then you deserve an MBE.

Mark

-





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

* Re: A big thank you to Bruce or Tracy, Robert  and Ted!!!!!!!
  2000-12-30 20:14 A big thank you to Bruce or Tracy, Robert and Ted!!!!!!! Mark Pagdin
@ 2000-12-30 23:53 ` Bruce or Tracy
  2000-12-31  0:34 ` Robert Dewar
  2001-01-07  1:29 ` John English
  2 siblings, 0 replies; 4+ messages in thread
From: Bruce or Tracy @ 2000-12-30 23:53 UTC (permalink / raw)


Generally speaking: (I say that to keep the flaming down!!  :)

Use/call a function when your program is wanting to know something
like the Sin of an angle or distance between two points - consider
a function as being an equation.

Procedures are for performing some action, like the get_line procedure
which populates a variable with some information or the "Put" procedure
that performs output to an output device (screen, file, etc). 
Procedures
will perform an action(s) or populate a complex data structure(s) via
"in out" notation in the procedure's spec of the  variable(s).  

Don't feel bad about having several functions, one function to give you
every little calculation you wish.

I guess I don't deserve an MBE - I don't quite understand the (b)
question.

Hope it goes well for you,
Bruce


Mark Pagdin wrote:
> 
> Hi guys,
> 
> Thank you all for your help. I am meant to attept a pretty graphics addition
> to the program, but i won't worry about that until I manage the basics.
> 
> I appreciate all your comments. I have been reading about Ada, Arrays etc
> but I find i learn from actually doing things, not just reading about them.
> I don't really want to lose face with my lecturer/plus he probably has 80
> emails from desperate students like me, hence turning to you guys for help.
> 
> 2 qns, about general Ada:
> 
> a) When does one use a function or a Procedure. I know it is to do with one
> not giving an output or something but can anyone give an example of when to
> use one rather that another?
> b)I use Gnat IDE and I was recomended by my lecturer to use packages and
> then procedures/functions in that package can be called. So when i want to
> write the Main Program (is that what you call it?) i say "with Mark;" if
> Mark is the package and then just write a procedure that calls the names of
> the procedures and functions from the package?
> 
> If you can understand what i just wrote then you deserve an MBE.
> 
> Mark
> 
> -



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

* Re: A big thank you to Bruce or Tracy, Robert and Ted!!!!!!!
  2000-12-30 20:14 A big thank you to Bruce or Tracy, Robert and Ted!!!!!!! Mark Pagdin
  2000-12-30 23:53 ` Bruce or Tracy
@ 2000-12-31  0:34 ` Robert Dewar
  2001-01-07  1:29 ` John English
  2 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 2000-12-31  0:34 UTC (permalink / raw)


In article <t4sghie7fam871@corp.supernews.co.uk>,
  "Mark Pagdin" <mark_pagdin@lineone.net> wrote:
> a) When does one use a function or a Procedure. I know it is
> to do with one not giving an output or something but can
> anyone give an example of when to use one rather that
> another?

This certainly confirms my earlier guess, that you don't know
enough yet to be trying to start coding. This is a VERY
fundamental question. It is sort of like someone who sits down
to play the piano, and first asks "I just have one question
what's the difference between the pedals for my feet and the
levers for my hands" :-)

Well perhaps that's a little too extreme, but it is not that
far off. A procedure carries out some actions, a function
returns a result. This must be discussed in any elementary
Ada book, furthermore, any Ada book is just FULL of examples
of the two, so that's the place to look to study.

What book are you using?

You will simply frustrate yourself if you try to code without
understanding the basics. Actually I would suggest doing a
simpler excercise first (like printing out the squares of
numbers from 1 to 5 using a function to compute the square).

> b)I use Gnat IDE and I was recomended by my lecturer to use
> packages and then procedures/functions in that package can be
> called. So when i want to
> write the Main Program (is that what you call it?) i say
> "with Mark;" if Mark is the package and then just write a
> procedure that calls the names of the procedures and
> functions from the package?

Again, any Ada book is FULL of such examples. The short answer
to your question is either qualify the names fully, or use a
USE statement, but I think the first step is to study examples
in your text book.

Then if there is something you can't understand in the text
book, ask your instructor, or failing that, ask here.


Sent via Deja.com
http://www.deja.com/



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

* Re: A big thank you to Bruce or Tracy, Robert  and Ted!!!!!!!
  2000-12-30 20:14 A big thank you to Bruce or Tracy, Robert and Ted!!!!!!! Mark Pagdin
  2000-12-30 23:53 ` Bruce or Tracy
  2000-12-31  0:34 ` Robert Dewar
@ 2001-01-07  1:29 ` John English
  2 siblings, 0 replies; 4+ messages in thread
From: John English @ 2001-01-07  1:29 UTC (permalink / raw)


Mark Pagdin wrote:
> I appreciate all your comments. I have been reading about Ada, Arrays etc
> but I find i learn from actually doing things, not just reading about them.
> I don't really want to lose face with my lecturer/plus he probably has 80
> emails from desperate students like me, hence turning to you guys for help.

Ooh. You will probably find that your lecturer will be gratified to
discover
that you've learned to ask questions when you don't understand
something.
There's nothing more frustrating than talking to an unresponsive class
who
don't stop you and ask questions, but when you ask them questions you
find
that they haven't understood anything you said since the bit where you
said
"Good morning" last Monday.

At Brighton we run "sandwich" courses where students do a year in
industry
between their 2nd and final years. One of the most rewarding results is
that
they come back for their final year and ask questions, rather than
sitting on
their hands and thinking "I must be stupid..." !!!

If you look around this (and other) groups, you'll find that most people
here
have asked the world to help when they've got stumped by something.
Nothing
to be ashamed of at all.

> 2 qns, about general Ada:
> 
> a) When does one use a function or a Procedure. I know it is to do with one
> not giving an output or something but can anyone give an example of when to
> use one rather that another?

Procedure: use as a statement:
   Do_This (Blah, Blah, Blah);

Function: use as an expression:
   This := Do_That(Blah, Blah) + The_Other;

> b)I use Gnat IDE and I was recomended by my lecturer to use packages and
> then procedures/functions in that package can be called. So when i want to
> write the Main Program (is that what you call it?) i say "with Mark;" if
> Mark is the package and then just write a procedure that calls the names of
> the procedures and functions from the package?

Yes. For example, this will work:

  with Mark;
  procedure My_Main_Program is
  begin
    Mark.Do_This;  -- call the procedure Do_This in package Mark
  end My_Main_Program;

Another way to say the same thing:

  with Mark; use Mark;
  procedure My_Main_Program is
  begin
    Do_This;  -- call the procedure Do_This in package Mark
  end My_Main_Program;

> If you can understand what i just wrote then you deserve an MBE.

Oh, thank you... :-)

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------



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

end of thread, other threads:[~2001-01-07  1:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-30 20:14 A big thank you to Bruce or Tracy, Robert and Ted!!!!!!! Mark Pagdin
2000-12-30 23:53 ` Bruce or Tracy
2000-12-31  0:34 ` Robert Dewar
2001-01-07  1:29 ` John English

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