Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apostrophe breaks function name derivation. #80

Open
pkel opened this issue Oct 30, 2018 · 4 comments
Open

Apostrophe breaks function name derivation. #80

pkel opened this issue Oct 30, 2018 · 4 comments

Comments

@pkel
Copy link

pkel commented Oct 30, 2018

Consider the following signature:

module Date : sig get_day' : t -> int end

Using the function after deriving an implementation with gen_js_api results in an ugly runtime error. I suspect that the apostrophe finds a way into the javascript world.

@nojb
Copy link
Member

nojb commented Oct 30, 2018

What is the desired behaviour?

In general the name given in the interface is supposed to match the javascript name modulo casing and some other related conventions. Apostrophes are not valid inside identifiers in javascript, so probably it should not be used in the .mli to start with.

@alainfrisch
Copy link
Collaborator

It could make sense simply to drop those characters, thus allowing to bind multiple overloaded variants of JS functions.

@nojb
Copy link
Member

nojb commented Oct 30, 2018

Sure; but IIRC we can already do that today using underscores at the end of the identifier.

@pkel
Copy link
Author

pkel commented Oct 30, 2018

Overloading the function was my intended use case. After reading the documentation I expected gen_js_api to drop invalid characters. It says

When the naming is left implicit, a Javascript name is automatically derived from the OCaml name by applying the following rules:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants