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: How to quote a list of functions? Date: Tue, 18 Aug 2015 03:43:32 +0200 Organization: Informatimago Message-ID: <87wpwt9xrv.fsf@kuiper.lan.informatimago.com> References: <871tfdjqjx.fsf@mbork.pl> <87zj1vddkz.fsf@kuiper.lan.informatimago.com> <87mvxug2us.fsf@nl106-137-147.student.uu.se> <87vbch1gb0.fsf@nl106-137-147.student.uu.se> <87wpwudby7.fsf@nl106-137-147.student.uu.se> <87zj1qbwxs.fsf@kuiper.lan.informatimago.com> <87r3n2btjl.fsf@kuiper.lan.informatimago.com> <87mvxqbooi.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1439892753 6578 80.91.229.3 (18 Aug 2015 10:12:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Aug 2015 10:12:33 +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 Aug 18 12:12:26 2015 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 1ZRdsX-0004lh-FE for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2015 12:12:25 +0200 Original-Received: from localhost ([::1]:35591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRVyY-0007lu-8f for geh-help-gnu-emacs@m.gmane.org; Mon, 17 Aug 2015 21:46:06 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 97 Original-X-Trace: individual.net RncM6TKgk5LF++Zno4iLewmdIqIGysOh21sVfiX3urjDt1QArw Cancel-Lock: sha1:OWM4NGQ2N2U5MWI2NGZkMTMzMWVkMTY1ZjU1MGE0ZjMxODE4NjhlMA== sha1:5kDQnutUpk3hqx8Vit63aceUqKY= 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/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:214376 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:106657 Archived-At: Emanuel Berg writes: > "Pascal J. Bourguignon" > writes: > >> NO! This is the point exactly! >> >> upcase-region is NOT a function. It is a symbol that >> _designates_ a function. > > OK. But this isn't how I think. Is this - 1 - one? > Or is is a char that designates the digit one? Well, you better get up to speed, because this is how things are. '(#x1 #o1 #b1 1 1.) ; are all different representations of 1! --> (1 1 1 1 1) But in lisp, we often just don't consider the textual representation of the object, since both the source code and the data are sexps, we consider rather those lisp objects. 1 is 1, and "#x1" and "1" are two textual representation of the same object. In this case, there's no "number designator". But you could define such a thing and say for example that a string containing a representation of a number could designate a number, and you could define functions taking number designators: (defun number-designator-p (object) (or (numberp object) (numberp (car (read-from-string object))))) (list (number-designator-p 42) (number-designator-p "42")) --> (t t) (defun designated-number (nd) (assert (number-designator-p nd)) (if (numberp nd) nd (car (read-from-string nd)))) (defun plus (nda ndb) (+ (designated-number nda) (designated-number ndb))) (plus 1 "42") --> 43 > And, are you suggesting every time a function or > "function symbol designation" is used, the programmer > should check the context to determine if what is > expected is the function, or a symbol designating > a function? Yes, you should think about the type of the objects you pass to functions. To a function that takes a function designator, you can pass a symbol naming a function, or a function. To a function that takes a symbol, you can only pass a symbol. (quote f) returns the symbol f. (function f) returns the function named by f in the lexical scope. Therefore you cannot pass (function f) to put. Again, (cl-flet ((f () 'hi)) (put (function f) 'disabled nil)) Debugger entered--Lisp error: (wrong-type-argument symbolp (lambda nil (quote hi))) > And again, when and why are functions refered to not > using symbols to designate them? When you use themselves to refer to themselves. (let ((f (symbol-function 'sin))) (funcall f (/ pi 3))) --> 0.8660254037844386 > Isn't the most natural way to refer to a function (or > anything else) just to type its name? No, not in a language that treats functions as first class objects. > What are we gaining from having people and not > computers deal with this distinction? You are gaining that you can manipulate functions, have anonymous functions, write high order functions, etc. -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk