Closed jbouwman closed 3 months ago
I would prefer to merge asdf support for .coal files before this. Without that it's difficult to tell if the compiler is generating valid fasls that can survive restarts.
The initial Coalton prototype had a problem where restarts would clear the type database. Solving this required building the current environment system. I think similar care will be needed to ensure that packages are re-created when cached fasls are loaded.
I would prefer to merge asdf support for .coal files before this. Without that it's difficult to tell if the compiler is generating valid fasls that can survive restarts.
I'm trying this out locally and I can't get asdf to compile a file.
test.asd
(asdf:defsystem #:test
:serial t
:pathname "src"
:depends-on (#:coalton #:coalton-asdf)
:components ((:coalton-file "test.coal")))
src/test.coal
(package test)
(define x 5)
CL-USER> (asdf:load-system :test)
T
CL-USER> (in-package :test)
The name "TEST" does not designate any package.
(asdf:defsystem #:test :serial t :pathname "src" :defsystem-depends-on (#:coalton-asdf) :depends-on (#:coalton) :components ((:coalton-file "test")))
I think the system needs :defsystem-depends-on (#:coalton-asdf)
[Jesse - I sneakily edited izaak's comment to take out the .coal extension from the components entry and now it seems to work. It's odd to me that the :coalton-file entry was ignored in the case where :defsystem-depends-on was absent.]
I think the system needs :defsystem-depends-on (#:coalton-asdf)
Thanks! I added defsystem-depends-on and got a different error.
Error while trying to load definition for system meh from
pathname /Users/ejlawsonfox/lisp/test/meh.asd:
COMPILE-FILE-ERROR while
compiling #<CL-SOURCE-FILE "coalton-asdf" "coalton-asdf">
READ error during COMPILE-FILE: Symbol "COMPILE-COALTON" not found in the COALTON-IMPL/ENTRY package
READ error during COMPILE-FILE: Symbol "COMPILE-COALTON" not found in the COALTON-IMPL/ENTRY package
I wonder if it's looking at a different coalton system, that symbol seems to be present and exported.
I wonder if it's looking at a different coalton system, that symbol seems to be present and exported.
Good catch. My lisp environment was screwed up.
The system is compiling now but it doesn't look like the compiled code is being run. I get compile errors, but I still can't in-package.
The system is compiling now but it doesn't look like the compiled code is being run. I get compile errors, but I still can't in-package.
I just tried and it's working for me:
asd-test.asd
(asdf:defsystem #:asd-test
:serial t
:defsystem-depends-on (#:coalton-asdf)
:depends-on (#:coalton)
:pathname "src"
:components ((:coalton-file "test")))
src/test.coal
(package test)
(define x 5)
In the REPL
CL-USER> (asdf:load-system :asd-test)
STYLE-WARNING: Generic function FSET:ITERATOR clobbers an earlier FTYPE proclamation (FUNCTION (T &KEY &ALLOW-OTHER-KEYS) (VALUES FUNCTION &REST T)) for the same name with (FUNCTION (T &KEY &ALLOW-OTHER-KEYS) *).
T
CL-USER> (in-package :test)
#<COMMON-LISP:PACKAGE "TEST">
TEST> x
5
That works for me. I was doing something else wrong :/
I think I ran into an actual issue. The fasl files produced don't appear to recreate their packages at load time.
(asdf:load-system :asd-test)
;; restart inferior lisp
(asdf:load-system :asd-test)
I got the following error:
The loader tried loading the symbol named X into the package named TEST, but the package did not get defined, and does not exist.
(Side comment: Can we test that ASDF corner cases work or fail appropriately? Like bad extension, missing file, etc. In a separate PR maybe.)
The loader tried loading the symbol named X into the package named TEST, but the package did not get defined, and
Aha, it wasn't emitting the defpackage form: I've restored that -- https://github.com/coalton-lang/coalton/pull/1091/files#diff-dbe076ada6d143bc146af69913f741b08735798471bd7bc03e0ca4a2dd7d089fR240 -- followed your steps, and it now appears to work.
(Side comment: Can we test that ASDF corner cases work or fail appropriately? Like bad extension, missing file, etc. In a separate PR maybe.)
https://github.com/coalton-lang/coalton/pull/1091/files#diff-dbe076ada6d143bc146af69913f741b08735798471bd7bc03e0ca4a2dd7d089fR240 might be a good place to add those
Also, touching each error case for invalid package forms.
Outcome of steering meeting:
@stylewarning @eliaslfox guidance on this changeset?
Extend the
package
form to support full package definitions.Supported syntax:
Example:
Import
import
allows you to specify which packages a package depends on:You can use nicknames for imported packages using the
as
keyword:Import-from
The
import-from
form allows you to specify which symbols from an imported package should be made available within your package:Export