Newsgroups: comp.software-eng,comp.theory,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.kei.com!world!mv!moreira.mv.com!alberto
From: alberto@moreira.mv.com (Alberto C Moreira)
Subject: Re: Style: multiple returns and relatives
Distribution: inet
Message-ID: <alberto.534.00162922@moreira.mv.com>
Organization: MV Communications, Inc.
Date: Fri, 17 Nov 1995 03:09:29 GMT
References: <RMARTIN.95Nov10210926@oma.com> <dclineDHw7yv.Kx1@netcom.com> <4867u4$of1@ratty.wolfe.net> <alberto.529.00005178@moreira.mv.com> <48d026$eeq@Starbase.NeoSoft.COM>
X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
X-Nntp-Posting-Host: moreira.mv.com
Lines: 52
Xref: glinda.oz.cs.cmu.edu comp.software-eng:38942 comp.theory:14560 comp.lang.scheme:14312

In article <48d026$eeq@Starbase.NeoSoft.COM> claird@Starbase.NeoSoft.COM (Cameron Laird) writes:

>In article <alberto.529.00005178@moreira.mv.com>,
>Alberto C Moreira <alberto@moreira.mv.com> wrote:

>>      Use Scheme... No goto's, "returns", breaks, continues, jumps, 
>>      loops or side-effects; all the above is moot. 

>I'm mildly fond of the "X has less than Y, therefore X is better"
>argument myself, so I'll not dismiss this out of hand.  I think,
>though, that you're answering the wrong question. 

     I was referring to some of the problems people usually have
     to face when programing in C or similar. For example, GOTO's
     (Scheme needs none), multiple returns (there's no such concept;
     functions don't "return" anything but are evaluated for a value))
     or loops (recursion handles it efficiently and in a much more
     organized way). 

>Certainly Scheme is a fine language, with many advantages over C; however,
>it still has to answer comparable questions about style.  How,
>for example, do Schemers code a Fibonacci function, 

        (define fib
           (lambda (n)
               (if (< n 2)
                   n
                   (+ (fib (- n 1)) (fib (- n 2))  ))))

>or program an
>application to issue a modem wake-up on detecting that a stock
>price has surpassed the ambient temperature (but only if during
>daylight hours)? 

      Just like any other programming language. For chips which need
      to be poked at exact addresses, set! works like a charm.

>Invocations of "malloc" need never pollute
>Scheme source, but problems of resource management, conceptual
>blocking, and validation of pre-conditions remain.

       Maybe you could give some example of something that can't
       be just as efficiently done in Scheme as in any other programming
       language. Yes, there are quality concerns in any language; but
       functional languages, in my view, have shed a lot of trouble areas
       which still plague many modern programming languages.


                                           _alberto_



