Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!pipex!sunsite.doc.ic.ac.uk!warwick!bsmail!miki!jwl
From: jwl@miki.cs.bris.ac.uk (John Lloyd)
Subject: meta-programming, strong typing, and monads
Message-ID: <CztzuC.H1w@info.bris.ac.uk>
Sender: jwl@miki (John Lloyd)
Nntp-Posting-Host: miki.cs.bris.ac.uk
Organization: University of Bristol, Dept of Computer Science
Date: Fri, 25 Nov 1994 16:15:48 GMT
Lines: 34


When the dust has settled, history will show Fernando Pereira is correct in his
remarks about the dangers of the Prolog meta-programming style. Not only is
the claim of Prolog's supposed advantage of having equality of programs and data
irrelevant and misleading, it is also actually dangerous and leads to all the 
problems he described and more. The really nice way to handle this is via ADT's 
using a type for programs and providing whatever operations on this type that are 
needed. To see how this approach works out in detail for one language, see the 
Goedel book.

On the issue of strong typing, I really wish the people who are so critical of
this idea would just try a decent strongly typed language for a while to see
the overwhelming advantages it provides. It's enormously more convenient to 
have the parser say there's are error *HERE* than it is to spend ages in the 
debugger trying to figure out what's wrong. To give some evidence for this,
the virtually unanimous opinion of students at Bristol who have been exposed
to Prolog and Goedel is that they really don't want to have to go back to
Prolog after using Goedel for exactly this reason. By the way, an examination
of large-scale Goedel programs will prove that the synatactic overhead is small -
basically one line per predicate plus a small fixed overhead for the types, 
constants, and functions. This kind of objection to strong typing is not only
silly, it's also wrong. I say again, go and give a strongly typed language
a significant try and then write what you think about the idea. 

I was surprised to see monads compared with difference lists. There really is
much more to monads than this. In particular, the monadic approach to IO is, quite 
simply, stunningly beautiful. Mind you, it needs higher order, which is another 
good reason for moving in this direction. I recently implemented monadic IO 
for Escher (yes, Virginia there is an Escher!) and it works really well, providing
a truly declarative model of IO. If you want to read more about it, raid the
Glasgow FP ftp site and grab papers by Peyton-Jones and Wadler. (E.g.
"Imperative Functional Programming" by these two gives a good introduction).

John Lloyd
