Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it, and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
However, if you run "gsc", and write those 2 lines, everything will work as expected.
Then I figured out that with the option "-:s" it seems to understand the "import" macro, so the error turns into:
(load "/usr/lib/modules/build") (import test-module)
*** ERROR IN #<procedure #2>, "/usr/lib/syntax-case.scm"@7821.33 -- unknown module test-module
(there is a test-module.scm file, of course, and this works again in interactive mode)
anyway, I don't really know what sense it makes to load the gambit syntax-case.scm when Black Hole is supposed to provide another one.
So, the point is: everything works in interactive mode as expected, but I can't run the same code from a file.
I would appreciate some help and/or clarifications, please.
Thank you,
Álvaro Castro-Castilla
Afficher les réponses par date
On Feb 5, Álvaro Castro-Castilla scribed:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it, and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
I just figured this out today: $ cat ~/.gambcini ; load blackhole, always (load "~~/lib/syntax-case") (load "~~/lib/modules/build") $ gsc -:s,dar Gambit v4.6.0
(import (std (srfi/1))
Runs great inside Emacs, too. ; put gamit.el in emacs/site-lisp (require 'gambit) (setq scheme-program-name "gsc -:s,dar-")
hth, dave
I just figured this out today: $ cat ~/.gambcini ; load blackhole, always (load "~~/lib/syntax-case") (load "~~/lib/modules/build") $ gsc -:s,dar Gambit v4.6.0
That will work. The load syntax-case will be a no-op, though, because BH and syntax-case attach to the same callback so BH will overwrite syntax-case. So I don't think you get syntax-case macros even if you do it that way. The code that I run before the REPL starts is this:
(and (equal? (path-strip-directory (car (command-line))) "bsc") (load "~~lib/modules/build") (let () (##namespace ("module#")) (##include "~~lib/gambit#.scm")
;; It's possible to do some configuration of BH here if desired.
(println "Loaded Black Hole.")))
I have a symlink in PATH that points to gsc. That way I can start Black Hole by running bsc and non-black hole gambit isn't affected.
/Per
On Feb 5, Per Eckerdal scribed:
I just figured this out today: $ cat ~/.gambcini ; load blackhole, always (load "~~/lib/syntax-case") (load "~~/lib/modules/build") $ gsc -:s,dar Gambit v4.6.0
That will work. The load syntax-case will be a no-op, though, because BH and syntax-case attach to the same callback so BH will overwrite syntax-case. So I don't think you get syntax-case macros even if you do it that way. The code that I run before the REPL starts is this:
(and (equal? (path-strip-directory (car (command-line))) "bsc") (load "~~lib/modules/build") (let () (##namespace ("module#")) (##include "~~lib/gambit#.scm")
;; It's possible to do some configuration of BH here if desired. (println "Loaded Black Hole.")))
I have a symlink in PATH that points to gsc. That way I can start Black Hole by running bsc and non-black hole gambit isn't affected.
/Per
Thanks Per.
I remember I had to play with it to get it to work. The load order actually mattered. If I didn't load syntax-case:
(import (std srf1/1))
*** ERROR -- No such file or directory (path-normalize "srf1/1.scm" #f "C:\tools\GAMBIT~1\v4.6.0\lib\modules\std\")
If I load syntax-case last:
(import (std srfi/1))
*** ERROR -- invalid module specifier (std srfi/1)
I'm basically a newbie to Scheme, but I have a couple of months playing with Chicken. I really liked Chicken's module system and eggs and see BH in a similar role (modules and controlled namespaces that R5RS doesn't provide). Once I get a set of libraries up and running, I can't imagine using Gambit without BH loaded.
Thanks, Dave
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it, and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import "http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
El 5 de febrero de 2010 10:51, Per Eckerdal per.eckerdal@gmail.comescribió:
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it,
and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something
that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import " http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
Thanks a lot for your explanations!
It works with the code that you said in the .gambcini I understand now the reasons why it doesn't work, it makes sense. What I don't fully understand is why I'm not supposed to use "loads" now anymore... At the moment, I was compiling bindings and some "libraries" that I needed to use, to speed up the code, how am I supposed to deal with that now? (they were not done thinking in Black Hole, but they don't use any namespaces functionality, AFAIK).
Thanks again for your prompt response.
Álvaro Castro-Castilla
Then (import nameofyourlibrary), presuming it is located in nameofyourlibrary.scm in your current working directory. (module-compile!) it first if it does not contain C FFI calls (which would force compile on import) and you want it compiled.
2010/2/5 Álvaro Castro-Castilla alvaro.castro.castilla@gmail.com
El 5 de febrero de 2010 10:51, Per Eckerdal per.eckerdal@gmail.comescribió:
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it,
and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something
that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import " http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
Thanks a lot for your explanations!
It works with the code that you said in the .gambcini I understand now the reasons why it doesn't work, it makes sense. What I don't fully understand is why I'm not supposed to use "loads" now anymore... At the moment, I was compiling bindings and some "libraries" that I needed to use, to speed up the code, how am I supposed to deal with that now? (they were not done thinking in Black Hole, but they don't use any namespaces functionality, AFAIK).
Thanks again for your prompt response.
Álvaro Castro-Castilla
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Then (import nameofyourlibrary), presuming it is located in nameofyourlibrary.scm in your current working directory. (module-compile! 'nameofyourlibrary) it first if it does not contain C FFI calls (which would force compile on import) and you want it compiled.
2010/2/5 Álvaro Castro-Castilla alvaro.castro.castilla@gmail.com
El 5 de febrero de 2010 10:51, Per Eckerdal per.eckerdal@gmail.comescribió:
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it,
and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out something
that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import " http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
Thanks a lot for your explanations!
It works with the code that you said in the .gambcini I understand now the reasons why it doesn't work, it makes sense. What I don't fully understand is why I'm not supposed to use "loads" now anymore... At the moment, I was compiling bindings and some "libraries" that I needed to use, to speed up the code, how am I supposed to deal with that now? (they were not done thinking in Black Hole, but they don't use any namespaces functionality, AFAIK).
Thanks again for your prompt response.
Álvaro Castro-Castilla
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
El 5 de febrero de 2010 13:25, Mikael mikael.trash@gmail.com escribió:
Then (import nameofyourlibrary), presuming it is located in nameofyourlibrary.scm in your current working directory. (module-compile! 'nameofyourlibrary) it first if it does not contain C FFI calls (which would force compile on import) and you want it compiled.
2010/2/5 Álvaro Castro-Castilla alvaro.castro.castilla@gmail.com
El 5 de febrero de 2010 10:51, Per Eckerdal per.eckerdal@gmail.comescribió:
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it,
and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out
something that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import " http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
Thanks a lot for your explanations!
It works with the code that you said in the .gambcini I understand now the reasons why it doesn't work, it makes sense. What I don't fully understand is why I'm not supposed to use "loads" now anymore... At the moment, I was compiling bindings and some "libraries" that I needed to use, to speed up the code, how am I supposed to deal with that now? (they were not done thinking in Black Hole, but they don't use any namespaces functionality, AFAIK).
Thanks again for your prompt response.
Álvaro Castro-Castilla
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
It seems I can compile modules in this way, but I stilla have problems:
I'm working now in opengl bindings, taken from Space Invaders. I have a file called opengl.scm, and other called opengl-header.scm opengl.scm imports opengl-header.scm, then a test module imports (or compile-module!) opengl.scm
A) If I use import, it says that c-lambda is not available in interpreted mode. But then I'm trying with compile-modules! However, it tries to write to /usr/lib/modules/ns.dat, and I don't have the permission. Using this compiler option:
bsc -:~~DIR=/data/projects/scheme -i
doesn't help.
*** ERROR IN module#save-ns-table, "/usr/lib64/modules/module.scm"@730.3 -- Permission denied (with-output-to-file "~~/lib/modules/ns.dat" '#<procedure #2>)
B) If I execute it again (with compile-module, as "import" doesn't work), I get another o2, and then o3, o4...
What I want is just a method to work with BH so I can have the FFI modules compiled (and, if possible also some other big libraries, such as SSAX-SXML) and then being able to run interpreted the rest of the program.
Thanks for all your help
El 5 de febrero de 2010 14:17, Álvaro Castro-Castilla < alvaro.castro.castilla@gmail.com> escribió:
El 5 de febrero de 2010 13:25, Mikael mikael.trash@gmail.com escribió:
Then (import nameofyourlibrary), presuming it is located
in nameofyourlibrary.scm in your current working directory. (module-compile! 'nameofyourlibrary) it first if it does not contain C FFI calls (which would force compile on import) and you want it compiled.
2010/2/5 Álvaro Castro-Castilla alvaro.castro.castilla@gmail.com
El 5 de febrero de 2010 10:51, Per Eckerdal per.eckerdal@gmail.comescribió:
5 feb 2010 kl. 01.25 skrev Álvaro Castro-Castilla:
Hi!
I'm new to this list and also to Gambit. I'm trying to get used to it,
and I like most of the things very much (taking into account that I'm new to Scheme).
I'm trying to use Black Hole module system, and I've found out
something that I don't understand how it works or what I'm doing wrong.
If you have this scheme file, called for example "bhtest.scm"
(load "/usr/lib/modules/build") (import (std srfi/14))
and you try to execute it with "gsc -i bhtest.scm", you'll get this:
*** ERROR IN "blackhole.scm"@3.2 -- Unbound variable: import
I think a clarification to why this doesn't work (and the same code in the REPL does) would be helpful not only to understand Black Hole, but also other similar issues.
When you type the load expression into the REPL, Gambit will load Black Hole, and Black Hole will override two hooks, ##expand-source and c#expand-source. These two functions are by default the identity function (that is, (lambda (x) x)). ##expand-source is called every time code is evaluated, and Black Hole adds its macro expander there.
After loading BH in the REPL, BH's macro expander will be there, so in the next line, when you type (import ...), BH will recognize it and take proper action.
However, when loading a file containing both (load "/usr/lib/modules/build") and (import (std srfi/14)), what will happen is that Gambit will parse the whole file, then call ##expand-source on the resulting s-expression, then eval that expression. Black Hole will get loaded, but when it is, the whole file's code will already have been macro-expanded, so the import will be seen as a normal procedure call, which obviously won't work.
This is a kind problem that many people that are new to Gambit (and probably other implementations of Scheme as well) seem to have. The difference between typing something into the REPL, load-ing a file with the same expressions, or include-ing a file is not very easy to understand at first.
For me, it helped to think like this (it's not entirely correct, but kind of): It's possible to implement both load and include, assuming that read-file is a function that reads a file's s-exps and wraps them in a begin, as an example would bhtest.scm yield (begin (load "/usr/lib/modules/build") (import (std srfi/14)))
(define (load filename) (eval (read-file filename)))
(define-macro (include filename) (read-file filename))
The main reason why you're not supposed to have a load expression inside of your scheme files is that I have tried hard to design BH in a way that makes it easy to share code. Having a load expression in the beginning of each file would ruin that, because everyone will not have BH installed at the same place. Also, this ensures that very simple code is kept very simple and clean, yet it will scale and still be useful in larger applications. An example of a typical BH module is a simple FIFO queue library that I have written:
http://github.com/pereckerdal/blackhole-libs/blob/master/ds/queue.scm
It's possible to import it like this: (import " http://github.com/pereckerdal/blackhole-libs/raw/master/ds/queue.scm")
This mail turned out somewhat messy, I hope it helps.
/Per
Thanks a lot for your explanations!
It works with the code that you said in the .gambcini I understand now the reasons why it doesn't work, it makes sense. What I don't fully understand is why I'm not supposed to use "loads" now anymore... At the moment, I was compiling bindings and some "libraries" that I needed to use, to speed up the code, how am I supposed to deal with that now? (they were not done thinking in Black Hole, but they don't use any namespaces functionality, AFAIK).
Thanks again for your prompt response.
Álvaro Castro-Castilla
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
It seems I can compile modules in this way, but I stilla have problems:
I'm working now in opengl bindings, taken from Space Invaders. I have a file called opengl.scm, and other called opengl-header.scm opengl.scm imports opengl-header.scm, then a test module imports (or compile-module!) opengl.scm
A) If I use import, it says that c-lambda is not available in interpreted mode. But then I'm trying with compile-modules! However, it tries to write to /usr/lib/modules/ns.dat, and I don't have the permission. Using this compiler option:
bsc -:~~DIR=/data/projects/scheme -i
doesn't help.
*** ERROR IN module#save-ns-table, "/usr/lib64/modules/module.scm"@730.3 -- Permission denied (with-output-to-file "~~/lib/modules/ns.dat" '#<procedure #2>)
B) If I execute it again (with compile-module, as "import" doesn't work), I get another o2, and then o3, o4...
What I want is just a method to work with BH so I can have the FFI modules compiled (and, if possible also some other big libraries, such as SSAX-SXML) and then being able to run interpreted the rest of the program.
Thanks for all your help
I think force-compile did B
but I still can't fix A.
On 2010-02-05, at 8:17 AM, Álvaro Castro-Castilla wrote:
A) If I use import, it says that c-lambda is not available in interpreted mode. But then I'm trying with compile-modules! However, it tries to write to /usr/lib/modules/ns.dat, and I don't have the permission. Using this compiler option:
bsc -:~~DIR=/data/projects/scheme -i
I'm just guessing, but you probably meant:
bsc -:~~=/data/projects/scheme -i
The "DIR" part is a meta variable in the documentation, to be replaced by "lib", "bin", etc or be empty when the central installation directory is meant (i.e. the meaning of a path like "~~/...").
Also, in your Scheme files (and maybe blackhole) there seems to be references to the library directory with a path like this:
~~/lib
Note that it is better to use
~~lib
so that proper redirection will occur (if the system is started with -:~~lib=/foo/bar).
Marc