[gambit-list] What's in your gambc.scm file?

Marc Feeley feeley at iro.umontreal.ca
Thu Oct 1 08:17:14 EDT 2009


On 1-Oct-09, at 7:57 AM, Nicola Archibald wrote:

> On 01/10/2009 12:51 PM, Robert H wrote:
>> I was just perusing the "Teach yourself Scheme in fixnum days"  
>> tutorial
>> and came across the gambc.scm init section. The tutorial doesn't go  
>> into
>> examples of what that file is so I thought I might ask what you all  
>> do
>> in the init file.
>>
>> Bob
>>
>
> 'wrong' is what it is... (At least today)
>
> A 20 second experiment, and subsequent strace run, reveals that it
> should be ~/.gambcini.scm not ~/gambc.scm.
>
> As for what I have in it (heh), nothing, as I wasn't aware of it  
> either :)

~/.gambcini.scm is where you should put any commands or definitions  
(macros or procedures) which you want to have access to from the REPL  
and other loaded code.

For example, if you want to be able to use syntax-case with no other  
incantations to gsi then put this in your .gambcini.scm file:

(println "loading ~/.gambcini.scm")
(load "~~lib/syntax-case")

If you are a Common Lisp fan and you would like to use "defun" to  
define functions:

(define-macro (defun name params . body)
   `(define ,name (lambda ,params , at body)))

[note that macros defined in .gambcini.scm are available in the REPL  
and programs loaded from the REPL]

If you constantly need "fib" then add:

(defun fib (n)
   (if (< n 2)
       1
       (+ (fib (- n 1))
          (fib (- n 2)))))

etc.

Marc




More information about the Gambit-list mailing list