From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Perl, etc has these "?"-prefix modifiers/codes/whatever. Precisely which does emacs have (and NOT have)? Date: Thu, 18 Feb 2010 12:46:14 +0100 Organization: Informatimago Message-ID: <877hqaojg9.fsf@galatea.lan.informatimago.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1266496853 18175 80.91.229.12 (18 Feb 2010 12:40:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Feb 2010 12:40:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 18 13:40:48 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ni5gP-00066V-8C for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Feb 2010 13:40:41 +0100 Original-Received: from localhost ([127.0.0.1]:52482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ni5gO-0005Hv-Le for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Feb 2010 07:40:40 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 129 Original-X-Trace: individual.net zeGFTtwpGlQwZ420+5IDawHFzBYdh8vj9Oh5JpEQSazIo1kdvz Cancel-Lock: sha1:MjllM2MzOTE1NTgwYmEwYmFhOTVkMGRmNDQzODU2MzhlNDc3MWYwMw== sha1:cnKQl9M/9wCXxRpWKWsMfKrIR7k= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:176856 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71923 Archived-At: dkcombs@panix.com (David Combs) writes: > Subj: Perl, etc has these "?"-prefix modifiers/codes/whatever. > Precisely which does emacs have (and NOT have)? > > > Please, someone, make an ascii or html table or even plain text > list of all these neat "new" non-standard ops that perl and > even php and ruby etc seem to have now, comparing them > to what Emacs has or don't have. emacs lisp has a lot of data types. But in lisp, the types are not associated to the variables, but to the values. Therefore names (symbols are used to name things in general in lisp) don't need to be marked in any special way. In lisps where there is both lexical bindings and dynamic bindings, such as Common Lisp, there's a convention to distinguish dynamic variable from lexical variables: - Dynamic variables are surrounded by stars: *variable* - Lexical variables are surrounded by nothing: variable in addition: - Constant variables are surrounded by pluses: +variable+ But in emacs lisp, there is only dynamic binding, so this convention is not applied by emacs lisp programmers in general (but Common Lisp programmers writing emacs lisp code tend to use it, so you may see it applied for *global-variables* vs. local-variables). Finally, in lisp, a name may have several meanings. We distinguish often the variable and the function meanings, and call lisps that distinguish them "lisp-2", while lisps that don't (eg. scheme or LeLisp) are called "lisp-1". But there are a lot of other meanings a name may take. For example, in emacs lisp, a same name may be used to variable, a function, a tagbody tag, a catch tag (catch also takes other objects), a block name, etc. And moreover, as a programmer, you can add new meanings to a name by writing new functions and macros (so the classifications should really be "lisp-infinity+1" vs. "lisp-infinity"). Anyways, the distinction of meaning of a name in lisp is not done by the form of the name, but by the context in which it is found. For example, in a function call, a name in first position is interpreted as a function name, while the same name in the other position would be interpreted as a variable name. In the case of a block name, the first argument (second position in the block form) is interpreted as a block name. (defun f (f) (1+ f)) (let ((f 41)) (block f (return-from f (f f)))) ; On this line, first f is a block name, ; second f is a function name, third f is a variable name. --> 42 Here is an non-exclusive example of the various meaning the name haha may be attached to in lisp: (require 'cl) (defmacro show (&rest exprs) `(progn ,@(mapcar (lambda (expr) `(insert (format "%60s = %S\n" ',expr ,expr))) exprs))) (defvar haha 0) (defun haha () 1) (progn (let ((haha 3)) (flet ((haha () 4)) (block haha (catch 'haha (tagbody (if (zerop haha) (go haha)) (print '(it was not zero)) (show haha (symbol-value 'haha) (haha) (funcall (function haha)) (funcall 'haha)) (throw 'haha nil) haha (print '(it was zero)) (show haha (symbol-value 'haha) (haha) (funcall (function haha)) (funcall 'haha)) (return-from haha t)))))) (show haha (symbol-value 'haha) (haha) (funcall (function haha)) (funcall 'haha))) (it was not zero) haha = 3 (symbol-value (quote haha)) = 3 (haha) = 4 (funcall (function haha)) = 4 (funcall (quote haha)) = 4 haha = 0 (symbol-value (quote haha)) = 0 (haha) = 1 (funcall (function haha)) = 1 (funcall (quote haha)) = 1 (In Common Lisp, output would be different, because it as lexical bindings as an additionnal meaning for names: (IT WAS NOT ZERO) HAHA = 3 (SYMBOL-VALUE 'HAHA) = 3 (HAHA) = 4 (FUNCALL #'HAHA) = 4 (FUNCALL 'HAHA) = 1 HAHA = 0 (SYMBOL-VALUE 'HAHA) = 0 (HAHA) = 1 (FUNCALL #'HAHA) = 1 (FUNCALL 'HAHA) = 1 ) -- __Pascal Bourguignon__