Hacker News new | past | comments | ask | show | jobs | submit login

Honest question as someone who never got comfortable with Lisp languages. Is the code in parser.mud easy to read. One of those 100 line functions, could you jump to the middle of it and start understanding the meaning as someone familiar with C like languages? Even though I can figure out the syntax it looks like line noise to me but perhaps it is because i've not done much Lisp coding.



I wouldn't call that code easy to read, and that's coming as someone who has actually at some point learned enough MDL to actually know the syntax rather than have to reverse engineer it on the spot. There's a couple of reasons why that code is rough to read today:

- It's doing very complicated operations that operate on mutable global data, and structuring it as huge and deeply nested functions rather than splitting the operations up to smaller chunks with meaningful names. But you'd see exactly the same kind of thing in non-Lisp source code of that era; it's just different sensibilities.

- The code is incredibly heavy on conditionals. Which makes sense given the problem domain: parsing a pseudo-natural language. But MDL is a language where the conditionals kind of suck. COND is basically unreadable in any Lisp, you'd very rarely see people use it today. In CL you'd have more readable options like IF, WHEN and UNLESS. In MDL the only option is misusing short-circuiting AND/OR as a poor man's IF. Which they do in places, which doesn't help readability either.

- The use of angle brackets makes everything look like a sea of less-/greater -than comparisons. At least I just can't help it. It's especially bad when combined with the array indexing syntax.


> COND is basically unreadable in any Lisp, you'd very rarely see people use it today. In CL you'd have more readable options like IF, WHEN and UNLESS.

I wouldn't say "very rarely"; COND is still used for multi-way conditionals. Virtually everyone I know would write:

    (cond ((minusp x) 'negative)
          ((plusp  x) 'positive)
          (t          'zero))
Rather than:

    (if (minusp x)
        'negative
        (if (plusp x)
            'positive
            'zero))
IF, WHEN, and UNLESS are generally preferred where they fit nowadays, but I wouldn't call writing them with COND "basically unreadable", either, ie:

    (cond (pred then)
          (t    else))
    (cond (pred then))
    (cond ((not pred) then))
Compared to:

    (if pred then else)
    (when pred then)
    (unless pred then)


Indeed, I always thought COND was a construct sorely missing from other languages. Pattern matching is becoming popular for similar uses. I honestly feel it can go over board in many of the same ways though.


As someone very comfortable with Lisp languages: it is hard to read. Initially, the angle brackets do throw me off a bit.

Beyond that, I'd have to read the language manual to make sense of notations like ,foo and .bar.

The code makes a lot of references to non-local names. Someone reading the code would benefit from being familiar with the semantics of what those denote.

What's going on in those functions isn't "rocket science" though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: