Gauche Devlog

< It seems working. But... | Macro system extension >

2013/08/01

.gaucherc

When gosh is started in the interactive REPL mode, it loads ~/.gaucherc if it exists. I suppose it may be handy if the user needs his own local setup, even though I personally haven't used the rc file yet---I guess it's a sort of traditional Unix culture.

Recently I realized this feature interferes with R7RS mode. The .gaucherc file is loaded into #<module user>, but what's visible from the user module differs greatly when gosh is invoked with -r7 option. It'll be quite difficult to write .gaucherc that can work both in traditional Gauche mode and r7rs mode.

(Note: I say r7rs mode and Gauche mode, but it's not that there are two separate modes, except the planned reader compatibility modes. You can load R7RS library from standard Gauche program and load Gauche library from standard R7RS program, no matter whether you start gosh with -r7 option or not. The -r7 option merely specifies which environment you're in at the time interactive REPL starts.)

I considered a few options:

  • If -r7 option is given, try to load a different rc file, e.g. ~/.gaucherc-r7. This option is less appealing: It scatters more rc files in the home directory. Besides, I expect things you want to do in rc file are likely to need to access Gauche-specific features (e.g. add-load-path) and you can't do that easily from R7RS environment. You would need to create a separate module, e.g. mysetup.scm for the setup code, then (import (mysetup)) from .gaucherc-r7.
  • Let rc file be loaded in a module other than user, say, gauche.user module. Then you can use Gauche features in .gaucherc, regardless of -r7 option. This is clean, but adding a new module just for the rc file seems a bit overkill. Besides, it is incompatible to the current version if a user defines something in .gaucherc and expect it visible from the user module.
  • Drop .gaucherc support. This is a tempting solution, for it makes things simpler. But who knows? Sometimes this kind of hook comes handy unexpectedly.

Eventually I settled on somewhat compromised design.

  • We load .gaucherc to #<module user>, as we have been doing.
  • When gosh is started with -r7 option, the initial module will be #<module r7rs.user>, not #<module user>.

It looks a bit ad-hoc solution, but let's give a shot.

Tags: gosh, r7rs, gaucherc

Post a comment

Name: