🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #387

Re: logic programs -> procedural lang?

#387
From: Jeff Dalton
Date: Wed, 04 Oct 1989 14:22
31 lines
1975 bytes
In article <2181@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes:
>Lisp needs types much worse than Prolog, because the Lisp equivalent
>of append/3 would be
>	(defun app (A Z)
>	    (if (endp A)			; check A
>		Z
>		(cons (car A)			; check A again
>		      (app (cdr A)		; check A again
>			   Z))))    
>where A gets checked three times.  In the code produced by a good Prolog
>compiler, this effectively happens just once, and is ``paid for'' by the
>`if'. 

Richard, I've seen this claim before (in Warren's paper, for example),
and I've always been a bit puzzled by it.  I would expect compiled
Lisp code to make only one check, not three.  And indeed, if I try
various Lisps where it's easy for me to read the compiled code
(such as Franz Lisp or KCL), it's clear that only one check is made.

However, in many Lisps there's only one check because the compiled
code for a car or cdr never includes a check.  That is, while some
Lisps might analyse the code to see whether a acheck might be 
needed, some certainly don't: they just emit the code to extract
the car or cdr, with no check.

It's fair to flame Lisp, or at least some Lisp implementations,
for being less safe.  It may even be fair to say Lisp needs types
more than Prolog does.  But I don't think it's fair to say Lisp
makes three checks, because it doesn't.

-- Jeff
Technical Details
Message-ID: <979@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!bloom-beacon!eru!luth!sunic!mcsun!ukc!edcastle!aiai!jeff
References: <27335@shemp.CS.UCLA.EDU> <869@gamera.cs.utexas.edu> <10822@eerie.acsu.Buffalo.EDU> <2181@munnari.oz.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!bloom-beacon!eru!luth!sunic!mcsun!ukc!edcastle!aiai!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Newsgroups: comp.lang.prolog
Subject: Re: logic programs -> procedural lang?
Keywords: Prolog, typing, compiler efficiency
Message-ID: <979@skye.ed.ac.uk>
Date: 4 Oct 89 14:22:18 GMT
References: <27335@shemp.CS.UCLA.EDU> <869@gamera.cs.utexas.edu> <10822@eerie.acsu.Buffalo.EDU> <2181@munnari.oz.au>
Reply-To: jeff@aiai.UUCP (Jeff Dalton)
Organization: AIAI, University of Edinburgh, Scotland
Lines: 31