🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #68

Re: Wish List

#68
From: KW Heuer
Date: Sat, 22 Mar 1986 23:43
32 lines
1972 bytes
In article <429@batcomputer.TN.CORNELL.EDU> garry@batcomputer.TN.CORNELL.EDU
(Garry Wiegand) proposed a new syntax:
>	foo = ~foo;   -->   ~~foo; /* Means: please bitwise-complement foo */
>	foo = !foo;   -->   !!foo; /* Means: please logically-complement foo */
>
>Of course, screwily written (macros without proper parenthesizing, for
>example) existing programs would break.

"~~" would probably be safe since it's a no-op under current semantics;
but "!!" is actually used by some people to convert an int into a canonical
truth-value (i.e. map all non-zero values to 1).  I think this usage might
even be mentioned in K&R?  Anyway, C++ is designed to extend the C language,
as opposed to being a new language, so I suspect this is unacceptable.

Anyway, an equally useful operation is "foo = -foo".  Your notation doesn't
generalize; clearly we can't write "--foo" for this!

I'd like to see an binary operator ",," which is a generalization of the
postfix "++" and "--".  "e1,,e2" should evaluate e1, save the result,
evaluate e2, and return the saved result.  Given this, "x++" is "x,,++x"
and "x--" is "x,,--x".

Is it useful?  Consider the code fragment:
	free(p);
	return (p->value);
which makes the dangerous assumption that p->value is still valid after
free().  This should be written
	temp = p->value;
	free(p);
	return (temp);
but my notation would avoid the extra variable:
	return (p->value,, free(p));
Technical Details
Message-ID: <657@bentley.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!uwvax!topaz!bentley!kwh
References: <429@batcomputer.TN.CORNELL.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!uwvax!topaz!bentley!kwh
From: kwh@bentley.UUCP (KW Heuer)
Newsgroups: net.lang.c++
Subject: Re: Wish List
Message-ID: <657@bentley.UUCP>
Date: Sat, 22-Mar-86 18:43:45 EST
Article-I.D.: bentley.657
Posted: Sat Mar 22 18:43:45 1986
Date-Received: Tue, 25-Mar-86 03:06:26 EST
References: <429@batcomputer.TN.CORNELL.EDU>
Organization: AT&T Bell Laboratories, Liberty Corner
Lines: 32