Hey :)
I've currently started to learn/use scheme for some experiments in machine learning and chose gambit for its close relation to c. I would like to share my first impression and misunderstandings with you and have some questions which maybe also help other newcomers.
1) I managed to compile my scheme library into a dynamic loadable unit that i use in some scripts for the gsi interpreter. Does anyone know how i can specify some kind of loadpath (e.g. via ENV, commandline flag) for the interpreter where (load "...") searches scheme modules? (Or any other common alternatives) Currently i'm always using relative paths through (string-append (path-directory (this-source-file)) "/" "module") based on the file location itself.
2) I've struggled in the beginning very much with the usage of gsc and gsi. My first step is often calling the --help flag of the command itself. Unfortanetely, i haven't found any useful option like "gsc --help" or "gsi --help" that provides a short summary about its common command flags. The man page and the -:h flag provides some information about runtime configuration. But it seems a little incomplete. (Especially for compiling scheme files to .o1). It would be a great help to extend this summary with the mentioned options from the documentation in "/usr/share/gambc" or "info gambit-c". (If i missed something interesting, just let me know)
3) For my own purpose i'm currently implementing a trivial testing library similar to rspec and would like to share this. The wiki mentioned two package systems (Black Hole and Snow). I like to ask if there exists some preferences using a specific system and which one do you suggest (or is there even one of them deprecated?)
4) Do you know a good scheme alternative for the printf command in c? I've currently only used (print ..) and (display ..) which worked, but i would also prefer some formated outputs for the future :)
5) I have currently no clue about gambit overall capabilities. But i guess it already belongs to the most matured scheme implementation due to its older age. I'm especially interested in its foreign interface to C and it would be interesting to know if its possible to bind bigger libraries like Glib/GTK/Cairo flawlessly. (Or does there exists some known limitations that could lead to obvious problems).
Hope you nevermind this trivial questions that helps me a little in gambits scheme landscape.
Chris
Afficher les réponses par date
Hi!
I'll try to help you with some answers:
1) One solution would be to use Blackhole, it handles the location. If you don't the best solution is to use the ~~ syntax: (load "~~yourlib/yourmodule") This will expand to your current Gambit installation directory. In my case, this would be /usr/local/Gambit-C/yourlib/yourmodule.scm
2) Well, the place for learning Gambit usage is the documentation in the web, AFAIK. There are also some other explanations in the wiki.
3) Use Blackhole, it will both give you a module system and a macro expander (for syntax-rules and syntactic closures). Snow was primarily intended to be a cross-implementation module system, for portable libraries, but I think it wasn't very successful as it seems unmaintained. Probably due to R6RS irruption. I have my own system, which is not really a module system, but a way to handle packages and automate tasks. In the near future I'll try to merge it with Blackhole.
4) Try with pretty printing: (pp object). Another useful procedure would be OBJECT->STRING
5) In my opinion, one of the strongest points of this implementation is its FFI capabilities. There are Cairo bindings in the dumping grounds of the web. I have also made my own, updated to Cairo 1.12. C bindings are _relatively_ straightforward. Objective-C seems to be as well, although I don't have experience with this (there are some helper macros in the dumping grounds as well). But I don't see why you would have any problems with Glib/GTK/Cairo. You'll have to figure a way to express the functionality of Glib's C macros.
I hope I clarified some things.
Best regards,
Álvaro
Thanks, that helped very much !
Am 10.01.2013 12:40, schrieb Álvaro Castro-Castilla:
Hi!
I'll try to help you with some answers:
- One solution would be to use Blackhole, it handles the location. If you
don't the best solution is to use the ~~ syntax: (load "~~yourlib/yourmodule") This will expand to your current Gambit installation directory. In my case, this would be /usr/local/Gambit-C/yourlib/yourmodule.scm
- Well, the place for learning Gambit usage is the documentation in the
web, AFAIK. There are also some other explanations in the wiki.
- Use Blackhole, it will both give you a module system and a macro
expander (for syntax-rules and syntactic closures). Snow was primarily intended to be a cross-implementation module system, for portable libraries, but I think it wasn't very successful as it seems unmaintained. Probably due to R6RS irruption. I have my own system, which is not really a module system, but a way to handle packages and automate tasks. In the near future I'll try to merge it with Blackhole.
I've managed to to get it work and start using it.
- Try with pretty printing: (pp object). Another useful procedure would be
OBJECT->STRING
Is it also possible to set a custom format for an object? (similar to http://srfi.schemers.org/srfi-28/srfi-28.html)
e.g. i'm currently looking for a (number->string ...) conversion, where i can set the number of digits after the decimal point within the string.
- In my opinion, one of the strongest points of this implementation is its
FFI capabilities. There are Cairo bindings in the dumping grounds of the web. I have also made my own, updated to Cairo 1.12. C bindings are _relatively_ straightforward. Objective-C seems to be as well, although I don't have experience with this (there are some helper macros in the dumping grounds as well). But I don't see why you would have any problems with Glib/GTK/Cairo. You'll have to figure a way to express the functionality of Glib's C macros.
I hope I clarified some things.
Best regards,
Álvaro
Yes, I've used that SRFI before, and also SRFI-48 and SRFI-54. I don't know any method to modifiy how PP displays an object, if that's what you want.
On Wed, Jan 16, 2013 at 9:50 AM, Chris Müller ruunsmail@gmail.com wrote:
Thanks, that helped very much !
Am 10.01.2013 12:40, schrieb Álvaro Castro-Castilla:
Hi!
I'll try to help you with some answers:
- One solution would be to use Blackhole, it handles the location. If you
don't the best solution is to use the ~~ syntax: (load "~~yourlib/yourmodule") This will expand to your current Gambit installation directory. In my case, this would be /usr/local/Gambit-C/yourlib/yourmodule.scm
- Well, the place for learning Gambit usage is the documentation in the
web, AFAIK. There are also some other explanations in the wiki.
- Use Blackhole, it will both give you a module system and a macro
expander (for syntax-rules and syntactic closures). Snow was primarily intended to be a cross-implementation module system, for portable libraries, but I think it wasn't very successful as it seems unmaintained. Probably due to R6RS irruption. I have my own system, which is not really a module system, but a way to handle packages and automate tasks. In the near future I'll try to merge it with Blackhole.
I've managed to to get it work and start using it.
- Try with pretty printing: (pp object). Another useful procedure would be
OBJECT->STRING
Is it also possible to set a custom format for an object? (similar to http://srfi.schemers.org/srfi-28/srfi-28.html)
e.g. i'm currently looking for a (number->string ...) conversion, where i can set the number of digits after the decimal point within the string.
- In my opinion, one of the strongest points of this implementation is its
FFI capabilities. There are Cairo bindings in the dumping grounds of the web. I have also made my own, updated to Cairo 1.12. C bindings are _relatively_ straightforward. Objective-C seems to be as well, although I don't have experience with this (there are some helper macros in the dumping grounds as well). But I don't see why you would have any problems with Glib/GTK/Cairo. You'll have to figure a way to express the functionality of Glib's C macros.
I hope I clarified some things.
Best regards,
Álvaro
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
2013/1/16 Chris Müller ruunsmail@gmail.com
Thanks, that helped very much !
Am 10.01.2013 12:40, schrieb Álvaro Castro-Castilla:
Hi!
I'll try to help you with some answers:
- One solution would be to use Blackhole, it handles the location. If you
don't the best solution is to use the ~~ syntax: (load "~~yourlib/yourmodule") This will expand to your current Gambit installation directory. In my case, this would be /usr/local/Gambit-C/yourlib/yourmodule.scm
- Well, the place for learning Gambit usage is the documentation in the
web, AFAIK. There are also some other explanations in the wiki.
- Use Blackhole, it will both give you a module system and a macro
expander (for syntax-rules and syntactic closures). Snow was primarily intended to be a cross-implementation module system, for portable libraries, but I think it wasn't very successful as it seems unmaintained. Probably due to R6RS irruption. I have my own system, which is not really a module system, but a way to handle packages and automate tasks. In the near future I'll try to merge it with Blackhole.
I've managed to to get it work and start using it.
- Try with pretty printing: (pp object). Another useful procedure would be
OBJECT->STRING
Is it also possible to set a custom format for an object? (similar to http://srfi.schemers.org/srfi-28/srfi-28.html)
Anything is possible: I believe there's not hooks for this in the system already, because when someone wants custom formatted output it's generally more suitable for the user to implement this from scratch, though you can add any hooks you want.
e.g. i'm currently looking for a (number->string ...) conversion, where i
can set the number of digits after the decimal point within the string.
You can patch Gambit to make this happen. Preferably you add a parameter i.e. |make-parameter| value to Gambit's code where you specify this setting, and then make the routine - number->string I guess - pick it up.
So,
; Global scope - default behavior (number->string 5.2) ; => "5.2"
; Global scope - chris/number->string:fixed-decimals set to 5 ** Generally don't do it this way! ** (chris/number->string:fixed-decimals 5.2) ; => "5.20000"
; Parameterized scope with chris/number->string:fixed-decimals set to 3. (but like this) (parameterize ((chris/number->string:fixed-decimals 3)) (number->string 5.2)) ; => "5.200"
; Global scope - of course it's back the same i.e. (chris/number->string:fixed-decimals 5.2) ; => "5.20000"
More generally, this kind of thing would be done with a formatting library. I believe it remains for one tuned for Gambit yet to come into existence - there's a SchemeFmt library, something like this, out there that's cross-scheme, perhaps it could be adapted. Someone on the ML by the name Tanya I believe got it running on Gambit.
Feel free to share any patches you produce with the ML.
- In my opinion, one of the strongest points of this implementation is its
FFI capabilities. There are Cairo bindings in the dumping grounds of the web. I have also made my own, updated to Cairo 1.12. C bindings are _relatively_ straightforward. Objective-C seems to be as well, although I don't have experience with this (there are some helper macros in the dumping grounds as well). But I don't see why you would have any problems with Glib/GTK/Cairo. You'll have to figure a way to express the functionality of Glib's C macros.
I hope I clarified some things.
Best regards,
Álvaro
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On Wed, Jan 16, 2013 at 6:46 AM, Mikael mikael.rcv@gmail.com wrote:
More generally, this kind of thing would be done with a formatting library. I believe it remains for one tuned for Gambit yet to come into existence - there's a SchemeFmt library, something like this, out there that's cross-scheme, perhaps it could be adapted. Someone on the ML by the name Tanya I believe got it running on Gambit.
For what it's worth, Alex Shinn's fmt library [1] requires only slight modification to make up for missing string functions; also you can use the reference implementation of SRFI-48 [2] verbatim.
[1] http://synthcode.com/scheme/fmt/ [2] http://srfi.schemers.org/srfi-48/srfi-48.html
Ah right, yes Shinn's fmt, that's the one. Would be interesting to see it run on vanilla Gambit and/or Black Hole.
2013/1/18 Taylor Venable taylor@metasyntax.net
On Wed, Jan 16, 2013 at 6:46 AM, Mikael mikael.rcv@gmail.com wrote:
More generally, this kind of thing would be done with a formatting library. I believe it remains for one tuned for Gambit yet to come into existence - there's a SchemeFmt library, something like this, out there that's cross-scheme, perhaps it could be adapted. Someone on the ML by the name Tanya I believe got it running on Gambit.
For what it's worth, Alex Shinn's fmt library [1] requires only slight modification to make up for missing string functions; also you can use the reference implementation of SRFI-48 [2] verbatim.
[1] http://synthcode.com/scheme/fmt/ [2] http://srfi.schemers.org/srfi-48/srfi-48.html
-- Taylor C. Venable http://metasyntax.net/
Am 18.01.2013 00:39, schrieb Taylor Venable:
On Wed, Jan 16, 2013 at 6:46 AM, Mikael mikael.rcv@gmail.com wrote:
More generally, this kind of thing would be done with a formatting library. I believe it remains for one tuned for Gambit yet to come into existence - there's a SchemeFmt library, something like this, out there that's cross-scheme, perhaps it could be adapted. Someone on the ML by the name Tanya I believe got it running on Gambit.
For what it's worth, Alex Shinn's fmt library [1] requires only slight modification to make up for missing string functions; also you can use the reference implementation of SRFI-48 [2] verbatim.
[1] http://synthcode.com/scheme/fmt/ [2] http://srfi.schemers.org/srfi-48/srfi-48.html
SRFI-48 provides exactly the function i'm looking for. Like printf, fprintf for scheme.
Also thanks for your hints patching gambit. Though it's possible i would still prefer a simple library. Would be only my last option to add a modification for standard api calls :)