rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Difference Between ReScript Double-Quote String Literal and JS String

Open imjoshellis opened this issue 4 years ago • 3 comments

I was just reminded that the first time I tried a non-supported symbol in a double-quote string literal, I got very confused why it wasn't working.

I'm sure other JS devs would assume like me that strings work exactly like JS strings because the overview simply says "Same" and there's no reason for us to assume otherwise. A note that explains it's not quite the same would be nice, similar to the note on Int/Float.

I realize that "Proper unicode handling" is mentioned on Primitive types in the part about backticks, but I still think it would be helpful to have it mentioned exactly what the double-quote syntax does support.

imjoshellis avatar Mar 29 '21 03:03 imjoshellis

indeed, the current Unicode handling is not ideal. We are working to unify the double quotes and backtics

bobzhang avatar Mar 29 '21 11:03 bobzhang

indeed, the current Unicode handling is not ideal. We are working to unify the double quotes and backtics

I really don't mind there being a difference if there's a reason for strings to work this way.

I just want documentation so I (and other newcomers) can understand and predict the behavior of quote.

Without knowing the difference, I'm starting always using backtick because it appears safer and more predictable, but I'm not sure if there's a tradeoff

imjoshellis avatar Mar 29 '21 12:03 imjoshellis

@imjoshellis yeah I'd be open for an extra note for unicode support on the overview

ryyppy avatar Apr 01 '21 07:04 ryyppy

unicode is supported in both "" and `` strings now

fhammerschmidt avatar Mar 09 '24 23:03 fhammerschmidt