satyr / coco

Unfancy CoffeeScript
http://satyr.github.com/coco/
MIT License
499 stars 48 forks source link

Property names and string literals #93

Open ceymard opened 12 years ago

ceymard commented 12 years ago

Maybe it would be good to remove the ':' character from the \notation.

Right now : a = \b: 1 produces an error ; we have to write a = \b : 1

It's not really bothering, but it just would be nicer.

satyr commented 12 years ago

Hm, it's a trade-off. Take a look at package.co.

  1. homepage : \http://satyr.github.com/coco/
  2. \uglify-js : \1.0.6

The former would become invalid, meanwhile the latter would be able to remove the space before :. I'm unsure if we'd be happier.

And if : were to join ,/;, other punctuations like ./?/! also become debatable.

Personally I think it's user-friendlier to have less exceptional characters as possible. Opinions?

scribu commented 12 years ago

-1 on removing ':'. It helps distinguish labels from function invocations.

ceymard commented 12 years ago

scribu: how ? with a good syntax highlighter, the label will always look different. And a string is not a function ?

satyr: I get that this is one less character to type, but when a string is already > 10~15 letters, why not quoting them ?

satyr commented 12 years ago

One less character is the whole point of the syntax. Should length matter?

ceymard commented 12 years ago

One less character is the whole point of the syntax. Should length matter?

I agree :)

Though I (personnaly) found it nice to use it as a string with meaning, whereas I use "" whenever I'm having something more textual.

IE:

$ \.delete-button .text "Delete"

Plus, I configured vim to color it differently. Handy.

mikeaustin commented 12 years ago

I don't understand the purpose of "\" - it's just a string with one less character (")?

a = { "b": 1 } # JavaScript - pretty obvious

a = "b": 1 # Starting to feel ambiguous - true ? "b": 1

a = \b: 1 # This reminds me of "\b" - is \bb legal?

I've been following CoffeeScript and like what Coco "fixes", but I'm dubious of syntax that only removes a few keystrokes. I think it also makes it more confusing since you can do the same thing with two syntaxes and the usage is arbitrary. x = \a + "b" + 'c';

Just my 2c. I'm new here :) I've also looked at Kaffeine, which has a good feel to it, but the author doesn't have much time to work on it.

Mike

satyr commented 12 years ago

is \bb legal?

Sure.

but I'm dubious of syntax that only removes a few keystrokes.

Then transpilers like CoffeeScript/Coco, which exist purely for removing key strokes, is probably not for you.

scribu commented 12 years ago

transpilers like CoffeeScript/Coco, which exist purely for removing key strokes

I think that's inaccurate. The main goal, for CoffeeScript at least, isn't to remove key strokes, but to have a more expressive, yet forgiving, language. At least that's how I see it.

scribu commented 12 years ago

To clarify, "being more expressive" usually means "less keystrokes", but not always.

Also, you can reduce the length by 1 character, but severely impact readability in the process, which scores low on the "being more expressive" chart.

mikeaustin commented 12 years ago

\r\n === "r\n"? \ === "\"?

Maybe it's just the \ symbol I'm weary of since it's often used inside strings. But then again, " used inside strings can get pretty hairy too:

"\"hi\""

I'm not adverse to removing keystrokes - I prefer => over function(), implicit returns in lambdas, etc. - just not so much when it can be done in a very similar way.

Mike

satyr commented 12 years ago

@scribu:

I think that's inaccurate.

Uh yes, sometimes they add keystrokes as well. "Changing key strokes" is more accurate.

The main goal, for CoffeeScript at least, isn't to remove key strokes, but to have a more expressive, yet forgiving, language. At least that's how I see it.

Right. Jeremy wanted CoffeeScript to be a literate programming language, making it close to English as possible.

Coco's goal is a little different, as I believe English (or any natural language) is total crap.

@mikeaustin:

Maybe it's just the \ symbol I'm weary of since it's often used inside strings

I worried this as well, but there really were no other symbols that fit. See also: gkz/LiveScript#25