Comments (4)
So, perhaps the style guide should say that although there is no such thing as a constant in JavaScript ... if you're using a variable as a constant, you may choose to put it in ALL_CAPS to communicate this.
@mjrusso: By the way, if you end up publishing this style guide online in a pretty HTML version (I'd recommend using the gh-pages branch), I'd be glad to link to it from coffeescript.org
from coffeescript-style-guide.
To simplify the overall discussion, I would like to broaden the scope of this ticket to include some of @jashkenas' comments from #2 re: the naming of constants:
For constants, use all uppercase with underscores
I don't think that this one is settled quite yet. In JavaScript, of course, until const lands, there's no such thing as a constant. For that reason, I think that simply using local variable style for constants may actually make more sense. I'm not sure which should be prescribed.
from coffeescript-style-guide.
I see the point that @jashkenas makes. I know that JS doesn't enforce true constants, but I like the ALL_CAPS convention for variables that are effectively read-only. Certainly, things like PI or FACEBOOK_API_ID should be ALL_CAPS, correct?
The biggest challenge for naming collisions is function names at top level scope. They can collide with local variable names in more narrow scopes. For me, the best resolution is to make sure that function names are distinct from local variable names in general, so all function names should include a verb, i.e prefer calculate_area to area for a function name.
from coffeescript-style-guide.
@jashkenas Yup, I think that's a good way to word it...put the emphasis on the fact there are no such things as a constant, and say that ALL_CAPS is only a convention or hint of intent.
from coffeescript-style-guide.
Related Issues (16)
- Add a suggested set of options for CoffeeLint HOT 2
- `(a)->` (no space) potential benefit HOT 1
- Module Imports example does not represent the style guide
- Style Guide Corrections ;) HOT 6
- Link to website broken HOT 2
- Optional commas for objects and arrays HOT 2
- Why 2 spaces? HOT 3
- How to Handle Docstrings HOT 6
- Why "Do not modify native objects"? HOT 1
- Multi line function calls HOT 1
- try without catch should be banned
- How do I set the indent to 4 spaces?
- Improve treatment of comments
- Replace or= with ?= HOT 2
- Why 2 spaces for tabs? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coffeescript-style-guide.