weird pasted by andyjpb on Mon Jul 15 19:18:49 2013



Main program:

-----
(use (prefix knapp.app knapp.app:))

...

(knapp.app:initialise)
-----



In module knapp.app :

-----
(use (prefix config cfg:))

...

(define (initialise)
  (printf "ding...\n")
  (cfg:load-config 'knapp.app "the-config.scm")
  (assert (number? (cfg:node-id)))
  (assert (string? (cfg:file-store-path)))
  (assert (string? (cfg:database-file)))
-----


In module config:

-----
(module config
 *

(import chicken scheme)

(define customer        (make-parameter #f))

(define node-id         (make-parameter #f))
(define file-store-path (make-parameter #f))
(define database-file   (make-parameter #f)) ; use the guard to prepend the current working directory if the path is relative.

(define (load-config the-customer file)
 ; find the file in . /etc/knodium ...
 ; Change into the directory containing the-config.scm
 (printf "Reading...")
 (parameterize ((customer the-customer))
	       (load file))

)

)
-----


In the-config.scm:

-----
(use config)

(node-id         5)
(file-store-path "ugc/")
(database-file   "../db/knodium.sqlite")
(display (customer))
;ssl cert file
-----


Output at runtime:

-----
ding...
Reading...knapp.appReading...knapp.appReading...knapp.app
-----




...and with the-config.scm:

-----
(use config)

(node-id         5)
(file-store-path "ugc/")
(database-file   "../db/knodium.sqlite")
(display (customer))
	(newline)
;ssl cert file
-----

Output at runtime:

-----
ding...
Reading...knapp.app
-----



...weird?


no title added by anonymous on Wed Jul 17 12:00:14 2013

With the-config.scm:

-----
(use config)

(node-id         5)
(file-store-path "ugc/")
(database-file   "../db/knodium.sqlite")
(display (customer))
	(let ((x (conc "a " (with-input-from-file "/tmp/ppp" read-line))))
	(with-output-to-file "/tmp/ppp" (lambda () (write-line x))))
;ssl cert file
-----


I see

-----
ding...
Reading...knapp.appReading...knapp.appReading...knapp.app
-----

but I the same /tmp/ppp file as with the-config.scm thus:

-----
(use config)

(node-id         5)
(file-store-path "ugc/")
(database-file   "../db/knodium.sqlite")
(display (customer))
(newline)
	(let ((x (conc "a " (with-input-from-file "/tmp/ppp" read-line))))
	(with-output-to-file "/tmp/ppp" (lambda () (write-line x))))
;ssl cert file
-----