From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeeds.belnet.be!news.belnet.be!news2.kpn.net!news.kpn.net!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader3.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Functional programming and local variables. References: <3c48f485.319044062@nntp.interaccess.com> Mail-Copies-To: never From: Erik Naggum Message-ID: <3219961726545265@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 49 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 14 Jan 2002 01:48:49 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader3.kpnqwest.net 1010972929 193.71.66.49 (Mon, 14 Jan 2002 02:48:49 MET) NNTP-Posting-Date: Mon, 14 Jan 2002 02:48:49 MET Xref: archiver1.google.com comp.lang.lisp:24211 * 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... /// --