comp.lang.ada
 help / color / mirror / Atom feed
* Ada statement
@ 1992-01-14  3:13 csus.edu!wupost!spool.mu.edu!news.cs.indiana.edu!bronze!master.cs.rose-hu
  0 siblings, 0 replies; 11+ messages in thread
From: csus.edu!wupost!spool.mu.edu!news.cs.indiana.edu!bronze!master.cs.rose-hu @ 1992-01-14  3:13 UTC (permalink / raw)


I'm taking CS404 here, the compilers class, and this quarter, we're
compiling a subset of Ada (We're using the book _Crafting_A_Compiler_ by
Charles Fischer and Richard LeBlanc, Jr., should anyone care.).  I used
Ada for two data structures classes last year, but never really thought
about this then.  And now...the $64,000 question....

	Why the HELL is there the NULL statement?????????????

There's only one use as far as I can tell...to fill an empty procedure/
function declaration so that the body isn't empty.  So why not just allow
an empty body?

It's not like this is a big deal...compiling that is a piece of cake.  Here's
the code from my semantic routine to compile said statement:

void null_statement(void)
{
   smPopStack(TOSS);   /* Remove the semicolon from the semantic stack
                          and heave it. */
   smPopStack(TOSS);   /* Remove the NULL from the ss and do the same. */
}

Hey, don't get on my case just 'cuz I'm writing it in C...I think Ada's
tolerable, and I love generic packages, but I just find it a little too
restrictive for someone who knows what HE's doing (so shoot me for
being politically incorrect) and wants to get something done NOW.

I'd be interested to know the reasons for NULL; being there...if you've
got anything inflammatory to say, just email it and spare the net
the grief.

P.S.  In case you've got anything nasty to say about writing it in C...
we're having it compile to VAX/11 assembler code...Blech!  :)

Todd Eigenschink
eigenstr@CS.Rose-Hulman.Edu
/* Another victim of Rose-Hulman propaganda...
 * And ARA food service.  (That rates another Blech!)
 *
 */

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

* Re: Ada statement
@ 1992-01-14 19:18 Brian Hanafee
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Hanafee @ 1992-01-14 19:18 UTC (permalink / raw)


In article <1992Jan14.031331.18320@cs.rose-hulman.edu> eigenstr@zoe.cs.rose-hul
man.edu (Todd R. Eigenschink) writes:
[stuff deleted]
>
>      Why the HELL is there the NULL statement?????????????
>
>There's only one use as far as I can tell...to fill an empty procedure/
>function declaration so that the body isn't empty.  So why not just allow
>an empty body?

I also use the explicit null to fill case statements
(when OTHERS=> null;) and, in some cases, exception handlers.
I would prefer to put in the explicit null, because it provides some
assurance that an empty body is actually what I want.  This is
particularly an issue in units with long comments.  For example, if
I have a stub body with a lot of comments about how it should be
implemented (maybe even some PDL), it is handy to have an explicit
null as a placeholder.
The explicit null also makes the grammar cleaner; null_statement
couldn't be defined to be "", because the grammer would be impossible
to parse.  Instead, you would have to change the definition of
sequence_of_statements.  You can see the problem a little better
by taking a close look at LRM 5.1/2.

[stuff deleted]
>Hey, don't get on my case just 'cuz I'm writing it in C...I think Ada's
>tolerable, and I love generic packages, but I just find it a little too
>restrictive for someone who knows what HE's doing (so shoot me for
>being politically incorrect) and wants to get something done NOW.
[stuff deleted]

There are some important differences between software development
in college and in the real world.  First, most programmers spend more
time working on other people's code than on their own.  Second, the
life cycle of a program is much longer (certainly more than a couple
semesters), so you may have to revisit your code long after you've
forgotten it.  Remember also that in the real world, you write a
lot more code, so it is harder to remember everything you've done.
Testing in the real world is also a lot more severe.

>P.S.  In case you've got anything nasty to say about writing it in C...
>we're having it compile to VAX/11 assembler code...Blech!  :)

What does the target language have to do with the language of the
compiler?  Compiling to assembler code is actually quite common.
Ideally, a vendor writes only one front end per language and one
code generator per target, then mixes and matches to get whatever
compiler is desired.  Much easier said than done.


--
Brian Hanafee                         Advanced Decision Systems
bhanafee@ads.com                      1500 Plymouth Street
(415) 960-7300                        Mountain View, CA 94043-1230

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

* Re: Ada statement
@ 1992-01-14 20:49 david.c.willett
  0 siblings, 0 replies; 11+ messages in thread
From: david.c.willett @ 1992-01-14 20:49 UTC (permalink / raw)


>From article <1992Jan14.031331.18320@cs.rose-hulman.edu>, by eigenstr@zoe.cs.r
ose-hulman.edu (Todd R. Eigenschink):
> about this then.  And now...the $64,000 question....
> 
> 	Why the HELL is there the NULL statement?????????????
> 
> There's only one use as far as I can tell...to fill an empty procedure/
> function declaration so that the body isn't empty.  So why not just allow
> an empty body?

I don't know the "official" answer to your question, but I would like to
offer two possibilities.

	You can use the NULL statement as one alternative of a conditonal
	accept, or as an alternative in a conditonal.  In both cases, it
	would be analogous to the FORTRAN  or C "continue".

	Ada is very strict about a programmer being explicit.  If you want
	to do something (or nothing) you must say so.  Having a NULL statement
	to tell the world that you are not doing anything is consistent with 
	this philosophy.

Good luck with the class,
Dave

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

* Re: Ada statement
@ 1992-01-14 21:39 Jeffrey M. Schweiger
  0 siblings, 0 replies; 11+ messages in thread
From: Jeffrey M. Schweiger @ 1992-01-14 21:39 UTC (permalink / raw)


In article <1992Jan14.031331.18320@cs.rose-hulman.edu> eigenstr@zoe.cs.rose-hul
man.edu (Todd R. Eigenschink) writes:
|I'm taking CS404 here, the compilers class, and this quarter, we're
|compiling a subset of Ada (We're using the book _Crafting_A_Compiler_ by
|Charles Fischer and Richard LeBlanc, Jr., should anyone care.).  I used
|Ada for two data structures classes last year, but never really thought
|about this then.  And now...the $64,000 question....
|
|	Why the HELL is there the NULL statement?????????????
|
|There's only one use as far as I can tell...to fill an empty procedure/
|function declaration so that the body isn't empty.  So why not just allow
|an empty body?

The 'null' statement exists because the syntax demands that there be a
statement at a particular place in a program (and not just restricted to
function and procedure bodies), but is used if there is nothing to be done
at this point.  It should be noted the C also uses the null statement (";"), 
see K&R, 2nd edition, page 18).


|It's not like this is a big deal...compiling that is a piece of cake.  Here's
|the code from my semantic routine to compile said statement:
|
|void null_statement(void)
|{
|   smPopStack(TOSS);   /* Remove the semicolon from the semantic stack
|                          and heave it. */
|   smPopStack(TOSS);   /* Remove the NULL from the ss and do the same. */
|}
|
|Hey, don't get on my case just 'cuz I'm writing it in C...I think Ada's
|tolerable, and I love generic packages, but I just find it a little too
|restrictive for someone who knows what HE's doing (so shoot me for
|being politically incorrect) and wants to get something done NOW.

So tell me, what can't you do in Ada that you can do in C (not necessarily
by the same method, and with the same ease)?  I'm not saying that one language
might not be better than another for specific applications, but I felt your
comment merited some response.  I don't view it as a case of 'political
correctness.'  Ada compilers have been written in Ada.

[deleted]

|Todd Eigenschink
|eigenstr@CS.Rose-Hulman.Edu


Jeff Schweiger

-- 
*******************************************************************************
Jeff Schweiger	      Standard Disclaimer   	CompuServe:  74236,1645
Internet (Milnet):				schweige@taurus.cs.nps.navy.mil
*******************************************************************************

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

* Re: Ada statement
@ 1992-01-14 22:16 Jim Giles
  0 siblings, 0 replies; 11+ messages in thread
From: Jim Giles @ 1992-01-14 22:16 UTC (permalink / raw)


In article <1992Jan14.204928.21571@cbnewsl.cb.att.com>, willett@cbnewsl.cb.att.
com (david.c.willett) writes:
|> [...]
|> 	You can use the NULL statement as one alternative of a conditonal
|> 	accept, or as an alternative in a conditonal.  In both cases, it
|> 	would be analogous to the FORTRAN  or C "continue".

The Fortran continue and the C continue do completely different things.
In Fortran, continue does nothing and is a convenient place to hang
a statement label.  In C, a continue statement causes the rest of the
innermost loop to be skipped and for the next pass of the loop to begin
(ie. the "cycle" statement in some languages).  The C feature which 
resembles a Fortran continue is ";" - the NULL statement - same as 
Ada.


J. Giles

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

* Re: Ada statement
@ 1992-01-15  1:15 dog.ee.lbl.gov!network.ucsd.edu!swrinde!mips!zaphod.mps.ohio-state.edu!so
  0 siblings, 0 replies; 11+ messages in thread
From: dog.ee.lbl.gov!network.ucsd.edu!swrinde!mips!zaphod.mps.ohio-state.edu!so @ 1992-01-15  1:15 UTC (permalink / raw)


In article <1992Jan14.221658.7468@beta.lanl.gov>, jlg@cochiti.lanl.gov (Jim Gil
es) writes:
|> In article <1992Jan14.204928.21571@cbnewsl.cb.att.com>, willett@cbnewsl.cb.a
tt.com (david.c.willett) writes:
|> |> [...]
|> |> 	You can use the NULL statement as one alternative of a conditonal
|> |> 	accept, or as an alternative in a conditonal.  In both cases, it
|> |> 	would be analogous to the FORTRAN  or C "continue".
|> 
|> The Fortran continue and the C continue do completely different things.
|> In Fortran, continue does nothing and is a convenient place to hang
|> a statement label.  In C, a continue statement causes the rest of the
|> innermost loop to be skipped and for the next pass of the loop to begin
|> (ie. the "cycle" statement in some languages).  The C feature which 
|> resembles a Fortran continue is ";" - the NULL statement - same as 
|> Ada.
|> 
|> 
|> J. Giles

Thanks for the responses.  All of them seemed to center around the same
basic things.  I do have one opinion different than that which was expressed,
about C's "null" statement.  True, a semicolon won't do anything if just
inserted into code.  However, it is my understanding (perhaps I'm
wrong, and I don't have my K&R handy to check this) that the semicolon is
a statement terminator...so C's null statement is _really_ null!  (And
therefore not necessary.)

What about something like:

	for (i = 0; i < 10; i++)
		;

As far as I know, the semicolon just terminates the statement, which doesn't
have any body (except for the i++).

Well, anyway, I'm glad I know.  I still don't see the point in demanding
a statement which does nothing, but I'll accept it.

Oh, yeah...and somebody (can't find the post) said something about writing
a lot more code in the real world.  Unless I'm mistaken, the average
programmer for a government project produces something like 10 lines of
code per day.  (Just shows the emphasis on design, I guess. :-> )

--
Todd Eigenschink
eigenstr@CS.Rose-Hulman.Edu

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

* Re: Ada statement
@ 1992-01-15  6:04 csus.edu!wupost!zaphod.mps.ohio-state.edu!mips!cs.uoregon.edu!nntp.uorego
  0 siblings, 0 replies; 11+ messages in thread
From: csus.edu!wupost!zaphod.mps.ohio-state.edu!mips!cs.uoregon.edu!nntp.uorego @ 1992-01-15  6:04 UTC (permalink / raw)


In article <1992Jan14.031331.18320@cs.rose-hulman.edu> eigenstr@zoe.cs.rose-hul
man.edu (Todd R. Eigenschink) writes:

  [ stuff deleted ]
>
>	Why the HELL is there the NULL statement?????????????
>
>There's only one use as far as I can tell...to fill an empty procedure/
>function declaration so that the body isn't empty.  So why not just allow
>an empty body?
>
NULL can be useful in e.g. a CASE statement, which requires that all
values of the case variable be accounted for.

WHEN OTHERS => NULL;

is often handy to write if no action is needed.
The NULL statement is similar to "THIS PAGE IS INTENTIONALLY LEFT BLANK"
in documents - it indicates a DELIBERATE "leaving out" of something.

Empty bodies are confusing; they lead to endless grief in C.
Consider
  x = 1;
  while (x < 100);
  {
     x++
  }

This is an endless loop, because the carelessly placed semicolon after
the while clause creates an empty loop body. This can't happen in Ada.

Mike

-------------------------------------------------------------------------------
Michael B. Feldman                       co-chair, SIGAda Education Committee

Visiting Professor 1991-92               Professor
Dept. of Comp. Sci. and Engrg.           Dept. of Elect. Engrg. and Comp. Sci.
University of Washington FR-35           The George Washington University
Seattle, WA 98105                        Washington, DC 20052

mfeldman@cs.washington.edu               mfeldman@seas.gwu.edu
(206) 632-3794 (voice)                   (202) 994-5253 (voice)
(206) 543-2969 (fax)                     (202) 994-5296 (fax)
-------------------------------------------------------------------------------

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

* Re: Ada statement
@ 1992-01-15  6:09 dog.ee.lbl.gov!network.ucsd.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!us
  0 siblings, 0 replies; 11+ messages in thread
From: dog.ee.lbl.gov!network.ucsd.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!us @ 1992-01-15  6:09 UTC (permalink / raw)


In article <3848@aldebaran.cs.nps.navy.mil> schweige@taurus.cs.nps.navy.mil (Je
ffrey M. Schweiger) writes:
 [ deleted ]
>
>So tell me, what can't you do in Ada that you can do in C (not necessarily
>by the same method, and with the same ease)?  I'm not saying that one language
>might not be better than another for specific applications, but I felt your
>comment merited some response.  I don't view it as a case of 'political
>correctness.'  Ada compilers have been written in Ada.
>
A masterful understatement, Jeff. The Janus, TeleSoft and Alsys compiler
families, accounting for a significant proportion of the validations,
are all written in Ada. For the record: Verdix codes in C, Meridian in
Pascal and C, DEC (still I think) in BLISS.

Mike

-------------------------------------------------------------------------------
Michael B. Feldman
Visiting Professor 1991-92               Professor
Dept. of Comp. Sci. and Engrg.           Dept. of Elect. Engrg. and Comp. Sci.
University of Washington FR-35           The George Washington University
Seattle, WA 98105                        Washington, DC 20052

mfeldman@cs.washington.edu               mfeldman@seas.gwu.edu
(206) 632-3794 (voice)                   (202) 994-5253 (voice)
(206) 543-2969 (fax)                     (202) 994-5296 (fax)
-------------------------------------------------------------------------------

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

* Re: Ada statement
@ 1992-01-15 15:11 Greg Harvey
  0 siblings, 0 replies; 11+ messages in thread
From: Greg Harvey @ 1992-01-15 15:11 UTC (permalink / raw)


In <3848@aldebaran.cs.nps.navy.mil> schweige@taurus.cs.nps.navy.mil (Jeffrey M.
 Schweiger) writes:

>So tell me, what can't you do in Ada that you can do in C (not necessarily
>by the same method, and with the same ease)?

On Space Station Freedom, there is a need to execute from an address.
(I won't go into WHY there is a need...please just accept this need
as an instructional example, i.e., at face value.)  There is no way
in Ada to begin execution from an address, short of handing that data
to a C or Assembly program for execution.  Better solutions would
include using reference tables, etc., but these do not take into
account that some software MUST be installable into a working
application without a fully qualified link phase.

Can we devise other solutions for this problem that work?  Probably.
Will they work for Space Station?  Not now.  Can 9X fix this?
Probably, by treating procedures as objects or parameters.

(This is supposed to be a discussion, so I don't mind the tomatoes
that are about to be thrown my way.  Feel free to instruct me.  ;-)


--
Greg Harvey                     Lockheed Engineering & Sciences Company
Internet(yucky path): <@aio.jsc.nasa.gov:gwharvey@lescsse.jsc.nasa.gov>
Houston, Texas                                          +1 713 283 5188

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

* Re: Ada statement
@ 1992-01-15 17:13 Stan McQueen
  0 siblings, 0 replies; 11+ messages in thread
From: Stan McQueen @ 1992-01-15 17:13 UTC (permalink / raw)


In article <1992Jan15.011557.29353@cs.rose-hulman.edu> eigenstr@susan.cs.rose-h
ulman.edu (Todd R. Eigenschink) writes:
> Thanks for the responses.  All of them seemed to center around the
> same basic things.  I do have one opinion different than that which
> was expressed, about C's "null" statement.  True, a semicolon won't do
> anything if just inserted into code.  However, it is my understanding
> (perhaps I'm wrong, and I don't have my K&R handy to check this) that
> the semicolon is a statement terminator...so C's null statement is
> _really_ null!  (And therefore not necessary.)

Ref. _Standard_C_ by Plauger and Brodie:

"NULL Statement (;):  A null statement does nothing.  You use it where
the translator requires a statement but you do not want to perform an
action."


>  Oh, yeah...and somebody (can't find the post) said something about writing
>  a lot more code in the real world.  Unless I'm mistaken, the average
>  programmer for a government project produces something like 10 lines of
>  code per day.  (Just shows the emphasis on design, I guess. :-> )

Of course, the statistic "10 lines of code per day" doesn't mean that
the average programmer reports for work each day, writes 10 lines of
code, and goes home, his/her hard work day finished.  It means that,
if you divide the total number of lines of code in the finished,
delivered product by the number of worker-days that the project
required (including requirements analysis, design, coding,
integration, and testing) the result should be about 10.  So the
statement that productivity rates are about 10 lines of code per day
per programmer are somewhat misleading, since the figure refers to
more than coding time alone.  


--
-------------------------------------------------------------------------------
sem@mbunix.mitre.org	                              "The right to buy weapons
Stan McQueen                                          is the right to be free."
The MITRE Corporation                                         -- A. E. van Vogt
1259 Lake Plaza Dr.                                 "The Weapon Shops of Isher"
Colorado Springs, CO 80906
719-380-3325

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

* Re: Ada statement
@ 1992-01-15 17:37 bu.edu!rpi!usenet.coe.montana.edu!ogicse!verdix!brucej
  0 siblings, 0 replies; 11+ messages in thread
From: bu.edu!rpi!usenet.coe.montana.edu!ogicse!verdix!brucej @ 1992-01-15 17:37 UTC (permalink / raw)


In article <1992Jan15.060934.17680@milton.u.washington.edu> mfeldman@milton.u.w
ashington.edu (Michael Feldman) writes:
>                        For the record: Verdix codes in C, Meridian in
>Pascal and C, DEC (still I think) in BLISS.

Just for the record,  most of Verdix's new development is coded in
Ada - the new optimizer,  the target debug monitor (tdm),  and the
runtime system for example.  The compiler's front and back ends are 
coded in C.

	-- brucej

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

end of thread, other threads:[~1992-01-15 17:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-01-15  6:04 Ada statement csus.edu!wupost!zaphod.mps.ohio-state.edu!mips!cs.uoregon.edu!nntp.uorego
  -- strict thread matches above, loose matches on Subject: below --
1992-01-15 17:37 bu.edu!rpi!usenet.coe.montana.edu!ogicse!verdix!brucej
1992-01-15 17:13 Stan McQueen
1992-01-15 15:11 Greg Harvey
1992-01-15  6:09 dog.ee.lbl.gov!network.ucsd.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!us
1992-01-15  1:15 dog.ee.lbl.gov!network.ucsd.edu!swrinde!mips!zaphod.mps.ohio-state.edu!so
1992-01-14 22:16 Jim Giles
1992-01-14 21:39 Jeffrey M. Schweiger
1992-01-14 20:49 david.c.willett
1992-01-14 19:18 Brian Hanafee
1992-01-14  3:13 csus.edu!wupost!spool.mu.edu!news.cs.indiana.edu!bronze!master.cs.rose-hu

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