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: if vs. when vs. and: style question Date: Wed, 25 Mar 2015 08:12:01 +0100 Organization: Informatimago Message-ID: <87twx9360u.fsf@kuiper.lan.informatimago.com> References: <87sicvwckx.fsf@wmi.amu.edu.pl> <87wq27yvqg.fsf@debian.uxu> <8d531e99-7260-4263-ac99-09c6871e2708@googlegroups.com> <87vbhq53lf.fsf@debian.uxu> <87a8z23p23.fsf@kuiper.lan.informatimago.com> <87lhilx0cf.fsf@debian.uxu> 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 1427268031 22501 80.91.229.3 (25 Mar 2015 07:20:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Mar 2015 07:20:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 25 08:20:21 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 1Yafbw-0006Xh-0Y for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 08:20:20 +0100 Original-Received: from localhost ([::1]:36526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yafbv-0000m7-8t for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 03:20:19 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 80 Original-X-Trace: individual.net YwLjpclvehESfSuNjckH6gClK0GH6wa25YeXNP0SiI2yhG6Vsw Cancel-Lock: sha1:NWY3ZWI0NmVlZmQzNmYyYjI5YTFlYzgzMWM1NDE5Y2YwYmNiMjFjNw== sha1:0aSl340Gkib8Ijm5rC3PNPqhUIk= 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:211027 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:103308 Archived-At: Rusi writes: > On Wednesday, March 25, 2015 at 8:10:18 AM UTC+5:30, Emanuel Berg wrote: >> "Pascal J. Bourguignon" writes: >> >> > But then, why stop with +? >> > >> > You could use instead: >> > >> > (funcall (additive-operator (ring integer)) >> > (neutral-element (multiplicative-operator (ring >> > integer))) 5) ; 6 >> > >> > or something even more general? > > I find Pascal's example brilliant and hilarious. > In this case though, I slightly err on your (Emanuel) side. > > When I see the 1+, I have a stop (like um... er...) > Is that a number, an expression, a constant, a comment? > > Oh Oh.. Functions can start with digits (Yeah this is lisp...) Indeed, it is clear that the names 1+ and 1- are ill-choosen. Notably 1-!!! (1- x) == (- x 1) BUT Those are actually fundamental operators, more fundamental than addition and substration, both in a theoric way, and in practice with a lot of processors. They are the operators named succ(x) and pred(x) in pascal (which C lacks as independent operators, but have combined with updating with the pre- and post- complifications of ++x, x++, --x, and x--; C is THE crazy language). In axiomatic number/set theory, we only assume a number noted 0, and a succ(x) operation that let us build a new number from any number x. so 1 = succ(0) by definition. (= 1 (1+ 0)) You do not program it the other way around, defining 1+ from x and 1, you define 1 from 1+ and 0! And the proof, is that processors usually have an increment and a decrement operation even while they may lack a general load operation (working or any immediate word-sized number). So when you write x:=512; you may actually obtain a "load #511; incr" instruction sequence, ie. (1+ 511). So write: (defun succ (x) (1+ x)) (defun pred (x) (1- x)) or in elisp: (defalias 'succ '1+) (defalias 'pred '1-) and use (succ x) instead of (1+ x) or (+ x 1). (Remember that the only literal numbers allowed in a program source are 0 and 1; well, it's even better if you allow only 0 and (succ x)). -- __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