Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Line breaks in parameter lists #2258

Closed
ryanflorence opened this Issue · 9 comments

5 participants

@ryanflorence

This is a syntax error:

foo = (
  bar
  baz
) ->

This is not

foo = ({
  bar
  baz
}) ->

Side-effect of destructuring assignment of parameters or intended behavior?

Personally, I'd like to be able to put line-breaks in my parameter lists just like you can with array and object definitions.

@showell

Seems like a reasonable request.

I'm used to Python, which allows this:

def foo(
  a,
  b,
  c,
  ): pass

Python doesn't go as far as comma-free syntax, but it does have the nice feature of ignoring the last comma.

CS allows this fairly ugly way of aligning parameters vertically:

foo = ( \
  a, \
  b, \
  c
) ->

Where the backslashes turn it essentially into this legal idiom:

yo = (a, b, c
) ->
@satyr
Collaborator

Or:

foo = ( a
      , b
      , c
      ) ->
@jashkenas
Owner

It's currently intended behavior (argument lists are supposed to be on one line) ... but we can certainly discuss it.

@ryanflorence

@jashkenas love it or hate it, AMD can create some pretty big function signatures when you have a lot of dependencies. An example from the dojo project https://github.com/dojo-toolkit-mirror/dojo/blob/master/dijit/Editor.js.

@showell

Even for a small list of parameters, I like the vertical style. I just find it a lot easier to scan text vertically than horizontally.

If nothing else, it's a bit of a wart that some rather bizarre multi-line styles can pass through the compiler, whereas the most natural one doesn't.

@jashkenas jashkenas closed this in 87257ea
@jashkenas
Owner

It's never going to be canonical style for any function def -- but I've added it for consistency with function calls and array bodies.

@satyr
Collaborator

Yay for another Coco-fication. (satyr/coco@519ab53)

@michaelficarra
Collaborator

@satyr: what's your most wanted coco-fication?

@ryanflorence

Yay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.