stylewarning / deprecated-coalton-prototype

Coalton is (supposed to be) a dialect of ML embedded in Common Lisp.
MIT License
208 stars 7 forks source link

Make define-type forms work at load-time #12

Closed appleby closed 5 years ago

appleby commented 5 years ago

PROOF-OF-CONCEPT GAWDAWFUL HACKS DO NOT MERGE

Fixes #11

This is a quick-and-dirty proof-of-concept fix for the issue I described in #11. This contains some fugly hacks, like the smattering 'round of make-load-forms rather than just doing the macro expansion properly, and also the fact that it's essentially duplicating code. Possibly everything could just be pushed down into the macro expansion and wrapped in (eval-when (:compile-toplevel :load-toplevel)...) or some such, but I wasn't sure if the registering of tycons also needed to happen at macro-expansion time (as distinct from compile-time).

appleby commented 5 years ago

Just confirmed that pushing the tycon registration down into the body of the macro wrapped in an eval-when is not sufficient. Registering the constructors apparently also needs to happen at macro-expansion time, which I suppose makes sense because a single coalton-toplevel form might contain many definitions, and types defined earlier need to be visible to later definitions.