Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 22 Oct 2012 18:47:12 -0500 From: Steve Thompson Newsgroups: comp.lang.c Subject: Re: Compatibility question Date: Mon, 22 Oct 2012 23:42:15 +0000 Organization: Friends of the Galactic Collective Message-ID: References: <0.a87a1c8a472d870b0466.20121022022701BST.87y5izxpne.fsf@bsb.me.uk> <2nYjPo.Krd.2aRbe@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: NN 6.4.3 Lines: 66 X-Trace: sv3-figVCpRdJnyklhUt0KoVE4Kh1UqWOzHeUQH/dtElJQg+Ial8BTwnMUM9CbVq/lF6DQ/HwJCvnS671Xv!w1lPPulrrix4fsyYxMUzqq1AdUUxiDeOm8HEd9u6aapzPi06KGLGp2tdKLzVLQ== X-Complaints-To: www.supernews.com/docs/abuse.html X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3078 X-Received-Bytes: 3219 Xref: csiph.com comp.lang.c:27551 On Mon, Oct 22, 2012 at 10:44:11PM +0100, BartC wrote: > "Steve Thompson" wrote in message > news:2nYjPo.Krd.2aRbe@gmail.com... > > >When I was > >less experienced with C, I was confused by the fact that variables > >defined as structures were not pointers: > > > >struct point { > >int x, y, z; > >}; > > > >struct point a; > > > > > >One cannot reference 'a' (as such) in an expression even though it is > >a pointer in the implementation because C allows one to use structures > >as arguments to a function. I'd never do that in my own code, but > >some people may like the fact that they can pass complex data > >structures around as if they were simple variables. I think it wastes > >resources, but of course that is less of an issue today than it was > >when C was first developed. > > What about this struct: > > struct { > char r,g,b,a; > } c; > > It would be less efficient to pass a pointer to this value, than to pass the > value itself (especially when the pointer could well be wider). Returning > such a struct as a value from a function is also far simpler. I have my doubts about that, at least on anything like a contemporary x86 machine. > In any case C gives you the choice of pass-by-value or pass-by-reference - > for structs. > > (What confuses *me* in some languages (it seems most of them these days) is > stuff like this: > > a=[10,20,30] > b=a > > a[0]=9999 # modify a > > print a > print b > > You modify a, and find that b has also changed! Yet if a and b were numbers, > you could 'modify' a after b=a, and b is not affected!) > > This is pass-by-reference taken to extremes. That's gross. Who would ever do such a thing and in what language? Regards, Steve Thompson -- GOTO's are like guns. Safety is entirely contingent on the user.