-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
WIP: implement #= ... =# multiline comments #6128
Conversation
Thanks so much for this. Does this have a hope of getting into 0.3? |
I shamelessly ripped this off but changed it to support |
(Copy-and-pasting my comments because that's what redundant PRs are for.) |
Without having tried it, I'm wondering what happens here:
In the worst case, if a variable named "result" were assigned somewhere, might not this compile but be completely wrong? This example is even more troubling than the one I posed at #69 (comment) |
Good point. The advantage of |
@StefanKarpinski, it's not true that you cannot end a line with This could theoretically happen with any
The basic issue here is that any two-character multiline comment delimiter |
It can, but editors tend to automatically prefix a bunch of lines with the comment character for you and people often put comments at the ends of lines. Now this can be mitigated by inserting spaces no matter what multiline combination we pick, but |
@StefanKarpinski, fair enough. I've amended the patch to use |
Here are starting frequencies of leading characters in base:
and ending frequences:
|
Now, back to the technical questions:
|
@StefanKarpinski, then maybe we should use Or go back to However, those statistics may be misleading. The main reason that I generally put |
Those statistics are misleading because Base is written to be pretty and readable. The question is what is convenient for debugging and quick modifications. I might want to format different when something fails and I want to comment out some part of the code. |
@ivarne, so therefore what delimiter are you arguing for, or what statistic should we look at? |
I agree that the statistics need to be interpreted a bit – and trailing |
@stevengj The best statistic (in my opinion) would be to make a poll that present the different solutions with pros and possible conflicts/ambiguities. This is about user convenience and pretty looking code, not technical reasoning. Stefans last comment is spot on by the way. |
How about something like:
Edit: I missed the discussion in #69 (ignore this) |
This is fine. Let's just go with |
WIP: implement #= ... =# multiline comments
Aww but issue #69 doesn't even have 100 comments yet. |
I'll be thrilled to never hear a word about multiline comments again. |
Not likely :) |
Time to spam |
If it's really intended as an emergencies-only feature, there's always |
Interestingly enough, re-reading the whole thread of #69 one can clearly notice that |
Remind me what the point of |
It seems nesting is not allowed. I think it would be nice if it was. |
I think the idea was to facilitate toggling the commenting of a section (changing You can do a similar thing in general without any special rules, with one more keystroke, changing |
Fixed nesting and threw in |
Thanks! |
Where's the tests? Also, somewhere you should mention that these are nesting. |
The REPL heuristics exist in several places. They are triggered when parsing returns an expression of the following form: (edit: fixed the form of the expression) |
Thanks @vtjnash, will look into it. (You know, I marked this pull request as a "WIP" for a reason.) |
This fixes #69, implementing
#= ... =#
multiline comments.(Several people had suggestedChanged to#= ... =#
instead, but#{ ... }#
has the advantage of exploiting automatic editor brace matching out of the box. Pascal forever!)#= .. =#
to make accidental multiline comments less likely (see below).It doesn't interact nicely with the REPL yet, because the REPL doesn't realize that
#{ ...
means that it should wait for more input. @loladiro, where is the end-of-input heuristic implemented in the REPL?I haven't documented it yet, for the simple reason that comment syntax is not currently documented anywhere(!) in the Julia manual as far as I can tell, and I couldn't figure out what section it should go into.