🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #620

Re: Why functional languages?

#620
From: Scott Draves
Date: Fri, 02 Oct 1992 01:06
85 lines
3602 bytes
>>>>> On 1 Oct 92 12:57:12 GMT, jamesh@castle.ed.ac.uk (James Hammerton) said:


jamesh> (define fac
jamesh>  (lambda (n)
jamesh>   ( if (= 0 n)
jamesh>     1
jamesh>     (* n (fac (- n 1))))))



jamesh> fun fac 0 = 1
jamesh> |   fac n = n * fac (n-1) ;


jamesh> Now which is easier to read?!!!

this is the standard argument one sees.  i agree that for this trivial
example the SML syntax is more quickly understood.  that's why some
language designers make this mistake.  it's a fine for a toy language.
and given SML's theoretical lineage, it's not surprising that things
ended up as they have (local optimization -> local maximum != global
maximimum).

but the answer to your question isn't important.  real programs aren't
that short.  large lisp functions retain their clarity.  large SML
functions are horrid messes.  this is taken from the compiler itself
(something i work on).  i didn't even have to try and find something
bad...  (* Copyright 1989 by AT&T Bell Laboratories *).

    and getroot(APP(VAR f,wl)) = (f,mix(wl,standardformals wl))
      | getroot(APP(LABEL f,wl)) = 
         (case know f 
            of KNOWN((vl,e),ref(SOME fmls)) => (f,mix(wl@(map VAR vl),fmls@fmls))
	     | KNOWN((vl,e),ref NONE) => 
                   (let val tmp = targeting(wl,vl,e)
                     in (f,tmp)
                    end)
	     | KNOWN_CHECK((vl,e),ref(SOME fmls),_) => (f,mix(wl@(map VAR vl),fmls@fmls))
	     | KNOWN_CHECK((vl,e),ref NONE,_) => 
                   (let val tmp = targeting(wl,vl,e)
                     in (f,tmp)
                    end)
	     | STANDARD _ => (f,mix(wl,standardformals wl))
	     | _ => die "a10 in CPSgen")




jamesh>  Even with such a simple example, it's not obvious that the
jamesh> close brackets at the end of the lisp version are enough,

i suppose you don't use an editor that matches ()s for you.


jamesh> where it's immediately obivous that the ML version has the
jamesh> correct syntax.

where's the obvious syntax error in this:

datatype foo = FOO of x
fun bar FOO x = x


jamesh> With long programs, the ease with which you can read them
jamesh> becomes very important. I can imagine that with a long lisp
jamesh> program, checking that all the brackets are in the right place
jamesh> could become a nightmare,

i've written a lot of SML and lisp code, and my experience is that
syntax (especially ()s) is not a problem in lisp, but that i do have
problems (understanding and writing) SML.


jamesh> ... As such many programs can be proven equivalent or correct
jamesh> mathematically in SML, since the notation is highly
jamesh> mathematical.

sigh.

if someone else would like to defend SML syntax, please do so...
-- 
			forms
Scott Draves		contracts
spot@cs.cmu.edu		standards
Technical Details
Message-ID: <BvGz2u.2rv.1@cs.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!spot
References: <TMB.92Sep28144424@arolla.idiap.ch> <annius.717696151@freyr> <TMB.92Sep28223555@arolla.idiap.ch> <26463@castle.ed.ac.uk>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.functional
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!spot
From: spot@CS.CMU.EDU (Scott Draves)
Subject: Re: Why functional languages?
In-Reply-To: jamesh@castle.ed.ac.uk's message of 1 Oct 92 12:57:12 GMT
Message-ID: <BvGz2u.2rv.1@cs.cmu.edu>
Originator: spot@HOPELESS.MESS.CS.CMU.EDU
Sender: root@cs.cmu.edu (System Manager)
Nntp-Posting-Host: hopeless.mess.cs.cmu.edu
Organization: School of Computer Science, Carnegie Mellon University
References: <TMB.92Sep28144424@arolla.idiap.ch> <annius.717696151@freyr>
 <TMB.92Sep28223555@arolla.idiap.ch> <26463@castle.ed.ac.uk>
Date: Fri, 2 Oct 1992 01:06:29 GMT
Lines: 85