Another stupid language proposal

David Chase rbbb at rice.ARPA
Mon Aug 18 23:13:02 AEST 1986


As long as people are talking about using expressions as conditionals
(the ? void : void discussion), how about using commands as expressions?
I'm not talking about little, wimpy commands like "a = b"; I'm talking
about real commands, like "{ ... }" where that little ellipsis might be
pages of code.  I'm talking about VALOF/RESULTIS (get out your history
books, C hackers.  That's BCPL there).

As a quick review, this construction is used in this manner:

  a = VALOF command

where "command" is any command that can contain a RESULTIS command.  Thus
you can have SWITCH statements, FOR loops, WHILE loops, or just compound
statements that return values, with no restriction on the number of
RESULTIS's or their placement, as long as they are in the block.  The
command executes until a "RESULTIS expression" is encountered, at which
point the value of "expression" is returned as the value of the VALOF.
Actually, in C that would be VALOF/RETURN, except that RETURN isn't
guaranteed to return a value, and I'm sure many people would feel terribly
constrained by not being able to blow clean out of a subroutine with one
statement.

It's unlikely that many C programmers have used such an animal, so many
people reading this list probably won't appreciate it.  I have used it,
and it is very handy.  Other than the fuss and bother of adding another
piece of gunk to the language, is there any reason NOT to add this?

I also realize that this is a bit of a hefty feature to go proposing for
ANSI C, so I am just asking people to think about it.  Maybe in the
future, you know.  Fortran made it from 66 to 77 and they're planning an
88 (I've seen a draft of the standard, though it doesn't specifically
mention 1988 yet, you KNOW it will happen then).

David



More information about the Comp.lang.c mailing list