-
Notifications
You must be signed in to change notification settings - Fork 2k
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
another indentation bordercase #3010
Comments
There are, like, 1000 of these. Please search next time. The error could be improved, so I guess I'll leave it open for that.
Not to my knowledge. |
is there any effort to writeup on the rules of CS? i mean nowhere does the homepage tell me this. i think it's important to tell people; also, with unfixed border-cases, it would be great to tell people to adhere to a certain 'best-practice style' to avoid breakage in the wild once something gets fixed. like "though you can write |
I think it'd actually be more surprised if, for some reason, some constructs of the language did not follow the same rules (usability not being taken into account) |
@Nami-Doc not sure i understand that |
A block is a indent, some lines, then a dedent. The reason why singe-line comments aren't part of this is because we just ignore them (since we don't "render" them). |
the documentation-worthy part of this is that block comments are rendered as JS comments, so they get a 100% ignorance from the next turtle down the way. this makes them exceptional since you can never do anything of computational relevance with them... they're not expressions since they cannot express computation, they're not expressions 'cause the cannot mix with expressions, yet the must obey the whitespace formatting rules of expressions. they end up as something that could, as far as JS is concerned, be placed almost anywhere (except inside a string literal) without affecting functionality at all. makes them an underdocumented strange beast... 'everything is an expression in CS', except for comments, which we ignore, and block comments, which are strange. btw i just found that there is also an identity crisis here ;-)
which rightly marks and delineates the culprit, but misidentifies it as HERECOMMENT, where the docs call it a block comment. now this is nitpicking on my part, sorry, just saying. |
That's the correct name.
They're Comments, which is part of Statement. |
... expression-phobic, indentation-scopic comments ... and underdocumented |
wait, what's the correct name? to quote (https://github.com/jashkenas/coffee-script/blob/master/src/grammar.coffee#L180) :
i fully get this. |
That's a tree. A "Statement" can be a "Return", a "STATEMENT" or a "Comment", which itself can be a "HERECOMMENT" (or nothing). |
yeah, i think i got the tree part.
as far as i understand it, a just found out you're serious ;-) i can do |
|
I would much prefer to ignore lines where after removing block comments, there is no code. if a
### comment ###
b() if a
b() I am sure there is an issue about this but what exactly are we gaining by having herecomments be statements? |
guess that's just how they were designed to be. your example above seems to ignore the intent that block comments should appear in the compiled source, which is a good thing. |
I don't see it that way, I presented the semantics of CoffeeScript, the output would still be if (a) {
/* comment */
b();
} In other words, the JavaScript output doesn't have necessarily anything to do with the comment block semantics in CoffeeScript. |
Let's lump this in with all of the other herecomments-should-be-parsed-in-a-far-better-way ... |
if true
### oops ###
x = 1 compiles now, via #4572. Sorry it took awhile. |
looks like this is becoming a habit: #2998
all of these will compile & run just fine:
but not this one:
the error message says, unhelpfully:
which makes it look like i had inserted an expression, not a comment at the point in question.
use case:
i like to comment on clauses etc before the indent when the comment is about the entire clause. that's ok with ordinary comments, but not w/ herecomments (which have the distinction to be preserved for the accidental JS aficionado).
incidentally, the error message is just as unhelpful in this case:
i can somehow understand & live w/ the first message, but this is bollocks: how can the last character on a line not be correctly indented? or have an unexpected indent? only line-initial linear whitespace followed by non-whitespace ('printing') characters can ever constitute indentation and is, therefore, the only eligible entity for this kind of complaint. other stuff–the rest of the line, blank lines, and, i'd've thought, comments, too–are simply not in a position for that (quite literally).
(i'll try and get a module online the next few days that does nothing but line-initial whitespace parsing. btw i was a little sad the other day when realizing that CS Redux would appear to have major issues concerning indentation, which seems to support my hunch that whitespace grammar should be kept apart from the rest of the language.)
The text was updated successfully, but these errors were encountered: