curimit / SugarCpp

SugarCpp is a language which can compile to C++11.
135 stars 13 forks source link

Dashes in identifier (like in LiveScript) #31

Open ozra opened 10 years ago

ozra commented 10 years ago

I've been coding LiveScript the last year, CS before that. Now it's time for C++ coding for the first time in ten years, and I'm happy too see this project, meaning I don't have to dust of my old C-transpiler Cython/Cytoc in perl.

What I love in LiveScript is the ability to use dashes in identifiers. Like in lisp. It really is so super natural. The dashed-identifier-names are translated to dashedIdentifierNames in the target code. Works like a charm.

I'm simply heavenly glad to see this project, must say!!

curimit commented 9 years ago

Thank you very much for your advice, the dash syntax looks good.

Implemented 0b508dc.

ozra commented 9 years ago

Neat! Glad to see you chose underscores as the target rather than humps :-) So much more suitable for C*.

As an elaborate exercise, they could even translate to either humps or underscores, depending on matching existing symbols (included from C* world). This of course would require a full C++11+ parser to build an AST from included C/C header files. All symbols defined in SC11 would obviously result in underscore target. May be worth keeping the mind open for for the long run. I'm however perfectly happy with having access to dashed identifiers as they are, happy happy joy joy.

I added a test case to the unit tests that breaks ( some-var-- ) - on your personal page.

curimit commented 9 years ago

Thank you for your test case : ) I choose underscores rather than humps, because I'm trying to follow Google C++ Style Guide.