marcomaggi / vicare

A native compiler for Scheme compliant with R6RS
http://marcomaggi.github.com/vicare.html
Other
200 stars 34 forks source link

library-path undefined #87

Closed svenha closed 8 years ago

svenha commented 8 years ago

The documentation at https://marcomaggi.github.io/docs/vicare-scheme.html/using-libraries-searching.html#using-libraries-searching mentions (library-path), but this is reported as undefined in current vicare. How can a directory be added to the search path?

marcomaggi commented 8 years ago

The documentation you are referring to is for version 0.3d7, the last in the 0.3 series. In the master branch things have changed a lot; you should refer to the bundled documentation.

By default, only documentation in Info format is built and installed; we can build and install HTML documentation from the build directory with:

$ make html
$ make install-html

the relevant nodes are using libraries and libutils.

svenha commented 8 years ago

Thanks, Marco. To avoid questions of lazy readers like me, maybe add the version to each generated page? Is there any way to use 'include' (like in R7RS) in library definitions? I end up with "malformed library" (if using include in 'library' from R6RS, which would be non-standard), or "invalid syntax, no clause matches the input form" (if using include in 'define-library' from R7RS, which would be conforming to the standard).

marcomaggi commented 8 years ago

To avoid questions of lazy readers like me, maybe add the version to each generated page?

I doubt GNU Texinfo allows this.

Is there any way to use 'include' (like in R7RS) in library definitions?

Yes. The syntax include is non-R6RS and it is exported by (vicare). We can create a source file in the current directory:

;; demo.scm --
;;

(define (doit)
  (display "hello world!\n"))

;;; end of file

a library file in the current source directory:

;; demo.sls --
;;

(library (demo)
  (export doit)
  (import (vicare))
  (include "demo.scm" #t))

;;; end of file

then enter the REPL giving the current directory as addition to the search path for source files:

$ vicare --source-path $PWD --option print-loaded-libraries
vicare: load-r6rs-script: loading R6RS script: /home/marco/.vicarerc
vicare: load-r6rs-script: running R6RS script: /home/marco/.vicarerc
Vicare Scheme version 0.4d0, 64-bit
Build 2015-12-15

Copyright (c) 2006-2010 Abdulaziz Ghuloum and contributors
Copyright (c) 2011-2015 Marco Maggi and contributors

vicare> (import (demo))
vicare: searching include file: demo.scm
vicare: including file: /home/marco/var/tmp/demo.scm
vicare: loaded library "(demo)" from: /home/marco/var/tmp/demo.sls
vicare> (doit)
hello world!
vicare> 

Now we can compile the library:

$vicare --source-path $PWD --option print-loaded-libraries --compile-library demo.sls --output demo.fasl
vicare: compile-source-library: loading library: demo.sls
vicare: searching include file: demo.scm
vicare: including file: /home/marco/var/tmp/demo.scm
vicare: serialising library: demo.fasl
vicare: library serialisation done

and remember that include is and expand-time thing, so the compiled library will not include anymore. Then we enter the REPL adding the current directory as search path for binary libraries:

$ vicare -L $PWD --option print-loaded-libraries
vicare: load-r6rs-script: loading R6RS script: /home/marco/.vicarerc
vicare: load-r6rs-script: running R6RS script: /home/marco/.vicarerc
Vicare Scheme version 0.4d0, 64-bit
Build 2015-12-15

Copyright (c) 2006-2010 Abdulaziz Ghuloum and contributors
Copyright (c) 2011-2015 Marco Maggi and contributors

vicare> (import (demo))
vicare: loaded library "(demo)" from: /home/marco/var/tmp/demo.fasl
vicare> (doit)
hello world!
vicare> 

(if using include in 'define-library' from R7RS, which would be conforming to the standard)

I am not sure to understand you: define-library is not in R6RS and so it is undefined by vicare; R7RS is not supported.