coffeescript shorthand object notation #1808

Closed
wants to merge 2 commits into
from

Projects

None yet

7 participants

@paulmars

salary = 50
name = "Joe"
dept = "Accounting"
employee = {salary, name, dept}
output = "#{employee.name} works in #{employee.dept}"

added to the docs

@jashkenas
Owner

Nice idea, but the documentation tries to use "real-world" examples as much as possible, and not foo and bar...

@paulmars

Glad to fix it. Let me see if I can figure out something more real.

On Oct 27, 2011, at 2:02 PM, Jeremy Ashkenasreply@reply.github.com wrote:

Nice idea, but the documentation tries to use "real-world" examples as much as possible, and not foo and bar...

Reply to this email directly or view it on GitHub:
#1808 (comment)

@gabehollombe

+1 to get this merged. If you're still unhappy with the example provided by @showell in the comment above, let's try to get something that makes sense to @jashkenas. I'm happy to suggest another example if needed. I'd just love to see this added to the docs soon, since it's a great feature and I get sad when the docs aren't as comprehensive as they could be. This feels like something we can surely get into the docs without too much more effort.

@michaelficarra
Collaborator

@gabehollombe: There are many important, undocumented features. If it really does bother you, want to take it upon yourself to document them all and open a pull request? I'd love to finally see comprehensive documentation.

@paulmars

@jashkenas, would the example @showell described suffice? I'm happy to update.

@gabehollombe

@michaelficarra I would absolutely love to help out and start documenting the important features you think need documentation. Do you want to throw a list of targets for me up on the wiki, or in an email? Either way, please just share the areas you think need mentioning or improvement and I'll totally take a crack at it. =-)

@michaelficarra
Collaborator

@gabehollombe: Well, you could start with the various nuances of our whitespace sensitivity. The numerous issues mentioning undocumented features are also a good starting point.

@michaelficarra
Collaborator

@gabehollombe: As part of my kickstarter project, I'll be compiling a comprehensive list of all (intentional) coffeescript features. It probably won't be comprehensive on my first try, but it'll be a good place to look for features that may be lacking in documentation. I'll post a link when I'm done.

@gabehollombe

Thanks, Michael. I'll look forward to your link for more documentation
inspiration. In the meantime, the undocumented tag for CS issues is a
great place to start chipping away.

On Sat, Jun 2, 2012 at 4:06 AM, Michael Ficarra <
reply@reply.github.com

wrote:

@gabehollombe: As part of my kickstarter project, I'll be compiling a
comprehensive list of all (intentional) coffeescript features. It probably
won't be comprehensive on my first try, but it'll be a good place to look
for features that may be lacking in documentation. I'll post a link when
I'm done.


Reply to this email directly or view it on GitHub:
#1808 (comment)

@paulmars

@showell I'd like to get this merged so I can make more improvements in the docs. Do you have merging abilities. If I make your recommended changes will this get merged?

@gabehollombe @michaelficarra Thanks for the support. Lets see if we can get this merged!

@showell
showell commented Jun 29, 2012

@paulmars Sorry, I don't have merge powers.

@paulmars

@jashkenas I believe the current code address all the thoughts brought up in this thread. Can you please merge?

@michaelficarra michaelficarra and 2 others commented on an outdated diff Jun 30, 2012
documentation/index.html.erb
@@ -418,6 +418,11 @@ Expressions
about it (say, when using jQuery).
</p>
<%= code_for('objects_reserved') %>
+ <p>
+ CoffeeScript has a shortcut for creating objects when you want the object name
@michaelficarra
michaelficarra Jun 30, 2012 collaborator

I would say "key name" here. LGTM otherwise.

@satyr
satyr Jun 30, 2012 collaborator

Note that number/string literals also work.

@paulmars
paulmars Jul 1, 2012

@michaelficarra done.

@satyr I'm going to leave that for a future commit and pull request. I'd like to get this merged after 8 months of waiting rather than complicate the pull request.

@michaelficarra
Collaborator

@gabehollombe: @paulmars:

I forgot to post back here with some undocumented features. Here's some that I thought of this week:

  • existential operators (#1631)
  • not in, not of, not instanceof
  • let-expressions (do (x = y) ->)
  • standalone extends
  • anonymous classes
  • condition-less switch
  • seq operator (;)
  • destructuring everywhere assignment happens
  • shallow copy (postfix [..])
  • heregex interpolation
  • binary literals (0b01010101)
@jashkenas
Owner

I'd be glad to merge, but first -- let's change the example to be something a little more exciting than Joe in accounting. Use your imagination.

@gabehollombe

OK. Pick a theme: Zombies, Super Powers, or Famous Movie Characters. I'll have fun with it... =-)

@GeoffreyBooth
Collaborator

Has this PR really been sitting open for five years just because no one can come up with a more exciting example than Joe in accounting? This PR is only for documentation, not a new feature. This object creation shorthand has actually been adopted by ES2015, and people probably have no idea that we pioneered it, because this never made it into the documentation.

Okay folks now’s your chance. The floodgates are open. Best example wins.

@GeoffreyBooth GeoffreyBooth added a commit that referenced this pull request Nov 21, 2016
@danielbayley danielbayley Docs shorthand object notation (#4356)
* Docs shorthand object notation

A simple but slightly more imaginative example of shorthand object notation.

Closes #1808.

Signed-off-by: Daniel Bayley <daniel.bayley@me.com>

* Update for new documentation folder structure

* Fix typo
6c759d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment