Indeed. But I think you have pretty much exhausted the possibilities here. I always feel that ocaml
is missing a great opportunity not to be more friendly to writing scripts. But doing so would require quite a bit of good and well coordinated design, not something the eco-system is known for (and backward compatibility problems quickly quick in).
Problems abound,type checkability, mess and no proper strategy around exit codes, and of course the split you mention between compilable sources and non-compilable ones with directives.
Regarding the latter either the compiler could be changed to accept them (which has been suggested a couple of times, can’t find a reference right now) or it could be solved by defining floating attributes for them which the ocaml
interpreter would transform into equivalent #require
directives (that would still leave the problem of the #! though). I think I initially had that design in b0caml
but I eventually came back to directives, not sure exactly why. But perhaps because I wanted to reuse as much as possible the existing directives and that at some point merlin seemingly had no problem with them.