Proof that Prolog can be faster than C

Vinod Grover grover at brahmand.Eng.Sun.COM
Sat Jun 16 10:31:02 AEST 1990


In article <1990Jun15.205242.16314 at agate.berkeley.edu> dankg at volcano.Berkeley.EDU (Dan KoGai) writes:
>In article <36986 at ucbvax.BERKELEY.EDU> vanroy at 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



More information about the Comp.lang.c mailing list