Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: Answers, Chapter 2: to point or not to point Message-ID: <6243:Nov720:29:4090@kramden.acf.nyu.edu> Date: 7 Nov 90 20:29:40 GMT References: <7006:Nov620:42:3990@kramden.acf.nyu.edu> <5088@lanl.gov> Organization: IR Lines: 27 In article <5088@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > From article <7006:Nov620:42:3990@kramden.acf.nyu.edu>, by brnstnd@kramden.acf.nyu.edu (Dan Bernstein): > > In article <5073@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > >> |> x(1,:) = x(2,:) [ I claim that this is an argument for array slices and copies, ] [ and has no bearing upon the pointer issue ] > That's not the point. The code (in existing languages) would > have to be written as: You are now *changing* what you said. I agree that your new version is relevant to this thread. I emphasize that your original x(1,:) = x(2,:) example was not. > Modula 2 C > for i := 1 to N do p = &x[1][0]; q = p+N; > x[1,i] := x[2,i] for (i=0; i end; *p++ = *q++; > (Modula 2 this time - I did Fortran last time.) The pointer/C version is > still be harder for the compiler to optimize. I take back what I said about this being relevant to the thread: your C code is incorrect. I believe that if you stated it correctly, the Convex compiler would be able to optimize it (specifically, vectorize it) the way you want. ---Dan