Newsgroups: comp.lang.c++
Path: utzoo!utgpu!cunews!bnrgate!bigsur!bcars171!tor
From: tor@bcars171.UUCP (Rene Tio)
Subject: Re: simplifying C++
Message-ID: <1991Feb20.151041.17315@bigsur.uucp>
Sender: news@bigsur.uucp
Reply-To: tor@bcars171.UUCP (Rene Tio)
Organization: Bell-Northern Research, Ottawa, Canada
References:  <5.UUL1.3#8618@softrue.UUCP>
Date: Wed, 20 Feb 91 15:10:41 GMT

In article <5.UUL1.3#8618@softrue.UUCP>, kearns@softrue.UUCP (Steven Kearns) writes:
>
>Here is another in the continuing series:  "Simplifying C++".  
>
>Expression languages are languages where each statement returns a value.
[explanation deleted...]
>The advantage of this is manyfold: first, we get to eliminate the
>comma operator, which is used to evaluate multiple expressions as in
>(e1, e2, e3).  Instead, you can write {e1; e2; e3;}.  Also, we can
>eliminate the ugly (B ? e1 : e2) syntax, writing (if (B) e1; else e2;) 
>instead.
>
>Also, you can do things impossible before, for example declaring
>variables inside expressions:
>
>	if {int i = f(a, b); i >=3 && i <= 33;}
>		cout << "hi there";
>
>We probably want to disallow "gotos" and "returns" inside a compound
>statement used as an expression.  
>
>-steve
...
Being an advocate of functional programming styles, I am all for such a
change.  After several years of data flow languages I really miss such
constructs.  However, I can see several problems with this:

a. You can't disallow gotos and returns inside a compound statement unless
   you disallow it from all compound statements.  Otherwise, you end up with
   an inconsistent syntax for anything in between braces.

b. Expression languages invariably bring up the question of arity. How would
   you return more than one value from a function? e.g.,
        a, b = f(x);
	....
	int, int f(int y)
	{
	    return y+1,y+2;
	}
   Lisp gets around this by returning lists (sort of a dynamic structure). 
   Other programs have a syntax similar to that above.

What is really needed is a concerted effort to evolve C along more functional
lines.  That would alleviate many of the problems with porting C to parallel
applications.
