comp.lang.ada
 help / color / mirror / Atom feed
* Using procedures
@ 1994-12-03 20:32 Bill Heiser
  0 siblings, 0 replies; 8+ messages in thread
From: Bill Heiser @ 1994-12-03 20:32 UTC (permalink / raw)



I am down to the wire and have to complete a couple of Ada programs ASAP.
There is something I just don't get about using procedures in Ada.
If I have a program with multiple procedures, how do I get all of
them to run?  If I try to call one from another, the compiler
complains of undeclared identifiers.
i.e.

    with text_io;
    procedure putv(i: OUT integer) is
    begin
      for i in 1..5 loop
      text_io.put(integer'image(i));
      end loop;

    end putv;

    with text_io;
    procedure puty(j: OUT integer) is
    begin
      for j in 1..5 loop
      text_io.put(integer'image(j));
      end loop;
    end puty;

How (for example) do I call putv from puty?  If I try a "putv(something)",
the compiler complains that putv is an undeclared identifier.  If I run
this little program as-is, it runs, but only one of the functions runs
(I get a "1-5", not two sets of them as I'd expect).

I'm really down to the wire to get these programs done for school, so
any help would be much appreciated.

BTW, this is for Ada/6000 release 3.3 on an RS/6000 running AIX 3.2.5.

Thanks,
Bill
-- 
Bill Heiser:    bill@bh.org     http://www.bh.org/
PGP public key available upon request.



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

* Re: Using procedures
@ 1994-12-05 21:42 Bennett, Chip (KTR) ~U
  1994-12-06 18:59 ` Bill Heiser
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Bennett, Chip (KTR) ~U @ 1994-12-05 21:42 UTC (permalink / raw)


Bill Heiser <bill@BHHOME.BH.ORG> wrote:

> I am down to the wire and have to complete a couple of Ada programs ASAP.
> There is something I just don't get about using procedures in Ada.
> If I have a program with multiple procedures, how do I get all of
> them to run?  If I try to call one from another, the compiler
> complains of undeclared identifiers.
> i.e.
>
>     with text_io;
>     procedure putv(i: OUT integer) is
>     begin
>       for i in 1..5 loop
>       text_io.put(integer'image(i));
>       end loop;
>
>    end putv;
>
>     with text_io;
>     procedure puty(j: OUT integer) is
>     begin
>       for j in 1..5 loop
>       text_io.put(integer'image(j));
>       end loop;
>     end puty;
>
> How (for example) do I call putv from puty?  If I try a "putv(something)",
> the compiler complains that putv is an undeclared identifier.  If I run
> this little program as-is, it runs, but only one of the functions runs
> (I get a "1-5", not two sets of them as I'd expect).
>
> I'm really down to the wire to get these programs done for school, so
> any help would be much appreciated.
>
> BTW, this is for Ada/6000 release 3.3 on an RS/6000 running AIX 3.2.5.
>
> Thanks,
> Bill
> --
> Bill Heiser:    bill@bh.org     http://www.bh.org/
> PGP public key available upon request.
>

Bill, your question shows you either haven't read the book, or you're not
listening in class, so I'll be brief and leave "the proof as an exercise"
:-).  Nest the subroutine or put it in a package.  (If I've misjudged the
situation I apologize.)

But this brings up a bigger point that is the real reason I bother to post
this.  I want to promote Ada, but I question whether doing a students
homework is going too far.  Comments?

*****************************************************************
* Chip Bennett, GDE Systems Inc | BennettC@j64.stratcom.af.mil  *
* USSTRATCOM/J64213             | Voice (402)294-7360           *
* 901 SAC Blvd, Suite 2B24      | FAX   (402)294-7912           *
* Offutt AFB, NE 68113-6600     | Proud member of Team Ada      *
* Opinions expressed here are my own _so_,  TTFWTW              *
*****************************************************************



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

* Re: Using procedures
@ 1994-12-06 17:20 Bob Wells #402
  1994-12-06 19:02 ` Bill Heiser
  0 siblings, 1 reply; 8+ messages in thread
From: Bob Wells #402 @ 1994-12-06 17:20 UTC (permalink / raw)


"Bennett, Chip (KTR) ~U" <BennettC@J64.STRATCOM.AF.MIL> writes ...

> But this brings up a bigger point that is the real reason I bother to post
> this.  I want to promote Ada, but I question whether doing a students
> homework is going too far.  Comments?

G'day,
I thought we decided on a previous thread that this wasn't actually "cheating"
but actually a good example of code reuse!
Bob W. (-:

BTW Bill H. did you get any responses providing solutions yet?



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

* Re: Using procedures
  1994-12-05 21:42 Bennett, Chip (KTR) ~U
@ 1994-12-06 18:59 ` Bill Heiser
  1994-12-08 12:40   ` Gentle
  1994-12-07 20:46 ` -mlc-+Schilling J.
  1994-12-07 23:35 ` Robert Dewar
  2 siblings, 1 reply; 8+ messages in thread
From: Bill Heiser @ 1994-12-06 18:59 UTC (permalink / raw)


Bennett, Chip (KTR) ~U (BennettC@J64.STRATCOM.AF.MIL) wrote:

: Bill, your question shows you either haven't read the book, or you're not
: listening in class, so I'll be brief and leave "the proof as an exercise"

Neither of your accusations is correct.  I spent nearly an entire day
poring over the textbook, and did not find a reference to using
multiple procedures together.  There was lots of talk about individual
procedures, but nothing concerning this particular situation.

: But this brings up a bigger point that is the real reason I bother to post
: this.  I want to promote Ada, but I question whether doing a students
: homework is going too far.  Comments?


I didn't notice anyone asking anyone to "do a student's homework".
Did you?  Sorry if you interpreted the question that way.  I see
nothing wrong with going to the net asking for help on how to
approach a problem.  There's no difference between doing that  
and going to a fellow student or the professor.  The only difference
is that I see the professor for 3 hours per week, whereas
the net is here 24x7.  Furthermore the whole point to homework is
to help the student learn the material.  It's not an exam!


--
Bill Heiser    heiser@acs.bu.edu, heiser@world.std.com
               Boston University, Boston MA   



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

* Re: Using procedures
  1994-12-06 17:20 Bob Wells #402
@ 1994-12-06 19:02 ` Bill Heiser
  0 siblings, 0 replies; 8+ messages in thread
From: Bill Heiser @ 1994-12-06 19:02 UTC (permalink / raw)


Bob Wells #402 (wel@EUROCONTROL.DE) wrote:
: "Bennett, Chip (KTR) ~U" <BennettC@J64.STRATCOM.AF.MIL> writes ...

: G'day,
: I thought we decided on a previous thread that this wasn't actually "cheating"
: but actually a good example of code reuse!
: Bob W. (-:

In my case, I wasn't even asking for code to solve a whole
problem.   I just needed a push in the right direction.
Several people *did* send code fragments, but I just took
the ideas and wrote my own actual code.  I see nothing wrong
with that .. .in fact I think it is the way one learns.
Fumbling around doing something that either doesn't work or
is done completely incorrectly doesn't teach a person the
right way to do things.
: BTW Bill H. did you get any responses providing solutions yet?


Yes - several people sent excellent replies by email.
I will post a summary shortly.  Thanks.


--
Bill Heiser    heiser@acs.bu.edu, heiser@world.std.com
               Boston University, Boston MA   



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

* Re: Using procedures
  1994-12-05 21:42 Bennett, Chip (KTR) ~U
  1994-12-06 18:59 ` Bill Heiser
@ 1994-12-07 20:46 ` -mlc-+Schilling J.
  1994-12-07 23:35 ` Robert Dewar
  2 siblings, 0 replies; 8+ messages in thread
From: -mlc-+Schilling J. @ 1994-12-07 20:46 UTC (permalink / raw)


In article <2EE38942@SMTPGATE2.STRATCOM.AF.MIL> "Bennett, Chip (KTR) ~U" <BennettC@J64.STRATCOM.AF.MIL> writes:
:
:But this brings up a bigger point that is the real reason I bother to post
:this.  I want to promote Ada, but I question whether doing a students
:homework is going too far.  Comments?

Yes, it's going too far.

-- 
Jonathan Schilling
Novell, UNIX Systems Group
jls@summit.novell.com



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

* Re: Using procedures
  1994-12-05 21:42 Bennett, Chip (KTR) ~U
  1994-12-06 18:59 ` Bill Heiser
  1994-12-07 20:46 ` -mlc-+Schilling J.
@ 1994-12-07 23:35 ` Robert Dewar
  2 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1994-12-07 23:35 UTC (permalink / raw)



my comment

doing a student's homework is going too far

(and typically, if the student does not acknowledge the help received,
 you are really an unintending participant in education fraud!)

The trick is always to help without actually providing the solution. 

I am not sure that the main CLA newsgroup is the right forum for this
in any case, maybe there should be a special subgroup.




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

* Re: Using procedures
  1994-12-06 18:59 ` Bill Heiser
@ 1994-12-08 12:40   ` Gentle
  0 siblings, 0 replies; 8+ messages in thread
From: Gentle @ 1994-12-08 12:40 UTC (permalink / raw)


On 6 Dec 1994 18:59:32 GMT, Bill Heiser (heiser@bu.edu) wrote:
: I didn't notice anyone asking anyone to "do a student's homework".
: Did you?  Sorry if you interpreted the question that way.  I see
: nothing wrong with going to the net asking for help on how to
: approach a problem.  There's no difference between doing that  
: and going to a fellow student or the professor.  The only difference
: is that I see the professor for 3 hours per week, whereas
: the net is here 24x7.  Furthermore the whole point to homework is
: to help the student learn the material.  It's not an exam!

  Well, here's probably the kind of advice you were asking for.

Take related procedures and put them into a package together.  The package
specification holds just the declarations of the procedures, while the body
holds their bodies (eew, sounds morbid).  Anyway, you can "with" in that
package from a  main program unit (or another package), and be able to call
the procedures using dot notation (like Package.Procedure(parms...)).
  Hopefully this helps.

--
=========================================================================
gentle@cnj.digex.net

Software Engineer (extraordinaire!)
Level: International Hacker
Edison, NJ

"All flesh is grass"
		-- Isiah
Smoke a friend today.
=========================================================================



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

end of thread, other threads:[~1994-12-08 12:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-12-03 20:32 Using procedures Bill Heiser
  -- strict thread matches above, loose matches on Subject: below --
1994-12-05 21:42 Bennett, Chip (KTR) ~U
1994-12-06 18:59 ` Bill Heiser
1994-12-08 12:40   ` Gentle
1994-12-07 20:46 ` -mlc-+Schilling J.
1994-12-07 23:35 ` Robert Dewar
1994-12-06 17:20 Bob Wells #402
1994-12-06 19:02 ` Bill Heiser

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