Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"//" as comments ? #80

Closed
yunxing opened this issue Feb 9, 2016 · 11 comments
Closed

"//" as comments ? #80

yunxing opened this issue Feb 9, 2016 · 11 comments
Labels
KIND: FEATURE REQUEST Parser parsing reason code into an AST

Comments

@yunxing
Copy link
Contributor

yunxing commented Feb 9, 2016

Currently we only support "/*" as comment.

Should we also support the format of "//" ?

@jordwalke
Copy link
Member

Many people really love these. I wonder how we might represent them. In the simplest case, you could imagine merely formatting any comment that contains no newline as a line comment.

(* this comment*)

would become:

// this comment

The only downside is that when you parse in Reason:

/* This Comment */

It would be printed as a line comment.

There would also be an extra check to make sure you're not already inside of a comment (nested).

I don't have any strong opinion in support/opposition to line comments. However, I like that it makes the technology more familiar to people.

@cristianoc
Copy link
Contributor

This discussion points to a consequence of Reason's design that I had not thought about much.
Inside the language there's also a "ghost language": all the things that are parsed, but will never be printed.
For the sake of discussion, a simple implementation of // would be to just add it to parsing but not to printing. So it would always be converted to /* stuff */
Even without thinking about comments, there are probably ghost things already.

@jordwalke
Copy link
Member

Another example: (((3 + 2)))

@jordwalke
Copy link
Member

It seems people really want this. @yunxing, seems like a good first issue for contributors.

@yunxing
Copy link
Contributor Author

yunxing commented Mar 28, 2016

Yes, I was thinking about this as well (and I also really want this).

I haven't found a good solution except for Cristiano's idea. But maybe
people who is gonna work on this issue can come up with a better idea.

It seems people really want this. @yunxing https://github.com/yunxing,
seems like a good first issue for contributors.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#80 (comment)

@jordwalke
Copy link
Member

I think it's just as easy to add it to both parsing and printing. Shouldn't it just be as easy as printing comments with no newlines as //?
So you could write either of the following, and they both become normalized to // line comments.

// This is the same thing
/* This is the same thing */

@jordwalke
Copy link
Member

The only challenge here is making sure that the operator // is properly representable, but I believe we may have already taken care of that.

@bordoley
Copy link

Any update on this. In my brief experience using reason, this is by far the most frustrating limitation of the syntax.

@jordwalke
Copy link
Member

No update yet. We can probably just print any comment as a single line comment automatically that:

  1. Contains no newline: So /* this */ would be printed as // this.
  2. Is guaranteed by the formatter to not have any content after it on the same line. For example, if we know that the following could never happen:
/*we have to make sure  */ this could never happen

@adnelson
Copy link

adnelson commented Feb 5, 2019

I believe this can be closed due to the merging of #2254

@IwanKaramazow
Copy link
Contributor

Indeed, this is implemented and released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: FEATURE REQUEST Parser parsing reason code into an AST
Projects
None yet
Development

No branches or pull requests

8 participants