Summary

Feature Request: Load type files for units

Metadata

Attachments

Description

Currently type files for units not installed in the repository are not loaded.

I've attached a patch that does something like this, but it's just a quick hack that works for my needs.

You should probably use `##sys#resolve-include-filename` to find the types file, like it's used to find the inline files.

Changes and comments

[2012-10-21 14:43:46 UTC] megane attached load-unit-type-files.patch (description=a hack)

[2012-10-21 21:39:32 UTC] felix changed status from new to assigned

[2012-10-21 21:39:32 UTC] felix set owner to felix

[2013-02-27 22:06:11 UTC] megane attached search-for-types-files-from-include-paths.patch (description=a better hack)

[2016-02-20 13:26:35 UTC] sjamaan changed milestone from someday to 5.1

[2016-02-20 13:26:35 UTC] sjamaan wrote:

Seems to be somehow related to the new unit/module handling in 5.0

[2016-08-25 21:28:24 UTC] sjamaan set difficulty to medium

[2018-11-08 11:18:35 UTC] megane wrote:

I think this issue was me confusing `-I` as an option to define additional paths CHICKEN should use to look for __modules__, when it's actually for the `include` form only.

CHICKEN only looks for modules in the egg repository and current directory. For modules in the current directory it does __not__ automatically import `.types` or `.inline` files. You have to use `-consult-types-file` and `-consult-inline-file` for those, respectively.

Maybe the `-I` could be made to specify additional paths to consult modules from, if that makes sense. I'm OK if this issue is closed as `invalid`, though.

The following shows that `.types` files are not automatically loaded.

 $ ./run.sh
 ::::::::::::::
 src/main.scm
 ::::::::::::::
 (cond-expand
  (chicken-5 (import (chicken base))
             (import mod))
  (else (import chicken)
        (use mod)))
 
 (print "--- main ---")
 (compiler-typecase (foo 1)
   (symbol (print 'ok))
   (* (error "was not symbol")))
 ::::::::::::::
 src/mod.scm
 ::::::::::::::
 (module
  mod
  (foo)
  (import scheme)
  (cond-expand
   (chicken-5 (import (chicken base) (chicken type)))
   (else (import chicken)))
 
  (: foo (* -> symbol))
  (define (foo x)
    (if (fixnum? x)
        'fixnum
        'not-fixnum))
  )
 ::::::::::::::
 run.sh
 ::::::::::::::
 #!/usr/bin/env bash
 set -e
 set -o pipefail
 
 more src/*.scm run.sh | cat
 
 echo "### BUILD ###"
 rm -rf build
 mkdir -p build
 cd build
 csc -s -J -O3 -ot mod.types ../src/mod.scm -o mod.so
 csc -O3 ../src/main.scm -o main
 
 more *.import.scm *.types | cat
 
 ./main
 
 ### BUILD ###
 ::::::::::::::
 mod.import.scm
 ::::::::::::::
 ;;;; mod.import.scm - GENERATED BY CHICKEN 5.0.0rc4 -*- Scheme -*-
 
 (##sys#register-compiled-module
   'mod
   'mod
   (scheme#list)
   '((foo . mod#foo))
   (scheme#list)
   (scheme#list))
 
 ;; END OF FILE
 ::::::::::::::
 mod.types
 ::::::::::::::
 ; GENERATED BY CHICKEN 5.0.0rc4 FROM ../src/mod.scm
 
 (mod#foo (#(procedure) mod#foo (*) symbol))
 
 ; END OF FILE
 --- main ---
 
 Error: was not symbol
 
 	Call history:
 
 	../src/main.scm:3: chicken.load#load-extension	  
 	../src/main.scm:7: chicken.base#print	  
 	../src/main.scm:8: mod#foo	  
 	../src/main.scm:10: chicken.base#error	  	<--
         }}}

[2019-04-08 01:06:33 UTC] sjamaan changed milestone from 5.1 to 5.2

[2019-08-25 17:32:40 UTC] felix changed milestone from 5.2 to 5.3

[2021-04-18 11:17:01 UTC] felix changed milestone from 5.3 to 5.4

[2023-11-06 22:18:08 UTC] felix changed milestone from 5.4 to 6.0.0

[2026-07-04 20:42:49 UTC] felix set owner empty

[2026-07-04 20:46:52 UTC] felix changed status from assigned to new