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
Lost semi-colon in Vue.js source code #1132
Comments
Just look at Code style and No semicolons unless necessary. I haven't issues with minimized Vue sources. How can we reproduce it? |
I don't write semicolons because they are not necessary. |
Thanks for the sharing. |
I would consider that broken. It does not follow the javascript standard. On Sat, Aug 8, 2015 at 7:58 PM, Charlie Li notifications@github.com wrote:
|
I believe that semicolons makes the code more readable, especially for developers that are accustomed to other programming languages such php, java, c/c++; Furtherless even when semicolons are not needed the engine use a feature called "semicolon insertion". So the engine recognizes that a semicolon is needed and automatically adds it. They are still needed in the final code, they are just automatically inserted when missing; From emca specs; When, as a Script or Module is parsed from left to right, a token (called the _offending token) is encountered that is not allowed by any production of the grammar, then a semicolon is _automatically inserted before the offending token if one or more of the following conditions is true:; it sounds to me like a missing semicolon is _corrected and automatically inserted_ and that a normal script _should_ have it, not that the semicolon is not needed; It is not written that unneeded semicolons are removed!!!; ....of course since the engine allows it anybody can use whichever style they prefer; kind regards; oh i forgot this... ; |
@yyx990803 i was only offering my POV on th matter and examining word by word emca specs. The reason i tend to use semicolons is about (!about!) the same that i have for declaring variables at the beginning of a function. The engine will automatically hoist any declaration, but the code is more clear when putting them just there where they will "end up" before being interpreted :-).
the final interpreted code will have missing ; in place and hoisted declarations it's called ASI not ASR ("R"emoval of unnecessary ;)...so the valid final statement after ASI will have its ";", not the other way around. For some reason some js developers will tell you (1) to put your var declarations at top to reflect the final code interpretation, but also tell you (!2) to avoid semicolons. So in one case they tell you to NOT rely of automation while in the other case they tell you to DO so. since js allows both forms: having something like PSR for Javascript would be good, at least a for the eyes/brain not having to adjust coding style when switching form 1 project to another. outside the scope of the discussion (and the fun of it :-) ) ...and....one final note.... ; just kidding...; kind regards and thank you so much for VUE.JS |
The whole point is that readability is subjective and neither approach is technically superior or "more correct". There's simply no point in complaining about whether other people's code uses it or not. |
I agree with you and i am not complaining! Maybe I wasn't clear (all the ; were just for fun). I was just expressing my point of view, the reason why i prefer not omitting semicolons and move all declarations on top and why a common style guideline among developers could be useful. PHP standard group has been very useful to te community. You can write php code in many ways but opening 10 different frameworks code and seeing the same style it's very helpful and saves you more than some time. |
@pine3ree As for my personal experience, I liked using semi because I come from a C/C++ background but after trying the no semi style I found it faster to code with and more readable. |
@posva same here, but i still prefer using it. As @yyx990803 says it's a matter of personal preference. var a = 1 + 2
++a are not valid js statements, but you are allowed to write code in that way. js ASI will transform them into a valid statements
the specs do not says that the ";" are removed from previous expressions because not needed, but that they are automatically added when missing. quoting emca 11.9: Certain ECMAScript statements MUST be terminated with semicolons (...). Such semicolons MAY always appear explicitly in the source text. For convenience, however, such semicolons MAY be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations. so we MAY do things the way we are more comfortable :-) quoting again: just quoting the specs: ...at the end of the preciding statement... it's fine for me reading code relying on ASI, many big projects are using it, but It feels more natural to me to add it in my own code just because the other programming language i use do not provide ASI. kind regards |
@pine3ree I guess we should avoid using |
@fnlctrl
Other than that I've never said to anyone what they should do....if you find me the line i will correct it because it's not what i intended. They only thing i was complaining about (this is a general topic, it has nothing to do with this project's community) is the fact that some js developers tells you to put declaration on top because the engine put them there and so it's more clear to have them there but at the same time they tell you to avoid ; even if the engine adds them. I believe that you should either advice to use both, forbid both or allow people to choose for themselves. But not advice to use one and not to use the other, because the reason behind both is the same: writing code closer to how is interpreted. Nobody should not feel sorry or more right than others for not using semicolons the same way nobody should feel sorry or more right for using them. Pls let stop this! I don't want this silly thing to turn into a religious struggle or spaghetti vs fettuccine. |
I'm not interested in this conversation and I don't think it belongs here. Feel free to discuss semicolons elsewhere. |
Hi 佑,
Thanks for your work, Vue is fantastic! But....
why not add a ";" to end each line of source code? when the code is compressed it appears to be a problem.
The text was updated successfully, but these errors were encountered: