Message from discussion
How Lisp's Nested Notation Limits The Language's Utility
Path: g2news1.google.com!news2.google.com!news.glorb.com!feed.xsnews.nl!border-1.ams.xsnews.nl!news.astraweb.com!newsrouter-eu.astraweb.com!feeder.news-service.com!nntp-peering.plus.net!ptn-nntp-feeder01.plus.net!ptn-nntp-spool01.plus.net!ptn-nntp-reader02.plus.net!not-for-mail
Message-Id: <463bd92a$0$8743$ed2619ec@ptn-nntp-reader02.plus.net>
From: Jon Harrop <j...@ffconsultancy.com>
Subject: Re: How Lisp's Nested Notation Limits The Language's Utility
Newsgroups: comp.lang.lisp,comp.emacs,comp.lang.scheme,comp.lang.functional
Followup-To: comp.lang.lisp
Date: Sat, 05 May 2007 02:03:23 +0100
References: <1178323877.927816.20770@o5g2000hsb.googlegroups.com> <1178325041.606260.94840@w5g2000hsg.googlegroups.com>
Organization: Flying Frog Consultancy Ltd.
User-Agent: KNode/0.10.4
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
Lines: 50
NNTP-Posting-Host: 3b4ee463.ptn-nntp-reader02.plus.net
X-Trace: DXC=8nO<I39b:Ckg2_3e^YPGEoigd3Y`7Rb;n37XnI;[OUCdG`jPeGcW;ikl@D5?lP11_iXGbD9U[nCdj[b@W6IG?5je
X-Complaints-To: abuse@plus.net
Kaz Kylheku wrote:
> On May 4, 5:11 pm, Xah Lee <x...@xahlee.org> wrote:
>> (1) Some 99% of programers are not used to the nested parenthesis
>> syntax. This is a practical problem.
>
> Since 99% of programmers don't use Lisp, it's not a practical problem.
If you're being pedantic, you may mean "it is an uncommon practical
problem". However, the problem extends beyond Lisp.
Recent discussions have covered the use of pattern matching. In SML, OCaml,
Haskell (I believe) and F# you must write pattern matches over the expr
type in prefix notation. To borrow from Alan's example, the Lisp code:
(destructuring-bind (op1 (op2 n x) y) form
`(* ,n (* ,(simplify x) ,(simplify y)))))
((cons (eql *) *)
(destructuring-bind (op left right) form
(list op
(simplify left)
(simplify right))))
((cons (eql +)
(cons (eql 0)
(cons * null)))
could be written:
| n*x*y -> n*(x*y)
but in ML this must be written as a pattern match over a sum type where the
type constructors must use prefix notation:
| Mul(Mul(n, x), y) -> Mul(n, Mul(x, y))
While this is clearly much better than the Lisp, it would be preferable to
use the mathematical syntax in this case. You can address this in OCaml
using macros and there is a chance that F# will support overloaded
operators in patterns in the future.
Mathematica lets you do:
n x y -> n (x y)
but I don't know of any other languages that do, without forcing you to
reinvent the wheel via macros.
--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet