Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!crackers!jjmhome!smds!rh From: rh@smds.UUCP (Richard Harter) Newsgroups: comp.lang.c Subject: Re: cond. op. on ='s LHS Summary: Missing the point? Message-ID: <328@smds.UUCP> Date: 18 Feb 91 06:29:37 GMT References: <11073@pasteur.Berkeley.EDU> <15184@smoke.brl.mil> <326@smds.UUCP> <15227@smoke.brl.mil> Organization: SMDS Inc., Concord, MA Lines: 28 In article <15227@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) writes: > In article <326@smds.UUCP> rh@smds.UUCP (Richard Harter) writes: > >> - > *(a==b?&c:&d) = 1; > >Seriously, there is a germ of a good idea here. > There are good ways of exploiting the ?: operator and bad ways. > The example being discussed is clearly among the latter. I agree that the example is a bad idea -- of using the ?: operator in C. For that matter the ?: operator is one of the uglier things in C. What the chap was doing was emulating a feature that is not in C or in most other languages, i.e. selected assignment. The idea is interesting although I am not sure it is worthwhile. For example you can do something like this is in C: static int a,b,c,d; static int *index[4] = {&a,&b,&c,&d}; .... *index[i] = some-expression; which is a round-about way of saying "set the i'th item in the list a,b,c,d to 'some-expression'". The point is that the example is an attempt to do something which C does not provide a natural way of doing. -- Richard Harter, Software Maintenance and Development Systems, Inc. Net address: jjmhome!smds!rh Phone: 508-369-7398 US Mail: SMDS Inc., PO Box 555, Concord MA 01742 This sentence no verb. This sentence short. This signature done.