What should be added to C

Andrew Koenig ark at alice.UucP
Wed May 21 02:18:09 AEST 1986


Frank Adams says:

> As has been noted, one should use restraint in adding new features to a
> language.  What follows is a list of the features I would support adding to
> the *next* version of C (after the current standard is complete).

OK, let's see his examples of "restraint:"

> o Min and max operators.  These would get used all over the place.  These
> should be usable to the left of the assignment operator, as most but not all
> C operators are.

What would it mean to use these on the left of an assignment,
and why would you want to use it?

> o An andif clause for if statements.

What does it do and how would you use it?

> o The ability to define multi-line pre-processor macros, using #begdef and
> #enddef statements.  #if and other conditionals in the body of the
> definition would be evaluated when the macro was not interpreted, not when
> it is encountered.

Why would you want to use it?

> o A typeof operator, similar to sizeof.

What would its value be?  Why would you want to use it?

> o := as a synonym for =.  Compilers could have an option to permit := only.

Why bother?

> o Permit a continue statement in switch, meaning that the next label should
> be fallen through to.  Compilers and/or lint could produce when a program
> falls through without a continue statement.

A continue statement is already legal in a switch, as long as that
switch is enclosed in a for or while.  It means go on to the next
iteration of the enclosing loop.  Are you proposing to change this?

> o Any sort of multi-level break statement.  There is no syntacticly clean
> way of adding this to C.

C already has a multi-level break statement.  It's spelled "goto."
Putting a goto in a costume doesn't disguise it.

> o Elimination of the eight-character truncation of internal variable names
> done by some compilers.  (This may be in the current spec; I haven't read
> that document.)  The entire length of a variable name should be significant.

Most compilers do this already.


The trouble with adding new features to C is that there is a very
strong incentive not to use them.  After all, any program that
uses some new feature is only going to run on machines that support
that feature.  I don't think I'm going to be using only one compiler
for the rest of my life and would like to avoid changing my code
every time the environment hiccups.



More information about the Comp.lang.c mailing list