coco icon indicating copy to clipboard operation
coco copied to clipboard

Property names and string literals

Open ceymard opened this issue 13 years ago • 11 comments

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.

ceymard avatar Sep 07 '11 07:09 ceymard

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?

satyr avatar Sep 07 '11 15:09 satyr

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

scribu avatar Sep 07 '11 15:09 scribu

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 ?

ceymard avatar Sep 07 '11 18:09 ceymard

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

satyr avatar Sep 08 '11 12:09 satyr

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.

ceymard avatar Sep 08 '11 13:09 ceymard

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

mikeaustin avatar Jun 04 '12 23:06 mikeaustin

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.

satyr avatar Jun 04 '12 23:06 satyr

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 avatar Jun 04 '12 23:06 scribu

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.

scribu avatar Jun 04 '12 23:06 scribu

\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

mikeaustin avatar Jun 05 '12 00:06 mikeaustin

@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

satyr avatar Jun 05 '12 00:06 satyr