From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: becoming a lisp developer Date: Wed, 27 Jun 2012 09:12:48 -0700 Message-ID: References: <87bokbb4zw.fsf@gnu.org> <4FE67DF4.1010903@mousecar.com> <8262af46dv.fsf@gmail.com> <87wr2uqms4.fsf_-_@kuiper.lan.informatimago.com> <4FEB2861.4040800@mousecar.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1340813594 31040 80.91.229.3 (27 Jun 2012 16:13:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 27 Jun 2012 16:13:14 +0000 (UTC) Cc: "Pascal J. Bourguignon" , help-gnu-emacs@gnu.org To: gebser@mousecar.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 27 18:13:11 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 1Sjurb-0006J2-Ds for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jun 2012 18:13:07 +0200 Original-Received: from localhost ([::1]:33414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sjurb-00044c-1g for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jun 2012 12:13:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjurR-00043a-F0 for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 12:13:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SjurL-00034Z-0G for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 12:12:57 -0400 Original-Received: from mail-bk0-f41.google.com ([209.85.214.41]:51127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjurK-00033r-Mv for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 12:12:50 -0400 Original-Received: by bkcjm19 with SMTP id jm19so1318093bkc.0 for ; Wed, 27 Jun 2012 09:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/V7JqXOkaWVbGGZq+0dvZtORjHccHLFmAPbVDGuo+Sw=; b=UOYaq2G48QlNJqFp5v7xBbMYcFUtD8hn48SMDlbc7uLDqcGvQUVttHGGvQHvp2fVZ/ 1gZGea7g3t41VrqTyJCNlLzkQXXNjy6Dc+42+h3hgJnHnIvOJ2xjnL8yFHGjGv9fJlOJ JcVAUcwzX2uTXlZ1FIjj+/fgtAu9sxC2GWCNswhS+r7ZQBo2Wh0kiprEZBHqHOWJ9Bil KaMMPkN1fFL60TsoB+sshbZHhBk7GOXYh14XfxMcsaQdpBgNw72Kb7W3H1hZblfrQsWj slimeXHayUfEFgATRM6PHcuqga2e9Y3wfug2e2OO3Wrr9L8CudAV8F8zDx+/aGtxBur7 FlUw== Original-Received: by 10.152.146.163 with SMTP id td3mr21607123lab.26.1340813568521; Wed, 27 Jun 2012 09:12:48 -0700 (PDT) Original-Received: by 10.112.5.102 with HTTP; Wed, 27 Jun 2012 09:12:48 -0700 (PDT) In-Reply-To: <4FEB2861.4040800@mousecar.com> X-Google-Sender-Auth: BytxIIFzzbsvCdsvUliGMD1R9DE X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.41 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:85522 Archived-At: On Wed, Jun 27, 2012 at 8:36 AM, ken wrote: > > > On 06/26/2012 08:29 AM Pascal J. Bourguignon wrote: ... >> =A0 =A0 (let ((a 1) >> =A0 =A0 =A0 =A0 =A0 (b 1111111112) >> =A0 =A0 =A0 =A0 =A0 (c 1111111113)) >> =A0 =A0 =A0 (setf a (+ b c))) >> >> in lisp. =A0But the syntac is irrelevant. =A0You can easily write a >> pre-processor to convert one into the other. >> (See for example: http://paste.lisp.org/display/25134) > > > Yes, the latter sort of expression, where the operand is at the beginning= of > the expression, is called reverse-polish. =A0There was at least one hand-= held > scientific calculator which came out in the mid-1970s which used this > notation. =A0Though it took only a few seconds to adjust one's thinking t= o > this syntax, that sort of syntax on such devices pretty much died out > (AFAIA), people, not surprisingly, preferring a notation which conformed > more closely to natural language. =A0Conforming to natural language has l= ong > been a goal of cyber-language developers, for understandable reasons: les= s > attention to syntactic anomolies allows for more attention to logic and s= o > too then probably better applications. > > But, yes, just this once instance is trivial. =A0Back in the 1980s I wrot= e an > expression parser (in C). =A0I remember being quite surprised how little = code > it required, just ten or twelve lines IIRC. =A0It was so pleasing in its > terseness and elegance that I assigned the same task to my college studen= ts > to exercise our discussion on recursion. =A0(To make it a homework assign= ment > they could do in a week, their C code needn't perform error checking, but > rather assume that all expressions their programs would read in were well > formed, nor would they need consider critically heavy burdens on the stac= k > due to very deep nesting.) =A0This function/program was intended to parse > C-style syntax (e.g., "(2 + (5 * 3))"), but it would be trivial to alter = it > to parse reverse-polish, or vice versa-- which offers up the question, wh= y > require text to be parsed to conform to one syntactical ruleset as oppose= d > to another? =A0The code for the parser is nigh identical... so why not cu= t > developers a small break by conforming more closely to natural language? a =3D b + c * d - e What happens first? Do you go left to right, assign b to a, add c to the result, multiply by d, and subtract e? No, in fact the assignment happens last, for mostly obvious reasons, and the multiplication happens first, because of some arbitrary convention. (setf a (- (+ b (* c d)) e)) It's different from natural language, but it's completely unambiguous, and in fact it's structured just like the tree you would have parsed the C-style expression into. Plus, it's exactly like the list data structure, which makes it easy for code to write code at runtime. Macros. You can define your own syntax. If you really wanted to, you could write a macro, call it `cparse', that would transform (cparse a =3D b + c * d - e) into (setf a (- (+ b (* c d)) e)) Load your macro at the beginning of the file, and you can use C-style expressions all you want. -PJ Gehm's Corollary to Clark's Law: Any technology distinguishable from magic is insufficiently advanced.