Subject: Re: Functional programming and local variables.
From: Erik Naggum <erik@naggum.net>
Date: Mon, 14 Jan 2002 01:48:49 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3219961726545265@naggum.net>

* Thaddeus L Olczyk
| I posted a question to an emacs newsgroup recently along with some code.
| Someone came back saying that I should make my code more "functional".

  When people make this "suggestion", it may be useful to think of
  "functional" as the opposite of "dysfunctional".  Some people want all
  Lisps to be functional programming languages, but that is because they
  think Scheme is a Lisp, as Scheme is certainly closer to the functional
  programming style than Lisps.  Emacs Lisp in particular lacks the feature
  that it would make sense to call "functional": no lexical scope and no
  closures, meaning: no support for currying, the feature most commonly
  associated with functionaly programming style.  Please note that only
  fanatics would consider "functional style" valuable without reference to
  a purpose, requirement, or specification.  Stylistic complaints with no
  real impact on readability or functionality should be ignored.  I have
  seen people rewrite clean, readable code into a complex mess simply
  because it contained a "goto" that triggered some allergic reaction.

| The complaint, he fealt I used setf too much.

  Ignore that.  Lack of assignment to local variables is not the real
  measure of a "functional" programming style, any more than lack of "goto"
  makes code modular or whatever.

| To me it doesn't seem to make much of a difference.

  It makes absolutely no difference.  The close proximity of the binding
  and the setting removes any and all ambiguity as to the purpose of the
  code, and the only possible loss of value is that of "reasoning" about
  the code, as if anyone could reason about Emacs Lisp code to begin with.

  A vacuous gripe that code should be more "functional" is akin to the
  vacuous gripe that someone should be more "polite": Someone has a problem
  they fail to cope with on their own, so they ask you to do their work for
  them.  Just ignore such people; they have vastly different goals than
  helping you write _correct_ code.

  However, your code layout sucks.  :)  If you write Emacs Lisp code, use
  M-( and M-) to open and close lists, use C-j to jump to the next line
  with proper indentation.  If you insist on writing code as if you were in
  Word or something, at least use M-C-q when at the opening parenthesis of
  the top-level form.  If you disagree with the way Emacs indents your
  code, you are simply wrong.  Indentation is the law in Lisp.  I sometimes
  think compilers should gripe about indentation vs structure mismatches,
  but that would only really make sense if the editor was part of the whole
  Lisp environment.  In Emacs it is...

///
--