rhombus-prototype icon indicating copy to clipboard operation
rhombus-prototype copied to clipboard

Is that possible to have a S-exp "version" of rhombus?

Open yfzhe opened this issue 6 years ago • 7 comments

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?

yfzhe avatar Nov 09 '19 14:11 yfzhe

It must be perfect if there were some tools to convert new syntax code and s-exp code to each other.

NoahStoryM avatar Dec 16 '19 18:12 NoahStoryM

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 -> NewStxString
  • to-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 avatar Dec 16 '19 19:12 AlexKnauth

@AlexKnauth Is it necessary for s-expr to be indented well? Why not use some function to format code (just like some editors' work)?

NoahStoryM avatar Dec 16 '19 19:12 NoahStoryM

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.

chutcheson avatar Mar 07 '21 19:03 chutcheson

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.

jackfirth avatar Mar 07 '21 21:03 jackfirth

I don't think this is correct as stated. One author has gone off the rails, but otherwise ()s rock.

mfelleisen avatar Mar 07 '21 21:03 mfelleisen

There's rubies if you stay on the rails, tho.

rfindler avatar Mar 07 '21 22:03 rfindler