From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: why not "stripes" in: (let ((zebra 'stripes) ... ; strings vs symbols? Date: Sun, 29 Dec 2013 08:00:43 -0800 (PST) Message-ID: References: <20131229142332.GA7972@boo.workgroup> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1388332879 7467 80.91.229.3 (29 Dec 2013 16:01:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Dec 2013 16:01:19 +0000 (UTC) To: Gregor Zattler , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 29 17:01:24 2013 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 1VxIno-0004Ug-Qa for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Dec 2013 17:01:20 +0100 Original-Received: from localhost ([::1]:55566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxIno-00046H-Dw for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Dec 2013 11:01:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxInW-000465-TP for help-gnu-emacs@gnu.org; Sun, 29 Dec 2013 11:01:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VxInO-0000ex-AT for help-gnu-emacs@gnu.org; Sun, 29 Dec 2013 11:01:02 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:24033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxInO-0000eh-47 for help-gnu-emacs@gnu.org; Sun, 29 Dec 2013 11:00:54 -0500 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBTG0nuo013149 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 29 Dec 2013 16:00:50 GMT Original-Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBTG0maw024843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 29 Dec 2013 16:00:49 GMT Original-Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBTG0mn1004675; Sun, 29 Dec 2013 16:00:48 GMT In-Reply-To: <20131229142332.GA7972@boo.workgroup> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6680.5000 (x86)] X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:95179 Archived-At: > ATM i read "An Introduction to Programming in Emacs Lisp". In > the section where the let function is explained in detail the > author, Robert J. Chassell, uses this "silly" example: >=20 > (let ((zebra 'stripes) > (tiger 'fierce)) > (message "One kind of animal has %s and another is %s." > zebra tiger)) >=20 > which when evaluated produces "One kind of animal has stripes and > another is fierce." as output. >=20 > The thing which makes me wonder is why he uses 'stripes instead > of "stripes" in this example. Either is OK. They both produce the same effect here. Use `C-h f format' to see what %s does (versus %S). > In the output of the message function it makes no difference but > to me it seems more natural to use strings here since they are > part of a string in the output... The beauty of %s is that you can print any Lisp object. For a symbol, its `symbol-name' is printed with %s. > I do not really understand how the 'stripes are different > to "stripes". Isn't 'stripes a notation for the symbol > stripes? This would mean there is the notion of a symbol which > is bound to noting? Yes, and yes. Here it is irrelevant whether the symbol `stripes' is bound to a value. A symbol can be used for various things in Lisp. For one thing, It can act as a variable, having a `symbol-value'. For another, it can act as a function, having a `symbol-function'. It can also act as a (rudimentary) OO object, having "slots" or "attributes", called its symbol "properties". These are stored on its `symbol-plist', and are accessed using `get' and `put'. And it need not have a non-nil value for any of these things, in which case it at least acts as an identity, having a `symbol-name'. Unlike strings "stripes" and "stripes", which might be `eq' but at least are `equal', (if in the same obarray) two symbols `stripes and `stripes are `eq'. They are the same Lisp object. For one thing, that generally saves space and makes comparison quicker. > Could somebody please enlighten me as to what the differences > between "stripes" and 'stripes are in which cases which notation > is more useful/natural? Natural is in the eye of the beholder. But symbols are powerful and easy to use in Lisp. They are used a lot.