[comp.lang.c] C blocks

edw@IUS1.CS.CMU.EDU (Eddie Wyatt) (12/08/87)

   Could the ANSI committee consider adding return values for blocks?
If they where added, I could guarentee my macro arguments where only
evaluated once as they are in function calls. So please, please,
please consider adding them.

					Eddie Wyatt

-- 
That one looks Jewish -- And that one's a coon -- Who let all this riff raff
into the room -- There's one smoking a joint -- and Anoter with spots -- If
I had my way -- I'd have all of you shot ... Pink Floyd, "In the Flesh"
Eddie Wyatt 				e-mail: edw@ius1.cs.cmu.edu

karl@haddock.ISC.COM (Karl Heuer) (12/10/87)

In article <470@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>Could the ANSI committee consider adding return values for blocks?
>If they where added, I could guarentee my macro arguments where only
>evaluated once as they are in function calls.

I would be very surprised if ANSI C ever gets this enhancement.  It's too big
a language change in comparison to the magnitude of the problem being solved.
A more likely enhancement is the "inline" keyword (applied to functions),
which has already had some exposure in C++.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

dag@chinet.UUCP (Daniel A. Glasser) (12/11/87)

In article <470@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>Could the ANSI committee consider adding return values for blocks?
>If they where added, I could guarentee my macro arguments where only
>evaluated once as they are in function calls.

This is unlikely to make it anywhere into the C language.  It is,
however, a feature of Bliss, which has many of the same design features
and ancestors as C.

Bliss does have a much more powerful macro language too.

Pity Bliss is almost a dead language outside of the walls of DEC.
I think it may be dying inside the walls too.
-- 
					Daniel A. Glasser
					...!ihnp4!chinet!dag
					...!ihnp4!mwc!dag
					...!ihnp4!mwc!gorgon!dag
	One of those things that goes "BUMP!!! (ouch!)" in the night.

jabir@quintus.UUCP (Jabir Hussain) (12/13/87)

In article <1966@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> Pity Bliss is almost a dead language outside of the walls of DEC.
> I think it may be dying inside the walls too.

well, you know what they say: Bliss is Ignorance !-) 

(ok, so i wanted to see my name in print :-))

peter@sugar.UUCP (Peter da Silva) (12/15/87)

In article <470@PT.CS.CMU.EDU>, edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>    Could the ANSI committee consider adding return values for blocks?

How very BCPL of you.

> If they where added, I could guarentee my macro arguments where only
> evaluated once as they are in function calls. So please, please,
> please consider adding them.

They won't, because the only compiler I ever heard of that implemented
them was the version of Small-C I enhanced with all sorts of BCPLoid
features. ANSI's only adding stuff that's been around for awhile in
some sort of commercial compiler and has shown itself useful. Pity, but
you can see their point.
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.

dag@chinet.UUCP (Daniel A. Glasser) (12/16/87)

In article <463@trantor.quintus.UUCP> jabir@quintus.UUCP (Jabir Hussain) writes:
>In article <1966@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
>> Pity Bliss is almost a dead language outside of the walls of DEC.
>> I think it may be dying inside the walls too.
>
>well, you know what they say: Bliss is Ignorance !-) 

Actually, what they say is

  "...Bliss is Ignorance is Bliss is Ignorance is Bliss is Ignorance is..."

In my DEC days, some freinds of mine in the Methods and Tools group at
Spitbrook had teeshirts with this wrapped around the middle.

>(ok, so i wanted to see my name in print :-))

Well, now you have!

Now for a bit of text to satisfy inews...

In C, the following is effectivly a no op, it does something in bliss --
Anybody care to guess what?  (A is a scalar)

		A = A;
-- 
					Daniel A. Glasser
					...!ihnp4!chinet!dag
					...!ihnp4!mwc!dag
					...!ihnp4!mwc!gorgon!dag
	One of those things that goes "BUMP!!! (ouch!)" in the night.

jfh@killer.UUCP (John Haugh) (12/17/87)

In article <1990@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> 
> In C, the following is effectivly a no op, it does something in bliss --
> Anybody care to guess what?  (A is a scalar)
> 
> 		A = A;
> -- 
> 					Daniel A. Glasser

Yes - it has to do with those insipit dots.  If there weren't those willy
dots all over the place, the language might just be useful.  What it should
be (in C) is:

		A = &A;

or maybe its

		*A = A;

I can't remember, and that's why I don't use BLISS ...

- JOhn.
-- 
John F. Haugh II                  SNAIL:  HECI Exploration Co. Inc.
UUCP: ...!ihnp4!killer!jfh                11910 Greenville Ave, Suite 600
      ...!ihnp4!killer!rpp386!jfh         Dallas, TX. 75243
"Don't Have an Oil Well?  Then Buy One!"  (214) 231-0993

lmiller@venera.isi.edu (Larry Miller) (12/17/87)

In article <1990@chinet.UUCP> dag@chinet.UUCP (Daniel A. Glasser) writes:
>In article <463@trantor.quintus.UUCP> jabir@quintus.UUCP (Jabir Hussain) writes:
>>In article <1966@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
>>> Pity Bliss is almost a dead language outside of the walls of DEC.

>In C, the following is effectivly a no op, it does something in bliss --
>Anybody care to guess what?  (A is a scalar)
>
>		A = A;

A is assigned its address.  The equiv. no op is:

		A = .A;

(For Bliss programmers, their errors eludom [get it, "module" backwards!!??]).

Larry Miller				lmiller@venera.isi.edu (no uucp)
USC/ISI					213-822-1511
4676 Admiralty Way
Marina del Rey, CA. 90292

rwa@auvax.UUCP (Ross Alexander) (12/17/87)

In article <1990@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> In C, the following is effectivly a no op, it does something in bliss --
> Anybody care to guess what?  (A is a scalar)
> 		A = A;

Am I correct in thinking it does

		a = & a;

(the answer is written in C-style, of course, since this is the C group).
It's been a long while since I looked at a Bliss reference, & I have never
needed to code in it or had the opportunity, either.

In the same vein, does anybody want to explain why there is an 'auto'
keyword in C?  I have an answer (which doesn't really please me, I have
a higher opinion of DMR than that) but I'd like other opinions...

--
Ross Alexander @ Athabasca University
alberta!auvax!rwa

aeusemrs@csun.UUCP (News Manager) (12/17/87)

In article <470@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>Could the ANSI committee consider adding return values for blocks?
>If they where added, I could guarentee my macro arguments where only
>evaluated once as they are in function calls.

Ah, yes, the joys of gcc:

#define max(a, b) ({int _a=(a), _b=(b); _a > _b ? _a : _b; })

Nice, I think they missed something though because they do not appear to
want the more general form:

#define max(a, b) ({int _a=(a), _b=(b); return _a > _b ? _a : _b; })

Live and Learn...
-- 
Mike Stump, Cal State Univ, Northridge Comp Sci Department
uucp: {sdcrdcf, ihnp4, hplabs, ttidca, psivax, csustan}!csun!aeusemrs

jack@swlabs.UUCP (Jack Bonn) (12/17/87)

In article <1990@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> 
> In C, the following is effectivly a no op, it does something in bliss --
> Anybody care to guess what?  (A is a scalar)
> 
> 		A = A;

Doesn't this set A to the address of A?  If I remember my (over the shoulder) 
exposure to Bliss, a prefixed "." operator was required to get a value.  

A similar feature is present in C in that X (for an array X) is the same as
&X[0].  But in C it is a special case.  In Bliss, I think it is "the" way.

But wasn't addressing always in bytes?  For a 4 byte integer array A,

	B = A + 4;

wouldn't B be set to &A[1] in C terminology?  Especially ugly for pointers
to structures it would seem.
-- 
Jack Bonn, <> Software Labs, Ltd, Box 451, Easton CT  06612
uunet!swlabs!jack

gwyn@brl-smoke.ARPA (Doug Gwyn ) (12/20/87)

In article <970@csun.UUCP> aeusemrs@csun.UUCP (Mike Stump) writes:
>Nice, I think they missed something though because they do not appear to
>want the more general form:
>#define max(a, b) ({int _a=(a), _b=(b); return _a > _b ? _a : _b; })

But "return" already has meaning inside a block, so trying to use it
for some other purpose is potentially confusing, at least.

C as it has existed for quite some time now uses both expressions AND
statements.  Perhaps when you design the language "D" you can change
this.

linda@rtech.UUCP (Linda Mundy) (12/23/87)

In article <1990@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> In article <463@trantor.quintus.UUCP> jabir@quintus.UUCP (Jabir Hussain) writes:
> >In article <1966@chinet.UUCP>, dag@chinet.UUCP (Daniel A. Glasser) writes:
> >> Pity Bliss is almost a dead language outside of the walls of DEC.
> >> I think it may be dying inside the walls too.
> >
> >well, you know what they say: Bliss is Ignorance !-) 
> 
> Actually, what they say is
> 
>   "...Bliss is Ignorance is Bliss is Ignorance is Bliss is Ignorance is..."
> 
What we used to say was "Ignorance is BLISS/NOOBJECT"...

-- 
"The sun is but an egg, that hatches great things"

Linda Mundy	{ucbvax,decvax}!mtxinu!rtech!linda
		Relational Technology, Inc., Alameda, CA

peter@sugar.UUCP (Peter da Silva) (12/27/87)

In article <470@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>Could the ANSI committee consider adding return values for blocks?
>If they where added, I could guarentee my macro arguments where only
>evaluated once as they are in function calls.

Having started (I think) a BCPL discussion with my first response to this
message, I'd like to suggest a better way of doing this:

inline max(a, b)
int a, b;
{
	return a+b;
}

"inline" would, of course, imply static.

As for "prior art", how about S. McGeady's "inline" processor, recently posted
to the net, from which I shamefully stole the idea?
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.