[gambit-list] Reliable way of knowing whether you are in the REPL

Marc Feeley feeley at iro.umontreal.ca
Sun Mar 15 17:33:40 EDT 2015


I’m not sure what you mean.  Can you give an example of what you want to do?  Do you want to distinguish between (load "foo.scm") and

gsi foo.scm

There is no general way to distinguish them.  Howwever, if you use start the Scheme file with a shebang line, then you could do something like this:

% cat load-test.scm 
#! /usr/bin/env gsi

(define (interactive-load?)
  (equal? (##command-line) ##processed-command-line))

(if (interactive-load?)
    (pp 'interactive-load)
    (pp 'batch-load))
% gsi load-test.scm
batch-load
% gsi
Gambit v4.7.4

> (load "load-test.scm")
interactive-load
"/Users/feeley/load-test.scm"

Marc

> On Mar 15, 2015, at 9:03 AM, Álvaro Castro-Castilla <alvaro.castro.castilla at gmail.com> wrote:
> 
> Hello,
> 
> I'm trying to find a way of knowing if some code is being run interactively or in batch mode. Is there a reliable way for this?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4839 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20150315/2f8ae799/attachment.bin>


More information about the Gambit-list mailing list