Hacker News new | ask | show | jobs
by rixed 20 days ago
Now that the native ocaml repl has landed, can't we just slap a s-expression syntax on top of ocaml and call it a day? We would have homoiconicity and the macros that go with it, and still could call "(compile `some-code)". Isn't that enough?
4 comments

I'd love that. The janky OCaml syntax is my least favorite part of the language.
Nothing will ever be enough, for all interpretations of the statement, reveling in all the irony, pathos, and prideful triumph that could possibly be extracted from such interpretations from here to eternity

Humans will keep inventing and remixing

We have a deep capacity for remixing.
Aside from the fact that slapping an s-expression syntax on top of a language typically leaves you with a fairly crappy Lisp, that would also lack the excellent Common Lisp interop that Coalton has.
OCaml is a better candidate than most. It already has a macro system (PPX), and the core language has a lot in common with Scheme.
The PPX macro system is far from perfect, that's the whole point of this idea: with the native REPL + an s-expression syntax, you have lisp-like macros for free.
S-expressions are more than mere syntax. Lists in OCaml can only have a single element type, so you would need something different for s-expressions.
> native ocaml repl has landed

What does this refer to? Most people use the OCaml `utop` REPL which isn't okay for some printf debugging but nowhere near what a Lisp could do.

There is a native toplevel hidden in OCaml5 source tree (not installed by default). So you can basically enter an expression, and the compiler will turn it into native code and dynamically load it. Interactive REPL with native code was not possible before that (apart from a short lived experiment long ago, if memory serves me well).