🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1418

Compiler smartness?

#1418
From: John Dowding
Date: Fri, 16 Nov 1990 22:01
29 lines
1064 bytes
I was poking around in some old code, and came across the following
clauses (names changed to protect the inocent):

foo(Term, Term):-
	(var(Term) ; atomic(Term)),
	!.
foo([Head|Tail], Result):-
	...


I was wondering if the following is more efficient:

foo(Term, Term):-
	var(Term),
	!.
foo(Term, Term):-
	atomic(Term),
	!.
foo([Head|Tail], Result):-
	...


Are Prolog compilers (particularly, Quintus version 2.4) smart enough 
index correctly on the 1st argument in either or both of these cases?

Thanks,
John Dowding
dowding@ai.sri.com
Technical Details
Message-ID: <DOWDING.90Nov16140150@palm.ai.sri.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!Teknowledge.COM!unix!unix.sri.com!dowding

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!Teknowledge.COM!unix!unix.sri.com!dowding
From: dowding@ai.sri.com (John Dowding)
Newsgroups: comp.lang.prolog
Subject: Compiler smartness?
Message-ID: <DOWDING.90Nov16140150@palm.ai.sri.com>
Date: 16 Nov 90 22:01:50 GMT
Sender: news@unix.SRI.COM
Distribution: comp
Organization: SRI International, Menlo Park, CA
Lines: 29