This is related to #899 but should be much more straightforward to implement.
Essentially a syntax translation from something like:
"Fifteen is ${a + b} and not ${2 * a + b}."
to
"Fifteen is " ^ (a + b) ^ " and not " ^ (2 * a + b) ^ "."
This also seems like a good first issue for one to dip ones toes into contributing. If someone could give me some pointers I'd be happy to give it a shot.
I have something started as a ppx. I still need to clean the code up enough to release but it may help as a starting point if you're interested. The target is currently format strings ("%s"/"%a"-style) but anything else could be used as a target.
Related: https://github.com/facebook/reason/pull/366. Note the PRs to free
` are still open.
On Feb 6, 2017 20:26, "Hezekiah M. Carty" notifications@github.com wrote:
I have something started as a ppx. I still need to clean the code up
enough to release but it may help as a starting point if you're interested.
The target is currently format strings ("%s"/"%a"-style) but anything
else could be used as a target.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/reason/issues/1040#issuecomment-277785689,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABEABQAGlVEtMZrecv_4WyMDX__KQ7ZSks5rZ3P_gaJpZM4L4btx
.
Wait, so there already is syntax for string interpolation with {|foo|}? How do you embed an expression in it?
If you are looking for an example, here is one. https://github.com/reasonml/rebel/blob/master/src/merlin.re#L93
@glennsl There is no interpolation in {|foo|} - that form is meant to allow unescaped content within a literal.
@hcarty %s would do fine. I had that exact same idea. It doesn't matter much to me what the exact syntax is, so if {| |} will do the trick too, that's fine by me. Otherwise I'd be happy to take a look at the ppx you've started on.
@hcarty ah, that's more commonly termed a raw string literal I think.
http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec250 - "quoted strings" in the OCaml manual. And yes it looks like raw string literal is used in at least a few other languages as the name for equivalent features.
BuckleScript now has a simple form of string interpolation: https://bloomberg.github.io/bucklescript/Manual.html#_unicode_support_with_string_interpolation_since_1_7_0
Some sugar would still be pretty _sweet_ though!
Most helpful comment
BuckleScript now has a simple form of string interpolation: https://bloomberg.github.io/bucklescript/Manual.html#_unicode_support_with_string_interpolation_since_1_7_0
Some sugar would still be pretty _sweet_ though!