Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop <jon@xxxxxxxxxxxxxxxxx>
- Date: Thu, 28 May 2009 02:52:01 +0100
anonymous.c.lisper@xxxxxxxxx wrote:
On May 27, 7:19 pm, Jon Harrop <j...@xxxxxxxxxxxxxxxxx> wrote:
(defun fact (n) (if (<= n 1) 1 (* n (fact (1- n)))))
With five sets of superfluous parentheses to balance? No.
The parens are after the definition, how do they effect readability?
They clutter the line by adding far more tokens than necessary.
You can make syntactic sense of this even if you've never studied Lisp;
No way. Most programmers could not even decipher "(<= n 1)". Indeed, just
Do you seriously believe that?
Absolutely. Virtually all programmers would assume that (f x) is a
subexpression "f x" and not a function application.
look at the overwhelming majority of programmers who already expressed
very strong opinions about the awfulness of Lisp syntax.
I see a lot of /other/ problems with lisp, the syntax isn't one of
them.
I'm sure you've noticed people complaining about the syntax.
you just have to understand that understand that parentheses indicate
subordination.
And that they appear for no reason, as in "(n)", and that operators are
placed unconventionally.
I'm sorry, operators?
Do you mean like math operations?
Yes.
Order of operations confuses me, I hate remembering the rules.
I'm sure you can handle + - * / and probably also comparisons.
I /like/ that the parenthesis make the precedence obvious.
But they don't. You still have to contend with , ` ' # and the grammar
itself is still unconventional (e.g. prefix).
Maybe this is because I'm not really a math/science person.
I do think that makes a big difference. I found Mathematica daunting when I
starting learning it because you have @ // and so on. However, I did learn
it quite quickly.
If you wanted to use a radically different grammar that would break yourThis last sentence didn't parse for me.
text editor then the obvious solution is to use an editor that uses
camlp4 and your own grammar itself.
I mean: if you want to keep your extensible grammar and editor in sync then
just build upon a single shared grammar using camlp4.
Macros in OCaml and Lisp are no different in these respects. Both allow
you to add syntax extensions without breaking the editor's interpretation
of the grammar. Both provide complete flexibility so you can completely
alter the grammar including even lexical tokens. Choosing to do so has
the same disadvantages in terms of maintenance in both cases.
Neat, now only if you replaced that ugly Ocaml syntax with something
that has more parens.
:-)
You can write your code entirely in the OCaml AST if you like. :-)
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u
.
- Follow-Ups:
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: anonymous . c . lisper
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- References:
- Writing a Compiler: Lisp or Scheme or Haskell?
- From: iwritecode2
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Raffael Cavallaro
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Christopher C. Stacy
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: John Thingstad
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Adlai
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Nicolas Neuss
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: anonymous . c . lisper
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: gugamilare
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Kaz Kylheku
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: Jon Harrop
- Re: Writing a Compiler: Lisp or Scheme or Haskell?
- From: anonymous . c . lisper
- Writing a Compiler: Lisp or Scheme or Haskell?
- Prev by Date: Re: Writing a Compiler: Lisp or Scheme or Haskell?
- Next by Date: hdmi kabel gut , hdmi 10m , dvi link , blue magic hdmi kabel , dvi d kabel 10 , dvi kabel 18 , panasonic hdmi kabel , billige hdmi kabel , dvi anschlüsse , dvi ,
- Previous by thread: Re: Writing a Compiler: Lisp or Scheme or Haskell?
- Next by thread: Re: Writing a Compiler: Lisp or Scheme or Haskell?
- Index(es):
Relevant Pages
|