Xref: utzoo comp.lang.lisp:3636 comp.lang.scheme:1660 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: Virtues of Lisp syntax Message-ID: Date: 13 Sep 90 12:52:42 GMT References: <33709@cup.portal.com> <1990Sep10.091911.20877@hellgate.utah.edu> <11048@cadillac.CAD.MCC.COM> <1990Sep12.021238.6859@Neon.Stanford.EDU> Sender: pcg@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 77 Nntp-Posting-Host: odin In-reply-to: andy@Neon.Stanford.EDU's message of 12 Sep 90 02:12:38 GMT On 12 Sep 90 02:12:38 GMT, andy@Neon.Stanford.EDU (Andy Freeman) said: andy> In article <11048@cadillac.CAD.MCC.COM> ned%cad@MCC.COM (Ned andy> Nowotny) writes: ned> In so far as extension languages are concerned, this is the most ned> important argument against unsugared Lisp syntax. Most people ned> learned mathematics with infix operators and most people are more ned> accustomed to communicating in a written form where keywords and ned> separators are the typical delimiters, obviating the need for ned> parenthesis or bracket matching. I would also like to observe that while providing users with a familiar, mathematical like syntax, may help sales, is is actually extremely misleading, because even if they look like mathemtical expressions, the semantics of expressions in programs are only weakly related to those of the mathamtical expressions they look similar to, especially for floating point, or unsigned in C (which actually uses modular arithmetic). andy> This makes a couple of assumptions that are unlikely to be true. andy> 1) We're not doing +,-,*,/ arithmetic, we're programming. (BTW - "+" andy> isn't really a binary operator, neither is "*"; there are andy> surprisingly few true binary, or unary, operations.) Precisely. Agreed. Even the semantics are different. andy> 2) One consequence is that binary and unary operators are the exception; andy> in fact, operators with arbitrary arity are common, or at least would andy> be if "modern" languages were as upto date as lisp. That being andy> the case, infix notation doesn't work and prefix notation requires andy> delimiters, which brings us back to lisp-like syntaxes. The real challenge here is that we want some syntax that says, apply this operator symbol to these arguments and return these value_s_. Even lisp syntax does not really allow us to easily produce multiple values. So either we say that after all all functions take just one argument and return one result (and they may be both structured), which may be an appealing solution, or we are stuck; mainly because our underlying mathematical habits do not cope well with program technology (and I am not happy with those that would like, like the functionalists, to reduce programming to what is compatible with *their* notion of maths). andy> As to the development of parsing technology, the state-of the art andy> syntax for n-ary operators, user-defined or system defined, is: andy> op() andy> I don't see that that is a big improvement over lisp syntax. Actually, there is state of the art technology for multiple arguments to multiple results, and it is *Forth* of all things, or maybe POP-2. A lot of power of Forth and Pop-2 indeed comes from their functions being able to map the top N arguments on the stack to a new top of M results. Maybe postfix is not that bad after all. Something like 10 3 / ( 10 and 3 replaced with 1 and 3 ) quot pop rem pop or with some sugaring like Pop-11. Another alternative is that used in languages like CDL or ALEPH, based on affix/2level grammar style, to junk function notation entirely, and just use imperative prefix syntax. Something like divide + 10 + 3 - quot - rem. I have seen substantial programs written like this, and this notation actually is not as verbose as it looks, and is remarkably clear. For example, Smalltalk syntax is essentially equivalent to this, as in: 10 dividedBy: 3 quotient: quot remainder: rem! There are many interesting alternatives... -- Piercarlo "Peter" Grandi | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk