forked from alex-eg/sex
An importer is given the pub forms and nothing else, so a pub form naming a private type, or one from an import without pub, compiled in its module and failed in every importer with `unknown type name'. The pub forms are checked as the module itself is compiled. A record, struct, union or sum behind a pointer needs only declaring, so its bodyless declaration goes out ahead of them -- the opaque handle that (pub record T) already gave by hand. Held by value it needs its body, and a typedef or an enum has no declaration short of its definition: those are errors at the pub form, saying what would do instead. A name Sex has no declaration for is left to C. An importer may now be handed a declaration after the definition it declares, so a bodyless aggregate no longer replaces known fields. Fixes #57, #58.
9 lines
289 B
Scheme
9 lines
289 B
Scheme
;;; A module greet.sex imports without `pub'. greet-app.sex never
|
|
;;; imports it, yet holds a (* ledger) that greet hands out: what greet
|
|
;;; exports has to declare the type for it.
|
|
|
|
(pub record ledger ((total int)))
|
|
|
|
(pub fn ledger-add ((l (* ledger)) (n int)) void
|
|
(+= (. l total) n))
|