~ chicken-core (chicken-5) de78797fa243211aca7d7ac520291f85d67051a7


commit de78797fa243211aca7d7ac520291f85d67051a7
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Wed Jan 13 22:54:21 2016 +1300
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Tue Mar 8 22:52:33 2016 +1300

    Move random[ize] to new chicken.random module

diff --git a/README b/README
index d950e28a..6a03430e 100644
--- a/README
+++ b/README
@@ -299,6 +299,7 @@
 	|   |       |-- chicken.irregex.import.so
 	|   |       |-- chicken.ports.import.so
 	|   |       |-- chicken.posix.import.so
+	|   |       |-- chicken.random.import.so
 	|   |       |-- chicken.repl.import.so
 	|   |       |-- chicken.tcp.import.so
 	|   |       |-- chicken.utils.import.so
diff --git a/chicken-install.scm b/chicken-install.scm
index 79dfc7c6..c25003d2 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -58,6 +58,7 @@
       "chicken.lolevel.import.so"
       "chicken.ports.import.so"
       "chicken.posix.import.so"
+      "chicken.random.import.so"
       "chicken.repl.import.so"
       "chicken.tcp.import.so"
       "chicken.utils.import.so"
diff --git a/defaults.make b/defaults.make
index 7ca9bc87..b9c1e039 100644
--- a/defaults.make
+++ b/defaults.make
@@ -264,7 +264,7 @@ CHICKEN_PROGRAM_OPTIONS += $(if $(PROFILE_OBJECTS),-profile)
 
 PRIMITIVE_IMPORT_LIBRARIES = chicken csi chicken.foreign
 DYNAMIC_IMPORT_LIBRARIES = setup-api setup-download srfi-4
-DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise posix
+DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise posix random
 DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES = data-structures eval repl expand \
 	continuation extras files internal irregex lolevel ports tcp utils
 
diff --git a/distribution/manifest b/distribution/manifest
index 9b56d71d..17100d7a 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -270,6 +270,8 @@ chicken.ports.import.scm
 chicken.ports.import.c
 chicken.posix.import.scm
 chicken.posix.import.c
+chicken.random.import.scm
+chicken.random.import.c
 chicken.repl.import.scm
 chicken.repl.import.c
 chicken.tcp.import.scm
diff --git a/extras.scm b/extras.scm
index 5185ad5c..34e04307 100644
--- a/extras.scm
+++ b/extras.scm
@@ -31,7 +31,7 @@
 
 (module chicken.extras
   (format fprintf pp pretty-print pretty-print-width printf
-   random randomize read-buffered read-byte read-file read-line
+   read-buffered read-byte read-file read-line
    read-lines read-string read-string! read-token sprintf
    write-byte write-line write-string)
 
@@ -57,22 +57,6 @@
 	  (call-with-input-file port slurp) ) ) ) )
 
 
-;;; Random numbers:
-
-(define (randomize . n)
-  (let ((nn (if (null? n)
-		(quotient (current-seconds) 1000) ; wall clock time
-		(car n))))
-    (##sys#check-fixnum nn 'randomize)
-    (##core#inline "C_randomize" nn) ) )
-
-(define (random n)
-  (##sys#check-fixnum n 'random)
-  (if (eq? n 0)
-      0
-      (##core#inline "C_random_fixnum" n) ) )
-
-
 ;;; Line I/O:
 
 (define read-line
@@ -655,6 +639,25 @@
 		  (##sys#error 'format "illegal destination" fmt-or-dst args)])
 	   args) ) )
 
-(register-feature! 'srfi-28)
+(register-feature! 'srfi-28))
+
 
-)
+;;; Random numbers:
+
+(module chicken.random
+  (randomize random)
+
+(import scheme chicken)
+
+(define (randomize . n)
+  (let ((nn (if (null? n)
+		(quotient (current-seconds) 1000) ; wall clock time
+		(car n))))
+    (##sys#check-fixnum nn 'randomize)
+    (##core#inline "C_randomize" nn)))
+
+(define (random n)
+  (##sys#check-fixnum n 'random)
+  (if (eq? n 0)
+      0
+      (##core#inline "C_random_fixnum" n))))
diff --git a/manual/Unit extras b/manual/Unit extras
index cb9d4299..ec3e9631 100644
--- a/manual/Unit extras	
+++ b/manual/Unit extras	
@@ -8,6 +8,7 @@ used in {{csi}} by default.
 
 === Random numbers
 
+These procedures are provided by the {{(chicken random)}} module.
 
 ==== randomize
 
diff --git a/modules.scm b/modules.scm
index 367c07fd..23c5f16a 100644
--- a/modules.scm
+++ b/modules.scm
@@ -942,6 +942,7 @@
 (##sys#register-module-alias 'lolevel 'chicken.lolevel)
 (##sys#register-module-alias 'ports 'chicken.ports)
 (##sys#register-module-alias 'posix 'chicken.posix)
+(##sys#register-module-alias 'random 'chicken.random)
 (##sys#register-module-alias 'repl 'chicken.repl)
 (##sys#register-module-alias 'tcp 'chicken.tcp)
 (##sys#register-module-alias 'utils 'chicken.utils)
diff --git a/posixwin.scm b/posixwin.scm
index 9990881d..d811825e 100644
--- a/posixwin.scm
+++ b/posixwin.scm
@@ -718,7 +718,8 @@ EOF
 	chicken.files
 	chicken.foreign
 	chicken.irregex
-	chicken.ports)
+	chicken.ports
+	chicken.random)
 
 (include "posix-common.scm")
 
diff --git a/rules.make b/rules.make
index a2644962..6c1938ee 100644
--- a/rules.make
+++ b/rules.make
@@ -519,6 +519,7 @@ $(foreach lib, $(filter-out chicken,$(COMPILER_OBJECTS_1)),\
 # special cases for modules not corresponding directly to units
 $(eval $(call declare-emitted-import-lib-dependency,chicken.posix,$(POSIXFILE)))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.bitwise,library))
+$(eval $(call declare-emitted-import-lib-dependency,chicken.random,extras))
 
 chicken.c: chicken.scm mini-srfi-1.scm \
 		chicken.compiler.batch-driver.import.scm \
@@ -589,7 +590,8 @@ support.c: support.scm mini-srfi-1.scm \
 		chicken.extras.import.scm \
 		chicken.files.import.scm \
 		chicken.foreign.import.scm \
-		chicken.ports.import.scm
+		chicken.ports.import.scm \
+		chicken.random.import.scm
 csc.c: csc.scm \
 		chicken.posix.import.scm \
 		chicken.data-structures.import.scm \
@@ -724,7 +726,7 @@ expand.c: $(SRCDIR)expand.scm $(SRCDIR)synrules.scm $(SRCDIR)common-declarations
 modules.c: $(SRCDIR)modules.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 	$(bootstrap-lib)
 extras.c: $(SRCDIR)extras.scm $(SRCDIR)common-declarations.scm
-	$(bootstrap-lib) -emit-import-library chicken.extras
+	$(bootstrap-lib) -emit-import-library chicken.extras -emit-import-library chicken.random
 posixunix.c: $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 	$(bootstrap-lib) -emit-import-library chicken.posix
 posixwin.c: $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
diff --git a/support.scm b/support.scm
index 4a992cb5..a730c3ea 100644
--- a/support.scm
+++ b/support.scm
@@ -81,7 +81,8 @@
 	chicken.extras
 	chicken.files
 	chicken.foreign
-	chicken.ports)
+	chicken.ports
+	chicken.random)
 
 (include "tweaks")
 (include "mini-srfi-1.scm")
diff --git a/tests/arithmetic-test.scm b/tests/arithmetic-test.scm
index e1472339..e1b56d7c 100644
--- a/tests/arithmetic-test.scm
+++ b/tests/arithmetic-test.scm
@@ -15,7 +15,7 @@
   (else))
 
 
-(use extras)
+(use extras random)
 
 #+use-numbers (use numbers)
 
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 41aaa2e1..fab020b2 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -50,6 +50,7 @@ for x in \
     chicken.lolevel.import.so \
     chicken.ports.import.so \
     chicken.posix.import.so \
+    chicken.random.import.so \
     chicken.repl.import.so \
     chicken.tcp.import.so \
     chicken.utils.import.so
diff --git a/types.db b/types.db
index 5cc68e5e..606c4109 100644
--- a/types.db
+++ b/types.db
@@ -1525,8 +1525,6 @@
 (chicken.extras#pretty-print (#(procedure #:enforce) chicken.extras#pretty-print (* #!optional output-port) undefined))
 (chicken.extras#pretty-print-width (#(procedure #:clean) chicken.extras#pretty-print-width (#!optional fixnum) *))
 (chicken.extras#printf (#(procedure #:enforce) chicken.extras#printf (string #!rest) undefined))
-(chicken.extras#random (#(procedure #:clean #:enforce) chicken.extras#random (fixnum) fixnum))
-(chicken.extras#randomize (#(procedure #:clean #:enforce) chicken.extras#randomize (#!optional fixnum) undefined))
 (chicken.extras#read-buffered (#(procedure #:enforce) chicken.extras#read-buffered (#!optional input-port) string))
 (chicken.extras#read-byte (#(procedure #:enforce) chicken.extras#read-byte (#!optional input-port) *))
 (chicken.extras#read-file (#(procedure #:enforce) chicken.extras#read-file (#!optional (or input-port string) (procedure (input-port) *) fixnum) list))
@@ -1540,6 +1538,10 @@
 (chicken.extras#write-line (#(procedure #:enforce) chicken.extras#write-line (string #!optional output-port) undefined))
 (chicken.extras#write-string (#(procedure #:enforce) chicken.extras#write-string (string #!optional * output-port) undefined))
 
+;; random
+
+(chicken.random#random (#(procedure #:clean #:enforce) chicken.random#random (fixnum) fixnum))
+(chicken.random#randomize (#(procedure #:clean #:enforce) chicken.random#randomize (#!optional fixnum) undefined))
 
 ;; files
 
Trap