Xref: utzoo comp.lang.prolog:2832 comp.lang.c:29621 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!cs.utexas.edu!samsung!usc!apple!sun-barr!newstop!sun!brahmand.Eng.Sun.COM!grover From: grover@brahmand.Eng.Sun.COM (Vinod Grover) Newsgroups: comp.lang.prolog,comp.lang.c Subject: Re: Proof that Prolog can be faster than C Keywords: Prolog, tak Message-ID: <137408@sun.Eng.Sun.COM> Date: 16 Jun 90 00:31:02 GMT References: <36986@ucbvax.BERKELEY.EDU> <1990Jun15.205242.16314@agate.berkeley.edu> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 16 In article <1990Jun15.205242.16314@agate.berkeley.edu> dankg@volcano.Berkeley.EDU (Dan KoGai) writes: >In article <36986@ucbvax.BERKELEY.EDU> vanroy@pisces.uucp () writes: >a1, a2, a3 to waste space and time. try the following. > >int tak(int x, int y, int z) >{ > return (x <= y) ? z : tak(tak(--x, y, z),tak(--y, z, x),tak(--z, x, y)) >} This program has a missing semicolon, and runs into an infinite loop. C does not require the side-effect in --x to happen immediately. You must force the subtraction. Furthermore, eliminating explicit temp variables does not mean that the compiler won't put them back in. However, declaring those explicit temps to be register variables *may* improve the program, but is not guarenteed to do so. Vinod Grover