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

A lot of this is pure preference, and if we try to debate the merits of prefix vs infix operators we're just going to yell MY PREFERENCES ARE RIGHT AND YOURS AREN'T at each other until we get bored.

But there are some places where I think Lisp syntax is objectively worse than the alternatives. Parsing Lisp is easy because it shifts all the hard parts to the semantic layer. Everything looks so similar that you have to do a lot more reading, and memorization, to know what's going on at all.

----

To take a supposedly good example from elsewhere in this thread[0]:

> (do-a-thing b (+ a 5))

Is this a function call, or a thing that expands into something totally different? It matters, because (+ a 5) may not be something so trivial - it may have side effects, or be evalulated multiple times. (If it was a lazily evaluated pure function, there would arguably be no point to having macros at all.)

This one is trivially solvable by making macros visually distinct in some way, e.g. Rust's ! suffix, or C's convention of MACROS_YELLING_AT_YOU. It doesn't matter what the syntax is, as long as it exists.

----

Is (progn a b c) a function call or a special form? What about (proxy a b c) or (pregen a b c), both totally plausible names for functions? It's totally possible, even easy, to tell those things apart if you're paying attention, but you have to actually read the word at the start and comprehend it. In languages with dedicated syntax for this, you can just recognize { and } and instantly know what's going on, no need to involve the word-recognition parts of your brain at all. This sounds trivial - nearly all syntax decisions are - but it adds up when everything in the language is like this.

----

[0] https://news.ycombinator.com/item?id=33469932; I've renamed the macro here to make my point clearer, because the obvious response would be "well obviously someMacro is a macro", but in the real world people do not name their macros that.




> Is this a function call, or a thing that expands into something totally different?

There is editor support for that, or lookup methods at the REPL. Put a cursor on the symbol, hit some key.

I use Vim and TXR Lisp. This one liner:

  :nmap L "_y:execute ":!txr -e \"(doc '" . expand("<cword>") . ")\""<CR>:redraw<CR>
lets me look up standard language things by pressing L while the cursor is on a symbol like progn; it launches a browser window on the doc, and jumps to the section. For stuff that is in the code tree being worked on, there is jump to definition via tags.

> In languages with dedicated syntax for this, you can just recognize { and } and instantly know what's going on, ...

If you don't already know the construct, it may be hard to search for it, especially online.

Recently I wanted to see some examples of C++ lambdas in code bases. I tried searching for things like "[](" and "[]{" and whatnot on github; no luck.

> C's convention of MACROS_YELLING_AT_YOU.

Plenty of C macros (that do non-obvious evaluation) get written in lower case.

Even if you think you're sure something is a function call, that tells you little. You might know that it won't clobber the argument expression, but what you often need to know is what the construct does; and in the course of finding that out, you will find out whether it happens to be a macro.


I wrote a response saying what I do to counter these problems.. but actually, I think introducing some form of syntax to differentiate macros would be amazing. I wonder if macro symbols could be pulled automatically from packages and suffixed with ! if they are not so already. A new symbol could be added to the package so as not to internally affect the code. Thanks for the idea.




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

Search: