Just a curiosity question. Lucee does not seem to ...
# lucee
s
Just a curiosity question. Lucee does not seem to flag the following as a syntax error whereas Adobe CF does. Is this intentional?
Copy code
var somestruct = {
    param1: "1",
    param2: "2",
};
The trailing comma for param2 is what I am calling out. I also commonly see code examples displaying the above "error" in github and cfdocs.org - the OCD in me classifies this as a syntax error.
s
I guess Lucee is more fogiving about misplaced commas
I definitely would expect (and prefer) and error for that
m
I prefer lucee's choice, because it is more consistent with other languages. While I don't personally like having a trailing comma, I think it being more like the c's, java, javascript, rust, go, python is a good thing.
💯 1
d
Ignoring trailing commas is something modern ECMAScript parsers now ignore as well, so I think Lucee is just taking that approach
s
What is strange is that I have found the opposite with trailing semi-colons - ACF is more forgiving that LCF. Luckily both work fine when coded "right".
I did notice that Javascript ignore the trailing comma.
a
PHP too
Personally, I think it's sloppy. But hey. The thinking I believe is that it makes a diff easier to understand when adding new array items. Because it's just "one line change" not "one character on one line, and another whole line" And that's better than those oiks who effect the same thing by putting the commas first. Those ppl.... should be shot 😉
😂 3
🔫 1
😱 1
s
I hate that too. Microsoft SQL studio is a big offender of that. It annoys the crap out of me.
a
heh
e
While I don’t like the comma first, I can at least acknowledge it solves the git diff issue without trailing commas. ¯\_(ツ)_/¯
j
I personally don’t like comma first, they are like razor blades to my eyes .. LOL. With that being said I use to dislike trailing commas, but now I love them. Let’s say you are OCD like me and love properties in alphabetical order and use a line sort function from your editor of choice, you no longer have to go look for which line you need to add the comma to and remove from the last. Also, consistent with other languages and it would bug me when I return to ACF and have to remind myself it is not supported :-)
💯 1