https://github.com/rongarret/ergolib/blob/master/core/bindin...
It's also helpful in preventing code from crawling off the right side of the screen.
However, like many of the sibling comments point out, if you think getting rid of the parens entirely is desirable then you have missed the point, which is that Lisp code is not text, it's a data structure, a linked list, and the textual representation of the code is just a serialization of that data structure. And the most straightforward way to serialize a linked list is with delimiters at the start and end, like so:
(1 2 3)
Indentation is a big guide, but can't do all the work.
I've also read that Julia is an acceptable Lisp [2].
1: https://news.ycombinator.com/item?id=36986769
2: https://mfiano.net/posts/2022-09-04-from-common-lisp-to-juli...
an answer to the post: https://gist.github.com/digikar99/24decb414ddfa15a220b27f674... (HN: https://news.ycombinator.com/item?id=32750052)
and BTW he's back to CL. https://mfiano.net/posts/2022-11-05-programming-languages-i-... (
there was a few more explanations and criticism of Julia on IRC (edit: found them) https://irclog.tymoon.eu/libera/%23commonlisp?around=1669837...
> I cannot consider Julia as a serious language anymore, for it has deceived me after 7 years of research.
> Basically, it took shortcuts, and the memory model of the host leaks in, in very unexpected and surprising ways. [TBC]
> It is disappointing, yes, but I do enjoy CL, with its many warts and all, so I am not as disappointed as I am glad to be back.
But parentheses aren't really that bad, after a while you get used to them and start seeing the actual structure behind them instead, kinda like that quote from The Matrix. Without them macros become much more complicated, especially if you want the syntax to be infix.
E.g. in Python indentation carries meaning. Ruby has "do/end"; but also it's possible to skip parentheses in some function calls; there are pipes too. Haskell - whatever haskell does, sometimes also pipes. There are more examples.
That being said, for me clojure parentheses were always more of a help than an inconvenience.
Could you give some examples? Or "all the punctuation" you are referring just to []?
With Common Lisp, you can define [ and { if you want to, but it's more common to use a reader macro character in front of an opening paren or a function name after it if you want different data structures. Those approaches scale.
But you said popular, so Javascript then. Seriously, JS is not what I'd consider a very good Lisp, but I think it is one because it allows you to build real lexical closures.
Edit: Haskell is a sort of a lisp too, and it's the only one IMHO that got rid of the parens in an intelligent way. Haskell lets you use either prefix or infix notation, and it works mostly without parentheses. Plus you can use the '$' character as a clever hack to remove parens where they would otherwise be needed. But...the price you pay for this is laziness and automatic currying, which most Lisps don't do.
There's: sweet-expression
https://srfi.schemers.org/srfi-110/srfi-110.html
https://sourceforge.net/p/readable/wiki/Examples/
define fibfast(n) ; Typical function notation
if {n < 2} ; Indentation, infix {...}
n ; Single expr = no new list
fibup(n 2 1 0) ; Simple function calls
define fibup(maxnum count n-1 n-2)
if {maxnum = count}
{n-1 + n-2}
fibup maxnum {count + 1} {n-1 + n-2} n-1
define factorial(n)
if {n <= 1}
1
{n * factorial{n - 1}} ; f{...} => f({...})In pipes, you can now bind variables that are in scope of later pipeline elements.
1> (flow "/usr/share/dict/words" ; start with this path
(file-get-lines) ; get content as list of lines
(let lines) ; bind lines variable to this list
len ; take length of list
rand ; get pseudo-random in [0, length)
lines) ; index into lines
"subdues"But that has a lot of pushback, and no scheme I've researched supported (implemented the SRFI) t-expressions out of the box. Usually it's some third party library or runtime you have to use for that.
Have played around a bit with it in GNU Guile, but in some circumstances I myself got confused :)
Thus: (if (< foo 0) (do-this) (do-that))
or if it's long
(when (< foo this)
(some-stuff)
(more-stuff)
...)
Obviously one can do this in C++ by introducing a block, but it isn't as syntactically natural; a block implies that there is important RAII involved, so usually I just do it by "vertical clumping"I find the standard c style (used by lots of languages) actually spreads the code out too much, emphasizing the curly braces rather than the code itself. (this is a local version of the OO+IDE plague that smears functionality across lots of tiny files.
This sense of locality is presumably why the gnu programming style is compact in some ways and expansive in others, different from K&R style, for example,
return-type function-name ( type1 arg1 ) {
allows the eye to see the identifiers without the syntactical markers () and {}, letting indentation and vertical whitespace to tell a story.
* except, de facto, Interlisp because it normally used a structure editor rather than a text editor.
Then, eventually, along comes Common Lisp with symbols like multiple-value-bind and update-instance-for-redefined-class.
I made a dialect called TXR Lisp in which most of the important symbols in the standard library are deliberately quite short, to avoid this readability/writability issue.
Lisp code often avoids vertical breaks within sections in a function, because many constructs nest, and so the nesting and indentation separates them already, like:
(while ...
...
(let ...
...))
(while ...
It's like point form: - abcde
- efgh
- jlk
- mn
- next pointhttps://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
https://www.draketo.de/proj/with-guise-and-guile/wisp-tutori...
(Along with the others already mentioned.)
see https://srfi.schemers.org/srfi-110/srfi-110.html
not too far from https://chrisdone.com/posts/z/ posted before
ps: personally, lisp syntax has been an issue once every 4 years. with threading macros, paredit .. you spend 0.00001% of your time thinking about it.
A single sexpr with only atoms could be written without parenthesis and with a EOL.
But no, genuine lisps come with parentheses (or some equivalent) because, as the name suggests, the entire point is list processing. Lisp programs are just data without (much) syntax. The more syntax you add, the less of a lisp it is.
It is quite far off. Just look at the version of "SICP in Javascript" (of which Julie Sussman was even one of the authors). The important points of the book are obscured by all the boilerplate and workarounds for the poor expressivity of the language.
[0] And conversely, Scheme doesn't have good expressivity as a scripting language.
Scripting languages are tightly coupled to the language they are scripting.