[gambit-list] What's in your gambc.scm file?
nikki at crysalis.com
Thu Oct 1 08:24:42 EDT 2009
On 01/10/2009 1:17 PM, Marc Feeley wrote:
> 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
>>> examples of what that file is so I thought I might ask what you all do
>>> in the init file.
>> '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)
> (+ (fib (- n 1))
> (fib (- n 2)))))
I realised that was the purpose of it, I was correcting the 'init file'
of ~/gambc.scm that TYSiFD states, as Robert was quoting...
While we're on the subject though, I notice that ~/.gambcini.scm gets
compiled *before* any command line parameters - thus rendering it
'awkward' for blackhole users, since anything defined in it has to
explicitly put in the "~" namespace...
Wouldn't it make more sense for it to be executed after command line
parameters? Or am I missing something?
(As for your example of defun, I wouldn't do that, but I am partial to
lisp's 'nth' function and find myself defining that an awful lot, so
I've put it in the ini file for now :)
More information about the Gambit-list