Hi all,

Now that we have the "namespaced identifier" support, we can finish
the (chicken load) module by not exporting load from it.  I've also
removed load-extension, because that's really just a one-argument
alias for `require', and it's confusing/redundant to have both, which
is probably why we reomved it from c-l-r.

Note that I had to add (import scheme) to module.scm, which isn't
wrapped in a module yet, because otherwise I'd get an error about
`load' not being defined.  This shouldn't be necessary, but probably
has to do with how the bootstrapping CHICKEN's chicken.load does
export `load' while the CHICKEN being built doesn't?  If someone
can explain to me exactly how it works, please do!

Cheers,
Peter
From eb806b43006940ad03a829a3def34ebb3f874450 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sun, 25 Jun 2017 16:01:59 +0200
Subject: [PATCH] Finalize (chicken load) by hiding `load' and `load-extension'

`load-extension' was deprecated in favor of `require'. `load' must be
exported by scheme, and it makes no sense to export it in two modules
so we do not export it from (chicken load).

This also adds those type database entries which were missing for the
remaining exported procedures in (chicken load).
---
 chicken.import.scm |  1 -
 core.scm           |  2 +-
 eval.scm           | 39 ++++++++++++++++-----------------------
 modules.scm        |  3 ++-
 types.db           |  5 ++++-
 5 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/chicken.import.scm b/chicken.import.scm
index 8a5f28f8..7b0600a4 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -127,7 +127,6 @@
    (installation-repository . chicken.platform#installation-repository)
    (ir-macro-transformer . chicken.syntax#ir-macro-transformer)
    keyword-style
-   (load-extension . chicken.load#load-extension)
    (load-library . chicken.load#load-library)
    (load-noisily . chicken.load#load-noisily)
    (load-relative . chicken.load#load-relative)
diff --git a/core.scm b/core.scm
index c2632cd4..54c34b41 100644
--- a/core.scm
+++ b/core.scm
@@ -693,7 +693,7 @@
 			   ,(walk (caddr x) e se dest ldest h ln #f)))
 
 			((##core#require-for-syntax)
-			 (load-extension (cadr x))
+			 (require (cadr x))
 			 '(##core#undefined))
 
 			((##core#require)
diff --git a/eval.scm b/eval.scm
index 772d0fb0..e86d2e58 100644
--- a/eval.scm
+++ b/eval.scm
@@ -584,7 +584,7 @@
 
 			 [(##core#require-for-syntax)
 			  (let ((id (cadr x)))
-			    (chicken.load#load-extension id)
+			    (chicken.load#require id)
 			    (compile '(##core#undefined)
 			     e #f tf cntr se #f))]
 
@@ -876,9 +876,9 @@
 
 
 (module chicken.load
-  (dynamic-load-libraries
-   load load-extension load-library load-noisily load-relative load-verbose
-   provide provided? require set-dynamic-load-mode!)
+  (dynamic-load-libraries set-dynamic-load-mode!
+   load-library load-noisily load-relative load-verbose
+   provide provided? require)
 
 (import (except scheme load)
 	chicken
@@ -1098,13 +1098,14 @@
 		    (close-input-port in))))))))
       (##core#undefined))))
 
-(define (load filename . evaluator)
-  (load/internal filename (optional evaluator #f)))
+;; Exported by "scheme", so use full name to avoid exporting it here.
+;; TODO: Maybe change this later to (set! scheme#load (lambda ..))
+(define (chicken.load#load filename #!optional evaluator)
+  (load/internal filename evaluator))
 
-(define (load-relative filename . evaluator)
-  (load/internal
-   (make-relative-pathname ##sys#current-load-filename filename)
-   (optional evaluator #f)))
+(define (load-relative filename #!optional evaluator)
+  (let ((fn (make-relative-pathname ##sys#current-load-filename filename)))
+    (load/internal fn evaluator)))
 
 (define (load-noisily filename #!key (evaluator #f) (time #f) (printer #f))
   (load/internal filename evaluator #t time printer))
@@ -1258,7 +1259,7 @@
 		 (or (check pa)
 		     (loop (##sys#slot paths 1)) ) ) ) ) ) ) ))
 
-(define (load-extension/internal id alternates loc)
+(define (chicken.load#load-extension id alternates loc)
   (cond ((##sys#provided? id))
 	((any ##sys#provided? alternates))
 	((memq id core-units)
@@ -1270,17 +1271,9 @@
 	(else
 	 (##sys#error loc "cannot load extension" id))))
 
-(define (##sys#load-extension id #!optional (alternates '()) loc)
-  (load-extension/internal id alternates loc)
-  (##core#undefined))
-
-(define (load-extension id)
-  (##sys#check-symbol id 'load-extension)
-  (##sys#load-extension id '() 'load-extension))
-
 (define (require . ids)
   (for-each (cut ##sys#check-symbol <> 'require) ids)
-  (for-each (cut ##sys#load-extension <> '() 'require) ids))
+  (for-each (cut chicken.load#load-extension <> '() 'require) ids))
 
 (define (provide . ids)
   (for-each (cut ##sys#check-symbol <> 'provide) ids)
@@ -1332,9 +1325,9 @@
          (mark-static id path)
          (values `(##core#declare (uses ,id)) id 'static)))
       (else
-       (values `(##sys#load-extension
-		 (##core#quote ,id)
-		 (##core#quote ,alternates))
+       (values `(chicken.load#load-extension (##core#quote ,id)
+					     (##core#quote ,alternates)
+					     'process-require)
 	       #f
 	       'dynamic)))))
 
diff --git a/modules.scm b/modules.scm
index 28cab3d6..48578fbb 100644
--- a/modules.scm
+++ b/modules.scm
@@ -39,7 +39,8 @@
 
 (define-syntax d (syntax-rules () ((_ . _) (void))))
 
-(import chicken.internal
+(import scheme
+	chicken.internal
 	chicken.keyword
 	chicken.load
 	chicken.platform
diff --git a/types.db b/types.db
index 40a5e05e..8aeaf28c 100644
--- a/types.db
+++ b/types.db
@@ -1210,14 +1210,17 @@
 
 ;; load
 
+(chicken.load#dynamic-load-libraries
+ (#(procedure #:clean) chicken.load#dynamic-load-libraries (#!optional (list-of string)) (list-of string)))
 (chicken.load#load (procedure chicken.load#load (string #!optional (procedure (*) . *)) undefined))
-(chicken.load#load-extension (#(procedure #:enforce) chicken.load#load-extension (symbol) undefined))
 (chicken.load#load-library (#(procedure #:enforce) chicken.load#load-library (symbol #!optional string) undefined))
+(chicken.load#load-noisily (procedure chicken.load#load-noisily (string #!optional (procedure (*) . *) boolean (procedure (*) . *)) undefined))
 (chicken.load#load-relative (#(procedure #:enforce) chicken.load#load-relative (string #!optional (procedure (*) . *)) undefined))
 (chicken.load#load-verbose (#(procedure #:clean) chicken.load#load-verbose (#!optional *) *))
 (chicken.load#provide (#(procedure #:clean #:enforce) chicken.load#provide (#!rest symbol) undefined))
 (chicken.load#provided? (#(procedure #:clean #:enforce) chicken.load#provided? (#!rest symbol) boolean))
 (chicken.load#require (#(procedure #:clean) chicken.load#require (#!rest symbol) undefined))
+(chicken.load#set-dynamic-load-mode! (#(procedure #:clean #:enforce) chicken.load#set-dynamic-load-mode! ((or symbol (list-of symbol))) undefined))
 
 ;; platform
 
-- 
2.11.0

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to