russplaysguitar / navel

Working towards a linter for cfscript
MIT License
2 stars 0 forks source link

struct definitions: colons vs. equals signs #33

Open russplaysguitar opened 11 years ago

russplaysguitar commented 11 years ago

Since both equals and colon notation can be used in the newest versions of CF, should the linter prefer one or the other?

Examples:

var myStruct = {
   myValue: "value"
};

or

var myStruct = {
   myValue = "value"
};

Both of these are valid in CF 10 and Railo 4.

atuttle commented 11 years ago

Maybe we should support a target platform version? Otherwise I don't think it should matter. At worst I'd say throw up a warning that says colons are only supported on CF10+/etc.

cfjedimaster commented 11 years ago

I'd actually assume the latest (CF10), and would throw a warning for =.

atuttle commented 11 years ago

A warning for = is wrong, imo. It's not a bad practice, it's not going to cause problems on any platform, anywhere.

adamcameron commented 11 years ago

There's nothing wrong with an equals operator, and arguably it's more correct as the usage in CF is nothing to do with assigning property values to objects as it is in JS; it's a value assignment. For which we have the = operator. IMO the colon operator is mis-implemented in CFML, and the reason for adopting it was ludicrous... it was basically because people were claiming to be confused when switching from CFML to JS and back. The solution to that is to make sure one keeps up to date with one's ritalin dosage, not to monkey with the language.

At best there should be a switch to say "I want to use =" or "I want to use :", so that there's not a mishmash of them in the code (which would be sloppy, and the sort of thing CFLINT should warn against. But just warn).

cfjedimaster commented 11 years ago

I'd call it bad practice to mix and match em then at least. Not sure if linters though can tell if you have done X all the time versus Y.

On Thu, Apr 18, 2013 at 6:00 PM, Adam Tuttle notifications@github.comwrote:

A warning for = is wrong, imo. It's not a bad practice, it's not going to cause problems on any platform, anywhere.

— Reply to this email directly or view it on GitHubhttps://github.com/russplaysguitar/cflint/issues/33#issuecomment-16617916 .

Raymond Camden, Adobe Developer Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: cfjedimaster

cfjedimaster commented 11 years ago

I think if you've never done any type of 'short hand' assignment before, then you wouldn't know/expect one versus the other. If you've done anything with JSON, then you would expect the colon. All things being considered then, I say it makes sense to recommend the colon.

On Thu, Apr 18, 2013 at 6:14 PM, Adam notifications@github.com wrote:

There's nothing wrong with an equals operator, and arguably it's more correct as the usage in CF is nothing to do with assigning property values to objects as it is in JS; it's a value assignment. For which we have the = operator. IMO the colon operator is mis-implemented in CFML, and the reason for adopting it was ludicrous... it was basically because people were claiming to be confused when switching from CFML to JS and back. The solution to that is to make sure one keeps up to date with one's ritalin dosage, not to monkey with the language.

At best there should be a switch to say "I want to use =" or "I want to use :", so that there's not a mishmash of them in the code (which would be sloppy, and the sort of thing CFLINT should warn against. But just warn).

— Reply to this email directly or view it on GitHubhttps://github.com/russplaysguitar/cflint/issues/33#issuecomment-16618760 .

Raymond Camden, Adobe Developer Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: cfjedimaster

russplaysguitar commented 11 years ago

Other linters are able to tell if you've mixed tabs and spaces, so I'm expecting that we'd be able to write a rule for consistency, at the very least.

It would be nice if there were a consensus on what we'd prefer to see (one or the other). Using a linter is entirely optional (and all the rules should be optional, too), so I just consider it a way to strongly suggest what the community expects the code to look like.

Sure, we can read it either way, but which is nicer to look at?

cfjedimaster commented 11 years ago

If you ask me, colons. :)

On Thu, Apr 18, 2013 at 7:57 PM, Russ Spivey notifications@github.comwrote:

Other linters are able to tell if you've mixed tabs and spaces, so I'm expecting that we'd be able to write a rule for consistency, at the very least.

It would be nice if there were a consensus on what we'd prefer to see (one or the other). Using a linter is entirely optional (and all the rules should be optional, too), so I just consider it a way to strongly suggest what the community expects the code to look like.

Sure, we can read it either way, but which is nicer to look at?

— Reply to this email directly or view it on GitHubhttps://github.com/russplaysguitar/cflint/issues/33#issuecomment-16622184 .

Raymond Camden, Adobe Developer Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: cfjedimaster

adamcameron commented 11 years ago

I don't think it should favour either, specifically.

atuttle commented 11 years ago

I too think that colons "feel" better (entirely subjective, I do a shitload with json) but I also have a gut feeling that the percentage of ACF10 (in production) shops is extremely small... In fact I keep getting but by this difference because I use ACF10 locally but ACF9 in production.

For my own usage I would prefer to be able to indicate platform/version so that it yells at me for my colon habit.

If we could put a directive comment a in the head of the file for this sort of thing, that would be great:

//cflint:target-platform ACF9
russplaysguitar commented 11 years ago

@atuttle seems like another use-case for #6