3 ms·
(I have a subtle optimization for S-expression syntax)(I am surprised nobody ever thought of it)(When S-expressions are in a sequence use an extra (special) del
by igravious 12y ago
(I have a subtle optimization for S-expression syntax)(I am surprised nobody ever thought of it)(When S-expressions are in a sequence use an extra (special) delimiter plus the regular token separator to separate expressions)(Maybe use dot? (period I think some call it))
Like so. I think it could catch on. And you get rid of so many round bracket block delimiters (at least for S-expressions on the same level. for nesting you obviously need them) that it makes reading a lot easier. Also make the language modal and have the default be the indicative mood. Maybe replace "." with "?" for interrogative mood? Maybe elide ".)" to ")" as another optimization?
- lisper 12y agoYou'll love my binding-block macro then. You can find it here: https://github.com/rongarret/ergolib https://github.com/rongarret/ergolib
- igravious 12y agoInteresting. Now all I have to do is learn a bit of Common Lisp. I'm surprised my half-jokey question turned out to have a legitimate response :)
- roryokane 12y agoSo this code (from https://github.com/axch/test-manager/blob/c4fc3224e873716c58b07ffd35b38ad6c9881e87/ordered-map.scm#L32-L38 https://github.com/axch/test-manager/blob/c4fc3224e873716c58...) (define-record-type omap-entry (make-omap-entry key item next prev) omap-entry? (key omap-entry-key set-omap-entry-key!) (item omap-entry-item set-omap-entry-item!) (next omap-entry-next set-omap-entry-next!) (prev omap-entry-prev set-omap-entry-prev!)) would be written like this? (define-record-type omap-entry make-omap-entry key item next prev. omap-entry?, key omap-entry-key set-omap-entry-key!. item omap-entry-item set-omap-entry-item!. next omap-entry-next set-omap-entry-next!. prev omap-entry-prev set-omap-entry-prev!) (To mark `omap-entry?` as being a value, not the S-expression `(omap-entry?)`, I decided to place a comma after it instead of a period. The alternative is requiring no punctuation and making newlines significant.) Well, I suppose it does look better. However, the idea is of limited applicability. While looking through the example project (https://github.com/axch/test-manager https://github.com/axch/test-manager), I had trouble finding some code where this would actually be useful – most code has too much nesting. That’s why I prefer another solution for removing excess parens from Lisp syntax: making whitespace significant. It improves the syntax in cases where your periods would help, and it applies in additional cases as well. “Sweet-expressions” (http://readable.sourceforge.net/ http://readable.sourceforge.net/) is an implementation of that. Here is the above code ran through the `sweeten` tool to convert it to sweet-expressions: define-record-type omap-entry make-omap-entry key item next prev omap-entry? key omap-entry-key set-omap-entry-key! item omap-entry-item set-omap-entry-item! next omap-entry-next set-omap-entry-next! prev omap-entry-prev set-omap-entry-prev! Absolutely no parentheses necessary, while still preserving homoiconicity. You don’t even have to remember the `)` at the end of the last nested line. And I chose this example code to look good with your idea – when the code has more nesting, sweet-expressions look even better. About the interrogative mood `?` you describe: it might simplify `if` statements. But that would require removing the convention where boolean-returning functions have a name ending in `?`, such as `omap-entry?` in the example. It’s a tradeoff.
- igravious 12y agoSweet-expressions is a cool idea. Was it Python that started the whitespace-is-significant trend? I'm wondering why someone doesn't create a Scheme or a Lisp with this as valid syntax out of the box. I think you'd still need to support regular S-expressions though, right?