The j
part in the original ocaml syntax is just like an ocaml attribute. Could have been any letter. A compiler/ppx might pass over it, pick up specific names like j
, and transform the string content accordingly.
As for why not just desugar foo
to {j|foo|}
, it’s because there are existing, edge-case reason callsites that already write {|$foo|}
(no interpolation). These would convert over to `foo`
, then desugar to {j|$foo|j}}
, and now suddenly the code doesn’t type because you need foo
in scope =|
The other reason is that desugaring to {j|foo|j}
is kinda BuckleScript-specific. During the making of it we intended it to be agnostic. Since now the syntax already is BS-specific, this justification disappears. And the previous one isn’t that good anymore imo. We in general don’t want code to break, but a one-time conversion breakable in order to make the experience much better later on might be worth it.
One last thing is that since this is namespaced, we can still reserve a proper, safer one for the unprefixed version.
Open to reconsider though. Also, your user.firstName
example already works. Just without proper unicode support.