Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Compiler smartness? Message-ID: <4358@goanna.cs.rmit.oz.au> Date: 23 Nov 90 06:25:07 GMT References: Distribution: comp Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 28 In article , dowding@ai.sri.com (John Dowding) writes: > I was wondering if the following is more efficient: > > foo(Term, Term):- > var(Term), > !. > foo(Term, Term):- > atomic(Term), > !. > foo([Head|Tail], Result):- > ... There is only one way to tell: MEASURE IT AND SEE. I am profoundly suspicious of a piece of code which tests for var, atomic, and then list. I suspect that there are far grosser efficiency issues to worry about. If it calls (=..)/2 you should eliminate that _first_. > Are Prolog compilers (particularly, Quintus version 2.4) smart enough > index correctly on the 1st argument in either or both of these cases? *CORRECTLY* yes, in that the code will work. Was QP2.4 first-argument indexing aware of type tests? No. Should you worry about that? It all depends on what the rest of your code is like: if you have calls to univ (=..) in there, you have more important things to worry about. -- I am not now and never have been a member of Mensa. -- Ariadne.