ocaml-sf / learn-ocaml

A Web Application for Learning OCaml
https://ocaml-sf.org/learn-ocaml/
MIT License
302 stars 66 forks source link

`Obj` cannot be used #364

Open HuStmpHrrr opened 4 years ago

HuStmpHrrr commented 4 years ago

Hi, I am developing an exercise in which we uses a generated parser in which it uses Obj. but it seems learn-ocaml blocks Obj. I am wondering is there any way out of this?

yurug commented 4 years ago

Hi @HuStmpHrrr. Obj is considered harmful, especially for beginners. For this reason, and also because it could generate safety issues when grading on the server-side, it is encouraged not to allow usage of Obj.

Now, I guess you can still let students use Obj by not calling ast_sanity_check in the grader.

HuStmpHrrr commented 4 years ago

I don't technically want students to use it but menhir generates code using it. I guess my ultimate question is how to make code generated by menhir work on LearnOCaml (by copying the code into prepare.ml?

HuStmpHrrr commented 4 years ago

to be more specific, it says Unbound module Obj.

lsylvestre commented 3 years ago

Hi, it is possible to use Obj in the toplevel (eg. prelude.ml, prepare.ml, test.ml, TryOCaml ...) by declaring %{ocaml-config:standard_library}/obj.cmi in https://github.com/ocaml-sf/learn-ocaml/blob/master/src/grader/dune#L86, and then recompiling Learn-OCaml.

Furthermore, the function Test_lib.ast_sanity_check prevents the student from using some modules (such as Obj and Pervasives) in his solution.