[comp.lang.ada] Invalid analogy

billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) (03/04/90)

From eaker@sunbelt.crd.ge.com (Charles E Eaker):
>>   [In C] similar flow-of-control constructs do not terminate in 
>>   similar ways.  If one is using the if statement, termination is
>>   automatic.  If one is using the switch statement, a break is required.  
> 
% [An invalid analogy is attempted:]
%    "LOOP" construct, which contained
%       a "CASE" statement, which contained 
%          an "IF" clause, which contained an
%             "EXIT," which was intended for
%          the "IF" clause, but instead broke from
%       the "LOOP" statement.

   Notice: "similar flow-of-control constructs".  Both the case and 
   the if statements execute different sections of code depending on
   the value of a controlling expression.  A loop is a flow-of-control
   construct, but not one which is similar to the if or case constructs,
   which are so closely related that one is a special case of the other. 

   This extreme similarity, unfortunately, does not extend to C's concept
   of how the two should be supported within the programming language. 


   Bill Wolfe, wtwolfe@hubcap.clemson.edu
 

khan@milton.acs.washington.edu (I Wish) (03/04/90)

In article <8222@hubcap.clemson.edu>
billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes:

> From eaker@sunbelt.crd.ge.com (Charles E Eaker):

>> [In C] similar flow-of-control constructs do not terminate in 
>> similar ways.  If one is using the if statement, termination is
>> automatic.  If one is using the switch statement, a break is required.  

[his example, a nested loop/if/switch/etc.]

> Notice: "similar flow-of-control constructs".  Both the case and 
> the if statements execute different sections of code depending on
> the value of a controlling expression.  [...]

> This extreme similarity, unfortunately, does not extend to C's concept
> of how the two should be supported within the programming language. 

> Bill Wolfe, wtwolfe@hubcap.clemson.edu

I see C's if as an exclusive two-case switch.  If doesn't need break
because fallthrough in an if would be useless -- any code common to the
then and else clauses can be factored out of the if, since there are no
other cases.  "If", as a _special_ _case_ of switch, assumes a break;
would C be better if "then" required a break to prevent fallthrough to
the else?  That would be a consistent way to make them similar.
-- 
"indecipherable strangers handing out inexplicable humiliation and an
 unidentified army of horsemen laughing at him in his head ..."
                                                           -- Douglas Adams
Erik Seaberg (khan@milton.u.washington.edu)

jnixon@andrew.ATL.GE.COM (John F Nixon) (03/06/90)

billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) writes:

> [Both case and if] statements execute different sections of code
> depending on the value of a controlling expression.  ... the if or
> case constructs ... are so closely related that one is a special case
> of the other. This extreme similarity, unfortunately, does not extend
> to C's concept of how the two should be supported within the ... language.

I was wondering how Bill was going to defend Ada's inclusion of loop/exit :-).
Clearly, it is a violation of the notion of consistency; so now we are
reduced to merely consistency within "similar" constructs.  I would argue that
if consistency is indeed a good thing, it is worth being consistent throughout.

It would be possible to design a language that is so inconsistent one would 
have difficulty programming in it.  I claim neither C nor Ada fall in that
class.  I have written lots of C code, and I cannot *ever* remember leaving
out a break; it is simply not confusing to anyone who understands C.  I have
not written much Ada; I have been confused by Ada, because I do not understand
the language well.  I do not understand why one cannot declare an array within
a record -- one must declare an array type, then use the type within a record.
Yes, I know it is good practice to declare types, but if so why does Ada allow
array declarations (without type) at all?

{Ada,C} can be mastered, and is a useful tool.  {Ada,C} has problem areas, but
is not unacceptable as a programming tool.  The crucial factor is not the
choice of language, but the education of the human who uses the language.
The difference between the best and the average is so large that surely
there is more room for improvment in education than language design.

----
jnixon@atl.ge.com                    ...steinmetz!atl.decnet!jnxion

sanders@sanders.austin.ibm.com (Tony Sanders) (03/10/90)

In article <8222@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes:
>   Notice: "similar flow-of-control constructs".  Both the case and 
>   the if statements execute different sections of code depending on
>   the value of a controlling expression.  A loop is a flow-of-control
>   construct, but not one which is similar to the if or case constructs,
>   which are so closely related that one is a special case of the other. 
Give me a break! (sorry, couldn't resist :-)

I make my living programming in C so I fail to see how evil and
corrupting the C programming language is.  If you make a living
programming in ADA that is just fine.  Someday, I might use ADA if I
think it is the best language for the project I'm working on at that
time.

BUT!
Please don't go around slamming some other language based on the fact
that you think that your language of choice is the ONLY programming
language that anyone should use, and then proceed to conclude that
(all/some) C programmers can't possibly write good code because their
language has to have a break statement at the end of a case.  Take it
to alt.religion.computers (where it belongs anyway) and then I'll be
happy to argue day in and day out on endlessly tiny details and nuances
of programming in each of the respective languages (see my followup line).

Simply put: ADA is not the end all of programming languages and neither
is C, both have advantages and disadvantages.  Learn them and they will
serve you well.

-- sanders                The 11th commandment: "Thou shalt use lint"
For every message of the day, a new improved message will arise to overcome it.
Reply-To:  cs.utexas.edu!ibmaus!auschs!sanders.austin.ibm.com!sanders