rhombus-prototype
rhombus-prototype copied to clipboard
Is that possible to have a S-exp "version" of rhombus?
Yes, I understand why infix notation is a goal of Racket 2 (or using the current project name, Rhombus). But there are some people love S-expression deeply. I'd like to write code in s-exp, while other (not syntactic) updates in Rhombus are also awesome. It would be great if I can use these updates in the ocean of parentheses.
IMO, the new syntax proposals now, make it not impossible to have a s-exp version syntax. So could we have one?
It must be perfect if there were some tools to convert new syntax code and s-exp code to each other.
A couple months ago I started to work on a new syntax proposal which would allow this two-way conversion. I don't like the existing non-s-exp syntax proposals very much because they don't seem close enough to s-expressions to make this bidirectional conversion nice or seamless.
Specifically, I want something like a bijection between s-expressions that are "well indented" and the new syntax, with:
from-sexpr : WellIndentedSExprString -> NewStxStringto-sexpr : NewStxString -> WellIndentedSExprString(well-indented-sexpr-string? s) => (string=? (to-sexpr (from-sexpr s)) s)(newstx-string? s) => (newstx-equiv? (from-sexpr (to-sexpr s)) s)
I've been trying to define the new syntax and to-sexpr and from-sexpr such that those equalities and equivalences are true, and I haven't gotten to that point yet.
I do think this is a good goal for a proposed s-expr replacement syntax to have.
@AlexKnauth Is it necessary for s-expr to be indented well? Why not use some function to format code (just like some editors' work)?
I'm a bit late to the discussion and I know that this is probably an old topic but I think some S-expressions are useful for a teaching language:
There are a lot of really good books written for lisp:
Structure and Interpretation of Computer Programs The "Little" Series (5 books - excl. ML & Java) LISP in Small Pieces Let Over Lambda How to Design Programs
Learning a language with S-expressions makes these books more readable.
At least for the How to Design Programs book, the experience of the authors of that book has been that the S-expressions made it more difficult for students, not less.
I don't think this is correct as stated. One author has gone off the rails, but otherwise ()s rock.
There's rubies if you stay on the rails, tho.