🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1439

Re: Compiler smartness?

#1439
From: Richard A. O'Keefe
Date: Fri, 23 Nov 1990 06:25
28 lines
1506 bytes
In article <DOWDING.90Nov16140150@palm.ai.sri.com>, 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.
Technical Details
Message-ID: <4358@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!samsung!munnari.oz.au!goanna!ok
References: <DOWDING.90Nov16140150@palm.ai.sri.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <DOWDING.90Nov16140150@palm.ai.sri.com>
Distribution: comp
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 28