[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] compilation question

From: Peter Keller
Subject: [Chicken-users] compilation question
Date: Sat, 14 Dec 2002 20:20:19 -0600
User-agent: Mutt/1.4i


Suppose I have this set of functions and files:

file foo.scm:
(define make-counter
        (let ((count 0))
                (lambda ()
                        (let ((temp count))
                                (set! count (+ count 1))
(define count1 (make-counter))
(define count2 (make-counter))
(define count3 (make-counter))

file bar1.scm:
(declare (unit bar1))
(include "foo.scm")
;; code which uses count1, count2, count3

file bar2.scm:
(declare (unit bar2))
(include "foo.scm")
;; code which uses count1, count2, count3

file bar3.scm:
(declare (unit bar3))
(include "foo.scm")
;; code which uses count1, count2, count3

file top.scm:
(declare (uses bar1) (uses bar2) (uses bar3))
;; code

Now suppose I compile bar1.scm, bar2.scm, bar3.scm, and top.scm separately
and link them all together to form an executable. How many copies of
count1, count2, and count3 are there going to be, and is an invocation
of count1 in bar1.scm, bar2.scm, or bar3.scm going to produce the correct
monotonically increasing number that is unique between bar1.scm, bar2.scm,
and bar3.scm?

How is this dealt with?

This comes up because I want to generate unique identifiers for each
result object in my testing infrastructure, but if the above ever happens
in someone's project, I don't know what is going to happen. Since it is
easy to write temendously sized test suite codes, I think people would
want separate compilation to speed up the development process.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]