feature request. more explicit error for unknown top level form
This code is bad because I have a (do (fun 0)) out in space when that's not a valid thing to do in c. I expect it to be not uncommon for a beginner (like me) since it looks/feels like Clojure where that's a totally normal thing to do. It's not really an issue but I think it's worth mentioning. Thanks.
(use IO)
(register fun (Fn [Int] Int))
(do
(fun 0))
(defn main []
(println* "hey"))
$ carp no.carp -x
I did not understand the form `(external fun (Fn [Int] Int))` at C:/Users/richie/Documents/org/projects/handmade-carp/no.carp:3:15.
Traceback:
(fun 0) at C:/Users/richie/Documents/org/projects/handmade-carp/no.carp:6:3.
(do (fun 0)) at C:/Users/richie/Documents/org/projects/handmade-carp/no.carp:5:1.
Actually, it's not a normal thing to do in clojure. I do it all the time because I can send the forms to the repl but I delete it when I'm done. Yea, not an issue. I'd still like a better error message though. It may be good enough to distinguish "not a valid top level form" from the catch all "idk what that is". Initially, I assumed it was a problem with registering the c function...
This should work though, you can call functions from the repl or from top-level in a file like that. So this seems like another bug with the detection of static code maybe.
Seems related to the (do ...).
Ok, thanks!