From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Style Issues in Lisp and Scheme programming, setq versus let ... and onion structure with multiple cores or eyes or kernels Re: string to list or string to array Date: Tue, 23 Oct 2012 10:15:07 +0200 Organization: Informatimago Message-ID: <87r4op4nas.fsf@kuiper.lan.informatimago.com> References: <62642868-f757-4115-a047-34c319a1c30f@o5g2000yqi.googlegroups.com> <87pq4c848a.fsf@kuiper.lan.informatimago.com> <4e87f58c-72fc-457b-8596-c792c39472e5@m4g2000yqb.googlegroups.com> <87zk3f7ey7.fsf@kuiper.lan.informatimago.com> <657d823b-990f-4a2b-a57c-2c644099ddcd@z2g2000yqj.googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1350980424 16323 80.91.229.3 (23 Oct 2012 08:20:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Oct 2012 08:20:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 23 10:20:29 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TQZin-0000Ld-8G for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Oct 2012 10:20:21 +0200 Original-Received: from localhost ([::1]:45656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQZif-00046A-HI for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Oct 2012 04:20:13 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs,comp.lang.lisp,comp.lang.scheme Original-Lines: 102 Original-X-Trace: individual.net wTms0bXheJu2sgjiBWFrwQKoQGMYYXqFSktpibl7JR8PtGasSXy/Eznp1nYClN8nH+ Cancel-Lock: sha1:NTM2NGM1NDlkZGM1NDBmNmQ0Yjg3NTFmZTI3ODg3NWEzODlmM2M1ZA== sha1:zRbvQ/eK+CNTPqJ8oUQ4jI6svxQ= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:195047 comp.emacs:102648 comp.lang.lisp:311485 comp.lang.scheme:89161 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87376 Archived-At: Swami Tota Ram Shankar writes: > Here are my questions. > > Does setq cause some kind of permanent persistence of the variable > like a global? > > In the lingo of computer science, such as lexical scoping, dynamic > scoping, static binding, dynamic binding, what is its meaning and what > is the meaning of these four terms? See http://www.informatimago.com/articles/usenet.html#Variables > I have found that let, and functional style leads to an onion type > structure. > > f(g(h(x,y),z,k(alpha,beta,l(theta)))w) > > If it is short, its not an issue, but the multiple cores or eyes of > the onion, makes it impossible to grasp the structure. No, the issue is when it's short, with short, unmeaningful names. If you use whole words and whole propositions as identifiers, then it can read as English. (mapcar (function list) (get-keys alist) (get-values alist)) vs. (m (f l) (k a) (v a)) > I ask you to focus your brain intensely and come up with some > COMPELLING rules of thumb, so I can write programs that are readable. Sorry, I don't have the time right now. > I want to apply to my own thing, but you also tell us how to read > these programs since when I look at yours, it becomes digestable only > after persisting with it and going to the cores and reading inward > out. The functions I presented you in this thread were procedural. You may be confused because in lisp, scope is limited to parentheses too. (when cond expr1 expr2) is different from: (mapcar fun expr1 expr2) You have to read the operator first. That's why it's in the first position in the lists: it's the most important thing you have to read to understand lisp code. And that's why lisp operators are rarely cryptic characters or single-letter. (The exceptions being +, -, *, etc, but originally it was PLUS, MINUS, MULTIPLY, etc). So when you read "when", you should know that it's a macro and that it has some specific rules of evaluation of its arguments. You should then read those arguments following those rules of evaluations. Namely, when evaluates its first argument, and if it returns true, then it evaluates in sequence the other arguments. This is not functional, this is procedural! On the other hand, when you read "mapcar", you should know that it's not a macro or a special operator, so it's a function, and therefore all its arguments are evaluated in order, and passed to the function that's called last. Here you have an "onion", since you have to read inside out to follow the flow of control. But with macros and special operators, the flow of control can be anything the macro is designed to implement. So you have to know your macros and special operators. > Whats your method or habit of reading? Read the reference. Common Lisp: http://www.lispworks.com/documentation/HyperSpec/Front/index.htm emacs lisp: An Introduction to Programming in Emacs Lisp http://www.gnu.org/software/emacs/emacs-lisp-intro/ or M-: (info "(eintr)Top") RET Emacs Lisp Manual http://www.gnu.org/software/emacs/manual/elisp.html or M-: (info "(elisp)Top") RET -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.