Re: Writing a Compiler: Lisp or Scheme or Haskell?



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 your
text editor then the obvious solution is to use an editor that uses
camlp4 and your own grammar itself.

This last sentence didn't parse for me.

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
.



Relevant Pages

  • Re: How Lisps Nested Notation Limits The Languages Utility
    ... «Some 99% of programers are not used to the nested parenthesis ... syntax can be considered a problem.» ... Why else has Lisp recovered from the AI Winter? ... Nowhere did I say people would have to struggle to appreciate parens, what I said was that it is not interesting if people who have never tried Lisp complain about the parens. ...
    (comp.lang.lisp)
  • Re: web development advice needed
    ... The facts are I was dragged kicking and screaming into ... When I started taking coding seriously learning the VB syntax and grammar ... It was all about pragmatism then and its all about ...
    (microsoft.public.dotnet.general)
  • Re: [OT] Syntax highlighting [was Re: Too much code - slicing]
    ... and grammar of English is buried deep in your brain. ... results in most languages pretty quickly. ... English grammar and syntax. ...
    (comp.lang.python)
  • Re: [News] Developers Embrace Java, Drop Visual Basic
    ... grammar have made their disdain for the legacy C syntax and grammar loud and ... dumbed down variant of Java intended to be used by VB developers. ... VB developers as a cultural phenomena have not generally become well known ...
    (microsoft.public.dotnet.general)
  • Re: Misplaced parenthesis
    ... The entire purpose of the parser component of a compiler is syntax ... Now the language, accepted by the compiler, is a subset of the ... grammar that describes an superset of the OPL language. ...
    (comp.lang.pascal.delphi.misc)