🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6172

Re: Expression Based Language

#6172
From: Peter da Silva
Date: Fri, 13 Jan 1989 23:05
53 lines
2030 bytes
  In article <2659@ficc.uu.net> I write:
> >Three comments: First,

> >	a = for(s1;e;s2)

> >	Is this legal? If e fails, is the value s1?

In article <11398@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes:
> I hadn't thought about that, but it's a reasonable definition -- provided the
> type of s1 matches the type of the body of the for statement.

I don't see why. After all, if you have an expression in current 'C' like:

	a = b ? c : d;

The types of c and d don't have to match. Why add an additional constraint
in the extended language?

> It does require
> saving the value of s1 before executing e, which is somewhat couterintuitive.

True. This might be a bit of a problem. I wonder if there's any way around
that...

> >I think the value of a statement with varying types is soluble by looking
> >at the coercion needed to use it in context.

> Context outside of the expression itself?  I think that's dangerous ground.

That's the way it currently works for ?:.

> Can you give an example of how one might use this?

int a;

	a = switch(nextchar()) {
		case '0': case '1': case '2': case '3':
		case '4': case '5': case '6': case '7':
			result 'O';
		case '8': case '9':
			result 'D':
		case 'A': case 'B': case 'C':
		case 'D': case 'E': case 'F':
			result 'X';
		default:
			result -1;
	}
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.
Technical Details
Message-ID: <2734@ficc.uu.net>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ficc!peter
References: <3300001@uxg.cso.uiuc.edu> <3290002@hpctdls.HP.COM> <11398@haddock.ima.isc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ficc!peter
From: peter@ficc.uu.net (Peter da Silva)
Newsgroups: comp.lang.misc
Subject: Re: Expression Based Language
Message-ID: <2734@ficc.uu.net>
Date: 13 Jan 89 23:05:58 GMT
References: <3300001@uxg.cso.uiuc.edu> <3290002@hpctdls.HP.COM> <11398@haddock.ima.isc.com>
Organization: Xenix Support
Lines: 53