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

usage from js_of_ocaml #36

Closed
joprice opened this issue Sep 19, 2020 · 4 comments
Closed

usage from js_of_ocaml #36

joprice opened this issue Sep 19, 2020 · 4 comments

Comments

@joprice
Copy link

joprice commented Sep 19, 2020

I get the error below when I call Soup.fold.

bigarray.ml:0 Uncaught RangeError: Maximum call stack size exceeded
    at adding (bigarray.ml:0)
    at add (bigarray.ml:0)
    at add_character (bigarray.ml:0)
    at bigarray.ml:0
    at caml_call1 (bigarray.ml:0)
    at reopen (bigarray.ml:0)
    at reconstruct_active_formatting_ (bigarray.ml:0)
    at in_body_mode_rules$0 (bigarray.ml:0)
    at in_body_mode_rules (bigarray.ml:0)
    at bigarray.ml:0

Is the library usable from js_of_ocaml 3.7, or maybe I'm doing something wrong?

@aantron
Copy link
Owner

aantron commented Sep 20, 2020

This is probably because the underlying HTML parser, Markup.ml, makes very heavy use of tail calls, and js_of_ocaml and/or JS engines don't have tail-call optimization. This is "tracked" in aantron/markup.ml#26. The reason for the quotes is that I'm not sure what can reasonably be done about it. Perhaps it has been addressed in newer versions of js_of_ocaml?

@dmbaturin
Copy link
Contributor

3.7.0 is the latest version, from August 05, so I assume its TCO support hasn't improved yet. It definitely should do something about it, I don't think any library ought to limits its use of TCO because one certain backend can't do it.

@joprice
Copy link
Author

joprice commented Sep 20, 2020

Thanks for the info. The same code is working great when targeting native, I was trying to see if I could reuse it in a web context. Luckily, it's not too much to rewrite using dom apis.

@aantron
Copy link
Owner

aantron commented Oct 9, 2020

Closing in favor of aantron/markup.ml#26.

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