Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!pipex!warwick!bsmail!miki!jwl
From: jwl@miki.cs.bris.ac.uk (John Lloyd)
Subject: Re: If-Then-Else (was: Re: Otherwise?)
Message-ID: <D4q1yK.ALK@info.bris.ac.uk>
Sender: jwl@miki (John Lloyd)
Nntp-Posting-Host: miki.cs.bris.ac.uk
Organization: Unviversity of Bristol, Dept of Computer Science
References: <D3x65E.JED@uceng.uc.edu> <3i1888$q7c@goanna.cs.rmit.edu.au> <9505502.26941@mulga.cs.mu.OZ.AU> <3ijuvd$fqi@goanna.cs.rmit.edu.au> <3ikadr$a95@news.irisa.fr> <D4I8DM.Mwq@info.bris.ac.uk> <9505704.23884@mulga.cs.mu.OZ.AU>
Date: Tue, 28 Feb 1995 17:59:07 GMT
Lines: 30

In article <9505704.23884@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU 
(Fergus Henderson) writes:
|> 
|> Yes, you are right - Goedel's (and NU-Prolog's) if-then-else is pretty
|> successful as a declarative replacement for Prolog's (C->A;B).
|> 
|> Unfortunately, it's not successful in doing so while retaining efficiency :-(.
|> 
|> The problem is that in both Goedel and NU-Prolog there is a run-time check
|> to see whether the non-local variables in the condition are ground.
|> This check is linear in the size of the terms to which those non-local
|> variables are bound.  In real-world programs, situations where those
|> terms are very large arise frequently.  The net implication of this is
|> that Goedel programs (or pure NU-Prolog programs) tend to run slower
|> than corresponding Prolog programs by a factor which is assymptotically
|> proportional to the amount of memory the program consumes!
|> 


I think this paints a picture which is a *tiny* bit more pessimistic than 
necessary :-). Mercury has very precise mode information which can be
exploited to completely eliminate such tests. However, Goedel programs (indeed 
programs in any language) can also be analysed and often one can eliminate 
many run-time tests. It's just a matter of the degree to which they can be
eliminated, not that such run-time tests are somehow inevitable in languages
other than Mercury.

In any case, whatever the language, the key ingredient here is analysis.

John Lloyd 
