unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* SLIB support
@ 2007-09-11 17:49 Andreas Rottmann
  2007-09-12 15:29 ` Andreas Rottmann
  2007-09-12 15:30 ` Andreas Rottmann
  0 siblings, 2 replies; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-11 17:49 UTC (permalink / raw)
  To: Guile Developers

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

Hi!

Currently on my System (Debian sid), Guile 1.8 does not support
SLIB. I have done a preliminary patch (attached) that makes the module
(ice-9 slib) load the guile.init file from SLIB, which seems to work
fine AFAICS.

Currently, the patch hard-codes the location of the guile.init file,
(which would be suitable for Debian use, but not for upstream); I had
the intention to improve this (using a path figured out by
configure.ac), if this is the right way to do this; another option
would be placing the contents of guile.init in the (ice-9 slib)
module. So which is the way forward? I'll prepare patches for Guile
upstream once I know what the right approach to this problem is...


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: slib.diff --]
[-- Type: text/x-diff, Size: 13506 bytes --]

Index: guile-1.8-1.8.2+1/ice-9/slib.scm
===================================================================
--- guile-1.8-1.8.2+1.orig/ice-9/slib.scm	2007-09-09 16:11:28.000000000 +0200
+++ guile-1.8-1.8.2+1/ice-9/slib.scm	2007-09-09 16:14:10.000000000 +0200
@@ -29,386 +29,8 @@
 	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
 	   slib:eval-load slib:tab slib:form-feed difftime offset-time
 	   software-type)
-  :replace (delete-file open-file provide provided? system)
+  :replace (provide provided?)
   :no-backtrace)
 
 \f
-
-(define (eval-load <filename> evl)
-  (if (not (file-exists? <filename>))
-      (set! <filename> (string-append <filename> (scheme-file-suffix))))
-  (call-with-input-file <filename>
-    (lambda (port)
-      (let ((old-load-pathname *load-pathname*))
-	(set! *load-pathname* <filename>)
-	(do ((o (read port) (read port)))
-	    ((eof-object? o))
-	  (evl o))
-	(set! *load-pathname* old-load-pathname)))))
-
-\f
-
-(define slib:exit quit)
-(define slib:error error)
-(define slib:warn warn)
-(define slib:eval (lambda (x) (eval x slib-module)))
-(define defmacro:eval (lambda (x) (eval x (interaction-environment))))
-(define logical:logand logand)
-(define logical:logior logior)
-(define logical:logxor logxor)
-(define logical:lognot lognot)
-(define logical:ash ash)
-(define logical:logcount logcount)
-(define logical:integer-length integer-length)
-(define logical:bit-extract bit-extract)
-(define logical:integer-expt integer-expt)
-(define slib:eval-load eval-load)
-(define slib:tab #\tab)
-(define slib:form-feed #\page)
-
-(define slib-module (current-module))
-
-(define (defined? symbol)
-  (module-defined? slib-module symbol))
-
-;;; *FEATURES* should be set to a list of symbols describing features
-;;; of this implementation.  Suggestions for features are:
-(set! *features*
-  (append
-      '(
-	source				;can load scheme source files
-					;(slib:load-source "filename")
-;	compiled			;can load compiled files
-					;(slib:load-compiled "filename")
-
-		       ;; Scheme report features
-
-;	rev5-report			;conforms to
-	eval				;R5RS two-argument eval
-;	values				;R5RS multiple values
-	dynamic-wind			;R5RS dynamic-wind
-;	macro				;R5RS high level macros
-	delay				;has DELAY and FORCE
-	multiarg-apply			;APPLY can take more than 2 args.
-;	rationalize
-	rev4-optional-procedures	;LIST-TAIL, STRING->LIST,
-					;LIST->STRING, STRING-COPY,
-					;STRING-FILL!, LIST->VECTOR,
-					;VECTOR->LIST, and VECTOR-FILL!
-
-;	rev4-report			;conforms to
-
-;	ieee-p1178			;conforms to
-
-;	rev3-report			;conforms to
-
-	rev2-procedures			;SUBSTRING-MOVE-LEFT!,
-					;SUBSTRING-MOVE-RIGHT!,
-					;SUBSTRING-FILL!,
-					;STRING-NULL?, APPEND!, 1+,
-					;-1+, <?, <=?, =?, >?, >=?
-;	object-hash			;has OBJECT-HASH
-
-	multiarg/and-			;/ and - can take more than 2 args.
-	with-file			;has WITH-INPUT-FROM-FILE and
-					;WITH-OUTPUT-FROM-FILE
-;	transcript			;TRANSCRIPT-ON and TRANSCRIPT-OFF
-;	ieee-floating-point		;conforms to IEEE Standard 754-1985
-					;IEEE Standard for Binary
-					;Floating-Point Arithmetic.
-	full-continuation		;can return multiple times
-
-			;; Other common features
-
-;	srfi				;srfi-0, COND-EXPAND finds all srfi-*
-;	sicp				;runs code from Structure and
-					;Interpretation of Computer
-					;Programs by Abelson and Sussman.
-	defmacro			;has Common Lisp DEFMACRO
-;	record				;has user defined data structures
-	string-port			;has CALL-WITH-INPUT-STRING and
-					;CALL-WITH-OUTPUT-STRING
-;	sort
-;	pretty-print
-;	object->string
-;	format				;Common-lisp output formatting
-;	trace				;has macros: TRACE and UNTRACE
-;	compiler			;has (COMPILER)
-;	ed				;(ED) is editor
-
-	;; core definitions compatible, plus `make-random-state' below
-	random
-	)
-
-	(if (defined? 'getenv)
-	    '(getenv)
-	    '())
-
-	(if (defined? 'current-time)
-	    '(current-time)
-	    '())
-
-	(if (defined? 'system)
-	    '(system)
-	    '())
-
-	(if (defined? 'char-ready?)
-	    '(char-ready?)
-	    '())
-
-	*features*))
-
-;; The array module specified by slib 3a1 is not the same as what guile
-;; provides, so we must remove `array' from the features list.
-;;
-;; The main difference is `create-array' which is similar to
-;; `make-uniform-array', but the `Ac64' etc prototype procedures incorporate
-;; an initial fill element into the prototype.
-;;
-;; Believe the array-for-each module will need to be taken from slib when
-;; the array module is taken from there, since what the array module creates
-;; won't be understood by the guile functions.  So remove `array-for-each'
-;; from the features list too.
-;;
-;; Also, slib 3a1 array-for-each specifies an `array-map' which is not in
-;; guile (but could be implemented quite easily).
-;;
-;; ENHANCE-ME: It'd be nice to implement what's necessary, since the guile
-;; functions should be more efficient than the implementation in slib.
-;;
-;; FIXME: Since the *features* variable is shared by slib and the guile
-;; core, removing these feature symbols has the unhappy effect of making it
-;; look like they aren't in the core either.  Let's assume that arrays have
-;; been present unconditionally long enough that no guile-specific code will
-;; bother to test.  An alternative would be to make a new separate
-;; *features* variable which the slib stuff operated on, leaving the core
-;; mechanism alone.  That might be a good thing anyway.
-;;
-(set! *features* (delq 'array          *features*))
-(set! *features* (delq 'array-for-each *features*))
-
-;; The random module in slib 3a1 provides a `random:chunk' which is used by
-;; the random-inexact module.  Guile doesn't provide random:chunk so we must
-;; remove 'random from `*features*' to use the slib code.
-;;
-;; ENHANCE-ME: Maybe Guile could provide a `random:chunk', the rest of the
-;; random module is already the same as Guile.
-;;
-;; FIXME: As per the array bits above, *features* is shared by slib and the
-;; guile core, so removing 'random has the unhappy effect of making it look
-;; like this isn't in the core.  Let's assume random numbers have been
-;; present unconditionally long enough that no guile-specific code will
-;; bother to test.
-;;
-(set! *features* (delq 'random *features*))
-
-
-;;; FIXME: Because uers want require to search the path, this uses
-;;; load-from-path, which probably isn't a hot idea.  slib
-;;; doesn't expect this function to search a path, so I expect to get
-;;; bug reports at some point complaining that the wrong file gets
-;;; loaded when something accidentally appears in the path before
-;;; slib, etc. ad nauseum.  However, the right fix seems to involve
-;;; changing catalog:get in slib/require.scm, and I don't expect
-;;; Aubrey will integrate such a change.  So I'm just going to punt
-;;; for the time being.
-(define (slib:load name)
-  (save-module-excursion
-   (lambda ()
-     (set-current-module slib-module)
-     (let ((errinfo (catch 'system-error
-			   (lambda ()
-			     (load-from-path name)
-			     #f)
-			   (lambda args args))))
-       (if (and errinfo
-		(catch 'system-error
-		       (lambda ()
-			 (load-from-path
-			  (string-append name ".scm"))
-			 #f)
-		       (lambda args args)))
-	   (apply throw errinfo))))))
-
-(define slib:load-source slib:load)
-(define defmacro:load slib:load)
-
-(define slib-parent-dir
-  (let* ((path (%search-load-path "slib/require.scm")))
-    (if path
-	(substring path 0 (- (string-length path) 17))
-	(error "Could not find slib/require.scm in " %load-path))))
-
-(define (implementation-vicinity)
-  (string-append slib-parent-dir "/"))
-(define (library-vicinity)
-  (string-append (implementation-vicinity) "slib/"))
-(define home-vicinity
-  (let ((home-path (getenv "HOME")))
-    (lambda () home-path)))
-(define (scheme-implementation-type) 'guile)
-(define scheme-implementation-version version)
-;;; (scheme-implementation-home-page) should return a (string) URI
-;;; (Uniform Resource Identifier) for this scheme implementation's home
-;;; page; or false if there isn't one.
-(define (scheme-implementation-home-page)
-  "http://www.gnu.org/software/guile/guile.html")
-
-;; legacy from r3rs, but slib says all implementations provide these
-;; ("Legacy" section of the "Miscellany" node in the manual)
-(define-public t   #t)
-(define-public nil #f)
-
-;; ENHANCE-ME: Could call ioctl TIOCGWINSZ to get the size of a tty (see
-;; "man 4 tty_ioctl" on a GNU/Linux system), on systems with that.
-(define (output-port-width . arg) 80)
-(define (output-port-height . arg) 24)
-
-;; slib 3a1 and up, straight from Template.scm
-(define-public (call-with-open-ports . ports)
-  (define proc (car ports))
-  (cond ((procedure? proc) (set! ports (cdr ports)))
-	(else (set! ports (reverse ports))
-	      (set! proc (car ports))
-	      (set! ports (reverse (cdr ports)))))
-  (let ((ans (apply proc ports)))
-    (for-each close-port ports)
-    ans))
-
-;; slib (version 3a1) requires open-file accept a symbol r, rb, w or wb for
-;; MODES, so extend the guile core open-file accordingly.
-;;
-;; slib (version 3a1) also calls open-file with strings "rb" or "wb", not
-;; sure if that's intentional, but in any case this extension continues to
-;; accept strings to make that work.
-;;
-(define-public (open-file filename modes)
-  (if (symbol? modes)
-      (set! modes (symbol->string modes)))
-  ((@ (guile) open-file) filename modes))
-
-;; returning #t/#f instead of throwing an error for failure
-(define-public (delete-file filename)
-  (catch 'system-error
-    (lambda () ((@ (guile) delete-file) filename) #t)
-    (lambda args #f)))
-
-;; Nothing special to do for this, so straight from Template.scm.  Maybe
-;; "sensible-browser" for a debian system would be worth trying too (and
-;; would be good on a tty).
-(define-public (browse-url url)
-  (define (try cmd end) (zero? (system (string-append cmd url end))))
-  (or (try "netscape-remote -remote 'openURL(" ")'")
-      (try "netscape -remote 'openURL(" ")'")
-      (try "netscape '" "'&")
-      (try "netscape '" "'")))
-
-;;; {array-for-each}
-(define (array-indexes ra)
-  (let ((ra0 (apply make-array '() (array-shape ra))))
-    (array-index-map! ra0 list)
-    ra0))
-
-;;; {Random numbers}
-;;;
-(define (make-random-state . args)
-  (let ((seed (if (null? args) *random-state* (car args))))
-    (cond ((string? seed))
-	  ((number? seed) (set! seed (number->string seed)))
-	  (else (let ()
-		  (require 'object->string)
-		  (set! seed (object->limited-string seed 50)))))
-    (seed->random-state seed)))
-
-;;; {rev2-procedures}
-;;;
-
-(define -1+ 1-)
-(define <?  <)
-(define <=? <=)
-(define =?  =)
-(define >?  >)
-(define >=? >=)
-
-;;; {system}
-;;;
-;; If the program run is killed by a signal, the shell normally gives an
-;; exit code of 128+signum.  If the shell itself is killed by a signal then
-;; we do the same 128+signum here.
-;;
-;; "stop-sig" shouldn't arise here, since system shouldn't be calling
-;; waitpid with WUNTRACED, but allow for it anyway, just in case.
-;;
-(if (memq 'system *features*)
-    (define-public system
-      (lambda (str)
-	(let ((st ((@ (guile) system) str)))
-	  (or (status:exit-val st)
-	      (+ 128 (or (status:term-sig st)
-			 (status:stop-sig st))))))))
-
-;;; {Time}
-;;;
-
-(define difftime -)
-(define offset-time +)
-
-\f
-(define define
-  (procedure->memoizing-macro
-   (lambda (exp env)
-     (if (= (length env) 1)
-	 `(define-public ,@(cdr exp))
-	 `(define-private ,@(cdr exp))))))
-
-;;; Hack to make syncase macros work in the slib module
-(if (nested-ref the-root-module '(app modules ice-9 syncase))
-    (set-object-property! (module-local-variable (current-module) 'define)
-			  '*sc-expander*
-			  '(define)))
-
-(define (software-type)
-  "Return a symbol describing the current platform's operating system.
-This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2,
-THINKC, AMIGA, ATARIST, MACH, or ACORN.
-
-Note that most varieties of Unix are considered to be simply \"UNIX\".
-That is because when a program depends on features that are not present
-on every operating system, it is usually better to test for the presence
-or absence of that specific feature.  The return value of
-@code{software-type} should only be used for this purpose when there is
-no other easy or unambiguous way of detecting such features."
- 'UNIX)
-
-(slib:load (in-vicinity (library-vicinity) "require.scm"))
-
-(define require require:require)
-
-;; {Extensions to the require system so that the user can add new
-;;  require modules easily.}
-
-(define *vicinity-table*
-  (list
-   (cons 'implementation (implementation-vicinity))
-   (cons 'library (library-vicinity))))
-
-(define (install-require-vicinity name vicinity)
-  (let ((entry (assq name *vicinity-table*)))
-    (if entry
-	(set-cdr! entry vicinity)
-	(set! *vicinity-table*
-	      (acons name vicinity *vicinity-table*)))))
-
-(define (install-require-module name vicinity-name file-name)
-  (if (not *catalog*)	     ;Fix which loads catalog in slib
-      (catalog:get 'random)) ;(doesn't load the feature 'random)
-  (let ((entry (assq name *catalog*))
-	(vicinity (cdr (assq vicinity-name *vicinity-table*))))
-    (let ((path-name (in-vicinity vicinity file-name)))
-      (if entry
-	  (set-cdr! entry path-name)
-	  (set! *catalog*
-		(acons name path-name *catalog*))))))
-
-(define (make-exchanger obj)
-  (lambda (rep) (let ((old obj)) (set! obj rep) old)))
+(load "/usr/share/slib/init/guile.init")

[-- Attachment #3: Type: text/plain, Size: 387 bytes --]


Regards, Rotty
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

Software Patents: Where do you want to stifle innovation today?

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-11 17:49 SLIB support Andreas Rottmann
@ 2007-09-12 15:29 ` Andreas Rottmann
  2007-09-12 15:30 ` Andreas Rottmann
  1 sibling, 0 replies; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-12 15:29 UTC (permalink / raw)
  To: Guile Developers

Andreas Rottmann <a.rottmann@gmx.at> writes:

> Hi!
>
> Currently on my System (Debian sid), Guile 1.8 does not support
> SLIB. I have done a preliminary patch (attached) that makes the module
> (ice-9 slib) load the guile.init file from SLIB, which seems to work
> fine AFAICS.
>
> Currently, the patch hard-codes the location of the guile.init file,
> (which would be suitable for Debian use, but not for upstream); I had
> the intention to improve this (using a path figured out by
> configure.ac), if this is the right way to do this; another option
> would be placing the contents of guile.init in the (ice-9 slib)
> module. So which is the way forward? I'll prepare patches for Guile
> upstream once I know what the right approach to this problem is...
>
I've now prepared a patch (attached) that's hopefully good enough for
upstream use.



-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

To iterate is human; to recurse, divine.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-11 17:49 SLIB support Andreas Rottmann
  2007-09-12 15:29 ` Andreas Rottmann
@ 2007-09-12 15:30 ` Andreas Rottmann
  2007-09-13  7:40   ` Ludovic Courtès
  2007-09-16  1:53   ` Rob Browning
  1 sibling, 2 replies; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-12 15:30 UTC (permalink / raw)
  To: Guile Developers

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]

Andreas Rottmann <a.rottmann@gmx.at> writes:

> Hi!
>
> Currently on my System (Debian sid), Guile 1.8 does not support
> SLIB. I have done a preliminary patch (attached) that makes the module
> (ice-9 slib) load the guile.init file from SLIB, which seems to work
> fine AFAICS.
>
> Currently, the patch hard-codes the location of the guile.init file,
> (which would be suitable for Debian use, but not for upstream); I had
> the intention to improve this (using a path figured out by
> configure.ac), if this is the right way to do this; another option
> would be placing the contents of guile.init in the (ice-9 slib)
> module. So which is the way forward? I'll prepare patches for Guile
> upstream once I know what the right approach to this problem is...
>
I've now prepared a patch (attached) that's hopefully good enough for
upstream use.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: slib.diff --]
[-- Type: text/x-diff, Size: 16274 bytes --]

Index: guile-1.8.2/ice-9/slib.scm
===================================================================
--- guile-1.8.2.orig/ice-9/slib.scm	2007-09-12 17:12:42.000000000 +0200
+++ guile-1.8.2/ice-9/slib.scm	2007-09-12 17:17:13.000000000 +0200
@@ -29,386 +29,8 @@
 	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
 	   slib:eval-load slib:tab slib:form-feed difftime offset-time
 	   software-type)
-  :replace (delete-file open-file provide provided? system)
+  :replace (provide provided?)
   :no-backtrace)
 
 \f
-
-(define (eval-load <filename> evl)
-  (if (not (file-exists? <filename>))
-      (set! <filename> (string-append <filename> (scheme-file-suffix))))
-  (call-with-input-file <filename>
-    (lambda (port)
-      (let ((old-load-pathname *load-pathname*))
-	(set! *load-pathname* <filename>)
-	(do ((o (read port) (read port)))
-	    ((eof-object? o))
-	  (evl o))
-	(set! *load-pathname* old-load-pathname)))))
-
-\f
-
-(define slib:exit quit)
-(define slib:error error)
-(define slib:warn warn)
-(define slib:eval (lambda (x) (eval x slib-module)))
-(define defmacro:eval (lambda (x) (eval x (interaction-environment))))
-(define logical:logand logand)
-(define logical:logior logior)
-(define logical:logxor logxor)
-(define logical:lognot lognot)
-(define logical:ash ash)
-(define logical:logcount logcount)
-(define logical:integer-length integer-length)
-(define logical:bit-extract bit-extract)
-(define logical:integer-expt integer-expt)
-(define slib:eval-load eval-load)
-(define slib:tab #\tab)
-(define slib:form-feed #\page)
-
-(define slib-module (current-module))
-
-(define (defined? symbol)
-  (module-defined? slib-module symbol))
-
-;;; *FEATURES* should be set to a list of symbols describing features
-;;; of this implementation.  Suggestions for features are:
-(set! *features*
-  (append
-      '(
-	source				;can load scheme source files
-					;(slib:load-source "filename")
-;	compiled			;can load compiled files
-					;(slib:load-compiled "filename")
-
-		       ;; Scheme report features
-
-;	rev5-report			;conforms to
-	eval				;R5RS two-argument eval
-;	values				;R5RS multiple values
-	dynamic-wind			;R5RS dynamic-wind
-;	macro				;R5RS high level macros
-	delay				;has DELAY and FORCE
-	multiarg-apply			;APPLY can take more than 2 args.
-;	rationalize
-	rev4-optional-procedures	;LIST-TAIL, STRING->LIST,
-					;LIST->STRING, STRING-COPY,
-					;STRING-FILL!, LIST->VECTOR,
-					;VECTOR->LIST, and VECTOR-FILL!
-
-;	rev4-report			;conforms to
-
-;	ieee-p1178			;conforms to
-
-;	rev3-report			;conforms to
-
-	rev2-procedures			;SUBSTRING-MOVE-LEFT!,
-					;SUBSTRING-MOVE-RIGHT!,
-					;SUBSTRING-FILL!,
-					;STRING-NULL?, APPEND!, 1+,
-					;-1+, <?, <=?, =?, >?, >=?
-;	object-hash			;has OBJECT-HASH
-
-	multiarg/and-			;/ and - can take more than 2 args.
-	with-file			;has WITH-INPUT-FROM-FILE and
-					;WITH-OUTPUT-FROM-FILE
-;	transcript			;TRANSCRIPT-ON and TRANSCRIPT-OFF
-;	ieee-floating-point		;conforms to IEEE Standard 754-1985
-					;IEEE Standard for Binary
-					;Floating-Point Arithmetic.
-	full-continuation		;can return multiple times
-
-			;; Other common features
-
-;	srfi				;srfi-0, COND-EXPAND finds all srfi-*
-;	sicp				;runs code from Structure and
-					;Interpretation of Computer
-					;Programs by Abelson and Sussman.
-	defmacro			;has Common Lisp DEFMACRO
-;	record				;has user defined data structures
-	string-port			;has CALL-WITH-INPUT-STRING and
-					;CALL-WITH-OUTPUT-STRING
-;	sort
-;	pretty-print
-;	object->string
-;	format				;Common-lisp output formatting
-;	trace				;has macros: TRACE and UNTRACE
-;	compiler			;has (COMPILER)
-;	ed				;(ED) is editor
-
-	;; core definitions compatible, plus `make-random-state' below
-	random
-	)
-
-	(if (defined? 'getenv)
-	    '(getenv)
-	    '())
-
-	(if (defined? 'current-time)
-	    '(current-time)
-	    '())
-
-	(if (defined? 'system)
-	    '(system)
-	    '())
-
-	(if (defined? 'char-ready?)
-	    '(char-ready?)
-	    '())
-
-	*features*))
-
-;; The array module specified by slib 3a1 is not the same as what guile
-;; provides, so we must remove `array' from the features list.
-;;
-;; The main difference is `create-array' which is similar to
-;; `make-uniform-array', but the `Ac64' etc prototype procedures incorporate
-;; an initial fill element into the prototype.
-;;
-;; Believe the array-for-each module will need to be taken from slib when
-;; the array module is taken from there, since what the array module creates
-;; won't be understood by the guile functions.  So remove `array-for-each'
-;; from the features list too.
-;;
-;; Also, slib 3a1 array-for-each specifies an `array-map' which is not in
-;; guile (but could be implemented quite easily).
-;;
-;; ENHANCE-ME: It'd be nice to implement what's necessary, since the guile
-;; functions should be more efficient than the implementation in slib.
-;;
-;; FIXME: Since the *features* variable is shared by slib and the guile
-;; core, removing these feature symbols has the unhappy effect of making it
-;; look like they aren't in the core either.  Let's assume that arrays have
-;; been present unconditionally long enough that no guile-specific code will
-;; bother to test.  An alternative would be to make a new separate
-;; *features* variable which the slib stuff operated on, leaving the core
-;; mechanism alone.  That might be a good thing anyway.
-;;
-(set! *features* (delq 'array          *features*))
-(set! *features* (delq 'array-for-each *features*))
-
-;; The random module in slib 3a1 provides a `random:chunk' which is used by
-;; the random-inexact module.  Guile doesn't provide random:chunk so we must
-;; remove 'random from `*features*' to use the slib code.
-;;
-;; ENHANCE-ME: Maybe Guile could provide a `random:chunk', the rest of the
-;; random module is already the same as Guile.
-;;
-;; FIXME: As per the array bits above, *features* is shared by slib and the
-;; guile core, so removing 'random has the unhappy effect of making it look
-;; like this isn't in the core.  Let's assume random numbers have been
-;; present unconditionally long enough that no guile-specific code will
-;; bother to test.
-;;
-(set! *features* (delq 'random *features*))
-
-
-;;; FIXME: Because uers want require to search the path, this uses
-;;; load-from-path, which probably isn't a hot idea.  slib
-;;; doesn't expect this function to search a path, so I expect to get
-;;; bug reports at some point complaining that the wrong file gets
-;;; loaded when something accidentally appears in the path before
-;;; slib, etc. ad nauseum.  However, the right fix seems to involve
-;;; changing catalog:get in slib/require.scm, and I don't expect
-;;; Aubrey will integrate such a change.  So I'm just going to punt
-;;; for the time being.
-(define (slib:load name)
-  (save-module-excursion
-   (lambda ()
-     (set-current-module slib-module)
-     (let ((errinfo (catch 'system-error
-			   (lambda ()
-			     (load-from-path name)
-			     #f)
-			   (lambda args args))))
-       (if (and errinfo
-		(catch 'system-error
-		       (lambda ()
-			 (load-from-path
-			  (string-append name ".scm"))
-			 #f)
-		       (lambda args args)))
-	   (apply throw errinfo))))))
-
-(define slib:load-source slib:load)
-(define defmacro:load slib:load)
-
-(define slib-parent-dir
-  (let* ((path (%search-load-path "slib/require.scm")))
-    (if path
-	(substring path 0 (- (string-length path) 17))
-	(error "Could not find slib/require.scm in " %load-path))))
-
-(define (implementation-vicinity)
-  (string-append slib-parent-dir "/"))
-(define (library-vicinity)
-  (string-append (implementation-vicinity) "slib/"))
-(define home-vicinity
-  (let ((home-path (getenv "HOME")))
-    (lambda () home-path)))
-(define (scheme-implementation-type) 'guile)
-(define scheme-implementation-version version)
-;;; (scheme-implementation-home-page) should return a (string) URI
-;;; (Uniform Resource Identifier) for this scheme implementation's home
-;;; page; or false if there isn't one.
-(define (scheme-implementation-home-page)
-  "http://www.gnu.org/software/guile/guile.html")
-
-;; legacy from r3rs, but slib says all implementations provide these
-;; ("Legacy" section of the "Miscellany" node in the manual)
-(define-public t   #t)
-(define-public nil #f)
-
-;; ENHANCE-ME: Could call ioctl TIOCGWINSZ to get the size of a tty (see
-;; "man 4 tty_ioctl" on a GNU/Linux system), on systems with that.
-(define (output-port-width . arg) 80)
-(define (output-port-height . arg) 24)
-
-;; slib 3a1 and up, straight from Template.scm
-(define-public (call-with-open-ports . ports)
-  (define proc (car ports))
-  (cond ((procedure? proc) (set! ports (cdr ports)))
-	(else (set! ports (reverse ports))
-	      (set! proc (car ports))
-	      (set! ports (reverse (cdr ports)))))
-  (let ((ans (apply proc ports)))
-    (for-each close-port ports)
-    ans))
-
-;; slib (version 3a1) requires open-file accept a symbol r, rb, w or wb for
-;; MODES, so extend the guile core open-file accordingly.
-;;
-;; slib (version 3a1) also calls open-file with strings "rb" or "wb", not
-;; sure if that's intentional, but in any case this extension continues to
-;; accept strings to make that work.
-;;
-(define-public (open-file filename modes)
-  (if (symbol? modes)
-      (set! modes (symbol->string modes)))
-  ((@ (guile) open-file) filename modes))
-
-;; returning #t/#f instead of throwing an error for failure
-(define-public (delete-file filename)
-  (catch 'system-error
-    (lambda () ((@ (guile) delete-file) filename) #t)
-    (lambda args #f)))
-
-;; Nothing special to do for this, so straight from Template.scm.  Maybe
-;; "sensible-browser" for a debian system would be worth trying too (and
-;; would be good on a tty).
-(define-public (browse-url url)
-  (define (try cmd end) (zero? (system (string-append cmd url end))))
-  (or (try "netscape-remote -remote 'openURL(" ")'")
-      (try "netscape -remote 'openURL(" ")'")
-      (try "netscape '" "'&")
-      (try "netscape '" "'")))
-
-;;; {array-for-each}
-(define (array-indexes ra)
-  (let ((ra0 (apply make-array '() (array-shape ra))))
-    (array-index-map! ra0 list)
-    ra0))
-
-;;; {Random numbers}
-;;;
-(define (make-random-state . args)
-  (let ((seed (if (null? args) *random-state* (car args))))
-    (cond ((string? seed))
-	  ((number? seed) (set! seed (number->string seed)))
-	  (else (let ()
-		  (require 'object->string)
-		  (set! seed (object->limited-string seed 50)))))
-    (seed->random-state seed)))
-
-;;; {rev2-procedures}
-;;;
-
-(define -1+ 1-)
-(define <?  <)
-(define <=? <=)
-(define =?  =)
-(define >?  >)
-(define >=? >=)
-
-;;; {system}
-;;;
-;; If the program run is killed by a signal, the shell normally gives an
-;; exit code of 128+signum.  If the shell itself is killed by a signal then
-;; we do the same 128+signum here.
-;;
-;; "stop-sig" shouldn't arise here, since system shouldn't be calling
-;; waitpid with WUNTRACED, but allow for it anyway, just in case.
-;;
-(if (memq 'system *features*)
-    (define-public system
-      (lambda (str)
-	(let ((st ((@ (guile) system) str)))
-	  (or (status:exit-val st)
-	      (+ 128 (or (status:term-sig st)
-			 (status:stop-sig st))))))))
-
-;;; {Time}
-;;;
-
-(define difftime -)
-(define offset-time +)
-
-\f
-(define define
-  (procedure->memoizing-macro
-   (lambda (exp env)
-     (if (= (length env) 1)
-	 `(define-public ,@(cdr exp))
-	 `(define-private ,@(cdr exp))))))
-
-;;; Hack to make syncase macros work in the slib module
-(if (nested-ref the-root-module '(app modules ice-9 syncase))
-    (set-object-property! (module-local-variable (current-module) 'define)
-			  '*sc-expander*
-			  '(define)))
-
-(define (software-type)
-  "Return a symbol describing the current platform's operating system.
-This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2,
-THINKC, AMIGA, ATARIST, MACH, or ACORN.
-
-Note that most varieties of Unix are considered to be simply \"UNIX\".
-That is because when a program depends on features that are not present
-on every operating system, it is usually better to test for the presence
-or absence of that specific feature.  The return value of
-@code{software-type} should only be used for this purpose when there is
-no other easy or unambiguous way of detecting such features."
- 'UNIX)
-
-(slib:load (in-vicinity (library-vicinity) "require.scm"))
-
-(define require require:require)
-
-;; {Extensions to the require system so that the user can add new
-;;  require modules easily.}
-
-(define *vicinity-table*
-  (list
-   (cons 'implementation (implementation-vicinity))
-   (cons 'library (library-vicinity))))
-
-(define (install-require-vicinity name vicinity)
-  (let ((entry (assq name *vicinity-table*)))
-    (if entry
-	(set-cdr! entry vicinity)
-	(set! *vicinity-table*
-	      (acons name vicinity *vicinity-table*)))))
-
-(define (install-require-module name vicinity-name file-name)
-  (if (not *catalog*)	     ;Fix which loads catalog in slib
-      (catalog:get 'random)) ;(doesn't load the feature 'random)
-  (let ((entry (assq name *catalog*))
-	(vicinity (cdr (assq vicinity-name *vicinity-table*))))
-    (let ((path-name (in-vicinity vicinity file-name)))
-      (if entry
-	  (set-cdr! entry path-name)
-	  (set! *catalog*
-		(acons name path-name *catalog*))))))
-
-(define (make-exchanger obj)
-  (lambda (rep) (let ((old obj)) (set! obj rep) old)))
+(load "/usr/share/slib/init/guile.init")
Index: guile-1.8.2/configure.in
===================================================================
--- guile-1.8.2.orig/configure.in	2007-09-12 17:12:42.000000000 +0200
+++ guile-1.8.2/configure.in	2007-09-12 17:14:39.000000000 +0200
@@ -171,6 +171,12 @@
   [  --disable-elisp         omit Emacs Lisp support],,
   enable_elisp=yes)
 
+AC_ARG_WITH([slib],
+	    AC_HELP_STRING([--with-slib=LOCATION], [Use SLIB located in LOCATION]),
+	    [SLIB_LOCATION="$withval"],
+	    [SLIB_LOCATION="$prefix/share/slib"])
+AC_SUBST(SLIB_LOCATION)
+
 #--------------------------------------------------------------------
 
 dnl Check for dynamic linking
@@ -1352,6 +1358,7 @@
   guile-config/Makefile
   ice-9/Makefile
   ice-9/debugger/Makefile
+  ice-9/slib.scm
   lang/Makefile
   lang/elisp/Makefile
   lang/elisp/internals/Makefile
Index: guile-1.8.2/ice-9/slib.scm.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ guile-1.8.2/ice-9/slib.scm.in	2007-09-12 17:14:39.000000000 +0200
@@ -0,0 +1,36 @@
+;;;; slib.scm --- definitions needed to get SLIB to work with Guile
+;;;;
+;;;;	Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+;;;;
+;;;; This library is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 2.1 of the License, or (at your option) any later version.
+;;;; 
+;;;; This library is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;;; Lesser General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free Software
+;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;;;;
+(define-module (ice-9 slib)
+  :export (slib:load slib:load-source defmacro:load
+	   implementation-vicinity library-vicinity home-vicinity
+	   scheme-implementation-type scheme-implementation-version
+	   output-port-width output-port-height array-indexes
+	   make-random-state
+	   -1+ <? <=? =? >? >=?
+	   require slib:error slib:exit slib:warn slib:eval
+	   defmacro:eval logical:logand logical:logior logical:logxor
+	   logical:lognot logical:ash logical:logcount logical:integer-length
+	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
+	   slib:eval-load slib:tab slib:form-feed difftime offset-time
+	   software-type)
+  :replace (provide provided?)
+  :no-backtrace)
+
+\f
+(load "@SLIB_LOCATION@/init/guile.init")

[-- Attachment #3: Type: text/plain, Size: 364 bytes --]


Regards, Rotty
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

To iterate is human; to recurse, divine.

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-12 15:30 ` Andreas Rottmann
@ 2007-09-13  7:40   ` Ludovic Courtès
  2007-09-13 13:14     ` Andreas Rottmann
  2007-09-16  1:53   ` Rob Browning
  1 sibling, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2007-09-13  7:40 UTC (permalink / raw)
  To: guile-devel

Hi Andreas,

Andreas Rottmann <a.rottmann@gmx.at> writes:

>> Currently on my System (Debian sid), Guile 1.8 does not support
>> SLIB. I have done a preliminary patch (attached) that makes the module
>> (ice-9 slib) load the guile.init file from SLIB, which seems to work
>> fine AFAICS.

The status of `(ice-9 slib)' has been discussed recently, the outcome
being that a solution similar to yours should be implemented [0].

However, instead of configure-time detection, I'd rather lean towards
using `load-from-path' without making any configure-time detection.
This would make it clear that SLIB is not a hard dependency and would
allow users to install/upgrade it afterwards.  Is that OK?

Thanks,
Ludovic.

[0] http://article.gmane.org/gmane.lisp.guile.devel/6764



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13  7:40   ` Ludovic Courtès
@ 2007-09-13 13:14     ` Andreas Rottmann
  2007-09-13 14:15       ` Greg Troxel
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-13 13:14 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:

> Hi Andreas,
>
> Andreas Rottmann <a.rottmann@gmx.at> writes:
>
>>> Currently on my System (Debian sid), Guile 1.8 does not support
>>> SLIB. I have done a preliminary patch (attached) that makes the module
>>> (ice-9 slib) load the guile.init file from SLIB, which seems to work
>>> fine AFAICS.
>
> The status of `(ice-9 slib)' has been discussed recently, the outcome
> being that a solution similar to yours should be implemented [0].
>
> However, instead of configure-time detection, I'd rather lean towards
> using `load-from-path' without making any configure-time detection.
> This would make it clear that SLIB is not a hard dependency and would
> allow users to install/upgrade it afterwards.  Is that OK?
>
I've now updated my patch (attached) to use a %LOAD-PATH search; it
looks for any of "slib/init/guile.init" (Debian) and "slib/guile.init"
(default installation) and loads it if found, erring out if there's no
such file in the %LOAD-PATH.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: slib.diff --]
[-- Type: text/x-diff, Size: 14286 bytes --]

Index: guile-1.8.2/ice-9/slib.scm
===================================================================
--- guile-1.8.2.orig/ice-9/slib.scm	2007-09-12 22:56:59.000000000 +0200
+++ guile-1.8.2/ice-9/slib.scm	2007-09-13 14:48:34.000000000 +0200
@@ -17,398 +17,13 @@
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 ;;;;
 (define-module (ice-9 slib)
-  :export (slib:load slib:load-source defmacro:load
-	   implementation-vicinity library-vicinity home-vicinity
-	   scheme-implementation-type scheme-implementation-version
-	   output-port-width output-port-height array-indexes
-	   make-random-state
-	   -1+ <? <=? =? >? >=?
-	   require slib:error slib:exit slib:warn slib:eval
-	   defmacro:eval logical:logand logical:logior logical:logxor
-	   logical:lognot logical:ash logical:logcount logical:integer-length
-	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
-	   slib:eval-load slib:tab slib:form-feed difftime offset-time
-	   software-type)
-  :replace (delete-file open-file provide provided? system)
+  :replace (provide provided?)
   :no-backtrace)
 
-\f
-
-(define (eval-load <filename> evl)
-  (if (not (file-exists? <filename>))
-      (set! <filename> (string-append <filename> (scheme-file-suffix))))
-  (call-with-input-file <filename>
-    (lambda (port)
-      (let ((old-load-pathname *load-pathname*))
-	(set! *load-pathname* <filename>)
-	(do ((o (read port) (read port)))
-	    ((eof-object? o))
-	  (evl o))
-	(set! *load-pathname* old-load-pathname)))))
-
-\f
-
-(define slib:exit quit)
-(define slib:error error)
-(define slib:warn warn)
-(define slib:eval (lambda (x) (eval x slib-module)))
-(define defmacro:eval (lambda (x) (eval x (interaction-environment))))
-(define logical:logand logand)
-(define logical:logior logior)
-(define logical:logxor logxor)
-(define logical:lognot lognot)
-(define logical:ash ash)
-(define logical:logcount logcount)
-(define logical:integer-length integer-length)
-(define logical:bit-extract bit-extract)
-(define logical:integer-expt integer-expt)
-(define slib:eval-load eval-load)
-(define slib:tab #\tab)
-(define slib:form-feed #\page)
-
-(define slib-module (current-module))
-
-(define (defined? symbol)
-  (module-defined? slib-module symbol))
-
-;;; *FEATURES* should be set to a list of symbols describing features
-;;; of this implementation.  Suggestions for features are:
-(set! *features*
-  (append
-      '(
-	source				;can load scheme source files
-					;(slib:load-source "filename")
-;	compiled			;can load compiled files
-					;(slib:load-compiled "filename")
-
-		       ;; Scheme report features
-
-;	rev5-report			;conforms to
-	eval				;R5RS two-argument eval
-;	values				;R5RS multiple values
-	dynamic-wind			;R5RS dynamic-wind
-;	macro				;R5RS high level macros
-	delay				;has DELAY and FORCE
-	multiarg-apply			;APPLY can take more than 2 args.
-;	rationalize
-	rev4-optional-procedures	;LIST-TAIL, STRING->LIST,
-					;LIST->STRING, STRING-COPY,
-					;STRING-FILL!, LIST->VECTOR,
-					;VECTOR->LIST, and VECTOR-FILL!
-
-;	rev4-report			;conforms to
-
-;	ieee-p1178			;conforms to
-
-;	rev3-report			;conforms to
-
-	rev2-procedures			;SUBSTRING-MOVE-LEFT!,
-					;SUBSTRING-MOVE-RIGHT!,
-					;SUBSTRING-FILL!,
-					;STRING-NULL?, APPEND!, 1+,
-					;-1+, <?, <=?, =?, >?, >=?
-;	object-hash			;has OBJECT-HASH
-
-	multiarg/and-			;/ and - can take more than 2 args.
-	with-file			;has WITH-INPUT-FROM-FILE and
-					;WITH-OUTPUT-FROM-FILE
-;	transcript			;TRANSCRIPT-ON and TRANSCRIPT-OFF
-;	ieee-floating-point		;conforms to IEEE Standard 754-1985
-					;IEEE Standard for Binary
-					;Floating-Point Arithmetic.
-	full-continuation		;can return multiple times
-
-			;; Other common features
-
-;	srfi				;srfi-0, COND-EXPAND finds all srfi-*
-;	sicp				;runs code from Structure and
-					;Interpretation of Computer
-					;Programs by Abelson and Sussman.
-	defmacro			;has Common Lisp DEFMACRO
-;	record				;has user defined data structures
-	string-port			;has CALL-WITH-INPUT-STRING and
-					;CALL-WITH-OUTPUT-STRING
-;	sort
-;	pretty-print
-;	object->string
-;	format				;Common-lisp output formatting
-;	trace				;has macros: TRACE and UNTRACE
-;	compiler			;has (COMPILER)
-;	ed				;(ED) is editor
-
-	;; core definitions compatible, plus `make-random-state' below
-	random
-	)
-
-	(if (defined? 'getenv)
-	    '(getenv)
-	    '())
-
-	(if (defined? 'current-time)
-	    '(current-time)
-	    '())
-
-	(if (defined? 'system)
-	    '(system)
-	    '())
-
-	(if (defined? 'char-ready?)
-	    '(char-ready?)
-	    '())
-
-	*features*))
-
-;; The array module specified by slib 3a1 is not the same as what guile
-;; provides, so we must remove `array' from the features list.
-;;
-;; The main difference is `create-array' which is similar to
-;; `make-uniform-array', but the `Ac64' etc prototype procedures incorporate
-;; an initial fill element into the prototype.
-;;
-;; Believe the array-for-each module will need to be taken from slib when
-;; the array module is taken from there, since what the array module creates
-;; won't be understood by the guile functions.  So remove `array-for-each'
-;; from the features list too.
-;;
-;; Also, slib 3a1 array-for-each specifies an `array-map' which is not in
-;; guile (but could be implemented quite easily).
-;;
-;; ENHANCE-ME: It'd be nice to implement what's necessary, since the guile
-;; functions should be more efficient than the implementation in slib.
-;;
-;; FIXME: Since the *features* variable is shared by slib and the guile
-;; core, removing these feature symbols has the unhappy effect of making it
-;; look like they aren't in the core either.  Let's assume that arrays have
-;; been present unconditionally long enough that no guile-specific code will
-;; bother to test.  An alternative would be to make a new separate
-;; *features* variable which the slib stuff operated on, leaving the core
-;; mechanism alone.  That might be a good thing anyway.
-;;
-(set! *features* (delq 'array          *features*))
-(set! *features* (delq 'array-for-each *features*))
-
-;; The random module in slib 3a1 provides a `random:chunk' which is used by
-;; the random-inexact module.  Guile doesn't provide random:chunk so we must
-;; remove 'random from `*features*' to use the slib code.
-;;
-;; ENHANCE-ME: Maybe Guile could provide a `random:chunk', the rest of the
-;; random module is already the same as Guile.
-;;
-;; FIXME: As per the array bits above, *features* is shared by slib and the
-;; guile core, so removing 'random has the unhappy effect of making it look
-;; like this isn't in the core.  Let's assume random numbers have been
-;; present unconditionally long enough that no guile-specific code will
-;; bother to test.
-;;
-(set! *features* (delq 'random *features*))
-
-
-;;; FIXME: Because uers want require to search the path, this uses
-;;; load-from-path, which probably isn't a hot idea.  slib
-;;; doesn't expect this function to search a path, so I expect to get
-;;; bug reports at some point complaining that the wrong file gets
-;;; loaded when something accidentally appears in the path before
-;;; slib, etc. ad nauseum.  However, the right fix seems to involve
-;;; changing catalog:get in slib/require.scm, and I don't expect
-;;; Aubrey will integrate such a change.  So I'm just going to punt
-;;; for the time being.
-(define (slib:load name)
-  (save-module-excursion
-   (lambda ()
-     (set-current-module slib-module)
-     (let ((errinfo (catch 'system-error
-			   (lambda ()
-			     (load-from-path name)
-			     #f)
-			   (lambda args args))))
-       (if (and errinfo
-		(catch 'system-error
-		       (lambda ()
-			 (load-from-path
-			  (string-append name ".scm"))
-			 #f)
-		       (lambda args args)))
-	   (apply throw errinfo))))))
-
-(define slib:load-source slib:load)
-(define defmacro:load slib:load)
-
-(define slib-parent-dir
-  (let* ((path (%search-load-path "slib/require.scm")))
-    (if path
-	(substring path 0 (- (string-length path) 17))
-	(error "Could not find slib/require.scm in " %load-path))))
-
-(define (implementation-vicinity)
-  (string-append slib-parent-dir "/"))
-(define (library-vicinity)
-  (string-append (implementation-vicinity) "slib/"))
-(define home-vicinity
-  (let ((home-path (getenv "HOME")))
-    (lambda () home-path)))
-(define (scheme-implementation-type) 'guile)
-(define scheme-implementation-version version)
-;;; (scheme-implementation-home-page) should return a (string) URI
-;;; (Uniform Resource Identifier) for this scheme implementation's home
-;;; page; or false if there isn't one.
-(define (scheme-implementation-home-page)
-  "http://www.gnu.org/software/guile/guile.html")
-
-;; legacy from r3rs, but slib says all implementations provide these
-;; ("Legacy" section of the "Miscellany" node in the manual)
-(define-public t   #t)
-(define-public nil #f)
-
-;; ENHANCE-ME: Could call ioctl TIOCGWINSZ to get the size of a tty (see
-;; "man 4 tty_ioctl" on a GNU/Linux system), on systems with that.
-(define (output-port-width . arg) 80)
-(define (output-port-height . arg) 24)
-
-;; slib 3a1 and up, straight from Template.scm
-(define-public (call-with-open-ports . ports)
-  (define proc (car ports))
-  (cond ((procedure? proc) (set! ports (cdr ports)))
-	(else (set! ports (reverse ports))
-	      (set! proc (car ports))
-	      (set! ports (reverse (cdr ports)))))
-  (let ((ans (apply proc ports)))
-    (for-each close-port ports)
-    ans))
-
-;; slib (version 3a1) requires open-file accept a symbol r, rb, w or wb for
-;; MODES, so extend the guile core open-file accordingly.
-;;
-;; slib (version 3a1) also calls open-file with strings "rb" or "wb", not
-;; sure if that's intentional, but in any case this extension continues to
-;; accept strings to make that work.
-;;
-(define-public (open-file filename modes)
-  (if (symbol? modes)
-      (set! modes (symbol->string modes)))
-  ((@ (guile) open-file) filename modes))
-
-;; returning #t/#f instead of throwing an error for failure
-(define-public (delete-file filename)
-  (catch 'system-error
-    (lambda () ((@ (guile) delete-file) filename) #t)
-    (lambda args #f)))
-
-;; Nothing special to do for this, so straight from Template.scm.  Maybe
-;; "sensible-browser" for a debian system would be worth trying too (and
-;; would be good on a tty).
-(define-public (browse-url url)
-  (define (try cmd end) (zero? (system (string-append cmd url end))))
-  (or (try "netscape-remote -remote 'openURL(" ")'")
-      (try "netscape -remote 'openURL(" ")'")
-      (try "netscape '" "'&")
-      (try "netscape '" "'")))
-
-;;; {array-for-each}
-(define (array-indexes ra)
-  (let ((ra0 (apply make-array '() (array-shape ra))))
-    (array-index-map! ra0 list)
-    ra0))
-
-;;; {Random numbers}
-;;;
-(define (make-random-state . args)
-  (let ((seed (if (null? args) *random-state* (car args))))
-    (cond ((string? seed))
-	  ((number? seed) (set! seed (number->string seed)))
-	  (else (let ()
-		  (require 'object->string)
-		  (set! seed (object->limited-string seed 50)))))
-    (seed->random-state seed)))
-
-;;; {rev2-procedures}
-;;;
-
-(define -1+ 1-)
-(define <?  <)
-(define <=? <=)
-(define =?  =)
-(define >?  >)
-(define >=? >=)
-
-;;; {system}
-;;;
-;; If the program run is killed by a signal, the shell normally gives an
-;; exit code of 128+signum.  If the shell itself is killed by a signal then
-;; we do the same 128+signum here.
-;;
-;; "stop-sig" shouldn't arise here, since system shouldn't be calling
-;; waitpid with WUNTRACED, but allow for it anyway, just in case.
-;;
-(if (memq 'system *features*)
-    (define-public system
-      (lambda (str)
-	(let ((st ((@ (guile) system) str)))
-	  (or (status:exit-val st)
-	      (+ 128 (or (status:term-sig st)
-			 (status:stop-sig st))))))))
-
-;;; {Time}
-;;;
-
-(define difftime -)
-(define offset-time +)
-
-\f
-(define define
-  (procedure->memoizing-macro
-   (lambda (exp env)
-     (if (= (length env) 1)
-	 `(define-public ,@(cdr exp))
-	 `(define-private ,@(cdr exp))))))
-
-;;; Hack to make syncase macros work in the slib module
-(if (nested-ref the-root-module '(app modules ice-9 syncase))
-    (set-object-property! (module-local-variable (current-module) 'define)
-			  '*sc-expander*
-			  '(define)))
-
-(define (software-type)
-  "Return a symbol describing the current platform's operating system.
-This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2,
-THINKC, AMIGA, ATARIST, MACH, or ACORN.
-
-Note that most varieties of Unix are considered to be simply \"UNIX\".
-That is because when a program depends on features that are not present
-on every operating system, it is usually better to test for the presence
-or absence of that specific feature.  The return value of
-@code{software-type} should only be used for this purpose when there is
-no other easy or unambiguous way of detecting such features."
- 'UNIX)
-
-(slib:load (in-vicinity (library-vicinity) "require.scm"))
-
-(define require require:require)
-
-;; {Extensions to the require system so that the user can add new
-;;  require modules easily.}
-
-(define *vicinity-table*
-  (list
-   (cons 'implementation (implementation-vicinity))
-   (cons 'library (library-vicinity))))
-
-(define (install-require-vicinity name vicinity)
-  (let ((entry (assq name *vicinity-table*)))
-    (if entry
-	(set-cdr! entry vicinity)
-	(set! *vicinity-table*
-	      (acons name vicinity *vicinity-table*)))))
-
-(define (install-require-module name vicinity-name file-name)
-  (if (not *catalog*)	     ;Fix which loads catalog in slib
-      (catalog:get 'random)) ;(doesn't load the feature 'random)
-  (let ((entry (assq name *catalog*))
-	(vicinity (cdr (assq vicinity-name *vicinity-table*))))
-    (let ((path-name (in-vicinity vicinity file-name)))
-      (if entry
-	  (set-cdr! entry path-name)
-	  (set! *catalog*
-		(acons name path-name *catalog*))))))
-
-(define (make-exchanger obj)
-  (lambda (rep) (let ((old obj)) (set! obj rep) old)))
+(let loop ((fnames '("slib/init/guile.init" "slib/guile.init")))
+  (cond ((null? fnames)
+         (error "SLIB not found in %load-path"))
+        ((%search-load-path (car fnames))
+         => load)
+        (else
+         (loop (cdr fnames)))))

[-- Attachment #3: Type: text/plain, Size: 348 bytes --]


Regards, Rotty
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

It's *GNU*/Linux dammit!

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13 13:14     ` Andreas Rottmann
@ 2007-09-13 14:15       ` Greg Troxel
  2007-09-13 14:35         ` Andreas Rottmann
  2007-09-13 15:39         ` Rob Browning
  0 siblings, 2 replies; 16+ messages in thread
From: Greg Troxel @ 2007-09-13 14:15 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: Ludovic Courtès, guile-devel

That should work on NetBSD:

fnord gdt 11 /usr/pkgsrc/devel/guile-slib > l /usr/pkg/share/guile/site/slib/guile.init 
-r--r--r--  1 root  wheel  19273 Mar 15 12:35 /usr/pkg/share/guile/site/slib/guile.init
fnord gdt 12 /usr/pkgsrc/devel/guile-slib > guile
guile> %load-path
("/usr/pkg/share/guile/site" "/usr/pkg/share/guile/1.8" "/usr/pkg/share/guile")


  +(let loop ((fnames '("slib/init/guile.init" "slib/guile.init")))

Shouldn't slib/guile.init, being the standard place, be first?  Or has
slib moved it in a more recent version?



Thanks for working on slib!


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13 14:15       ` Greg Troxel
@ 2007-09-13 14:35         ` Andreas Rottmann
  2007-09-13 15:39         ` Rob Browning
  1 sibling, 0 replies; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-13 14:35 UTC (permalink / raw)
  To: Greg Troxel; +Cc: Ludovic Courtès, guile-devel

Greg Troxel <gdt@ir.bbn.com> writes:

> That should work on NetBSD:
>
> fnord gdt 11 /usr/pkgsrc/devel/guile-slib > l /usr/pkg/share/guile/site/slib/guile.init 
> -r--r--r--  1 root  wheel  19273 Mar 15 12:35 /usr/pkg/share/guile/site/slib/guile.init
> fnord gdt 12 /usr/pkgsrc/devel/guile-slib > guile
> guile> %load-path
> ("/usr/pkg/share/guile/site" "/usr/pkg/share/guile/1.8" "/usr/pkg/share/guile")
>
>
>   +(let loop ((fnames '("slib/init/guile.init" "slib/guile.init")))
>
> Shouldn't slib/guile.init, being the standard place, be first?  Or has
> slib moved it in a more recent version?
>
Yeah, the order could be reversed; I don't really care.

Cheers, Rotty
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

Latein ist das humanoide Äquivalent zu Fortran.
   -- Alexander Bartolich in at.linux


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13 14:15       ` Greg Troxel
  2007-09-13 14:35         ` Andreas Rottmann
@ 2007-09-13 15:39         ` Rob Browning
  2007-09-13 15:56           ` Andreas Rottmann
  1 sibling, 1 reply; 16+ messages in thread
From: Rob Browning @ 2007-09-13 15:39 UTC (permalink / raw)
  To: Greg Troxel; +Cc: s, guile-devel

Greg Troxel <gdt@ir.bbn.com> writes:

> Shouldn't slib/guile.init, being the standard place, be first?  Or
> has slib moved it in a more recent version?

I think ice-9/slib.scm should only look for guile.init in it's normal,
default upstream location.

Has SLIB used both locations, or is one of them where the Debian SLIB
package moves the file?  If the latter, then I'd be inclined to let
Debian handle that in the Debian diff rather than add a distribution
specific adjustment to Guile's code.

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13 15:39         ` Rob Browning
@ 2007-09-13 15:56           ` Andreas Rottmann
  2007-09-15  9:10             ` Ludovic Courtès
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Rottmann @ 2007-09-13 15:56 UTC (permalink / raw)
  To: Rob Browning; +Cc: Ludovic Courtès, guile-devel, Greg Troxel

Rob Browning <rlb@defaultvalue.org> writes:

> Greg Troxel <gdt@ir.bbn.com> writes:
>
>> Shouldn't slib/guile.init, being the standard place, be first?  Or
>> has slib moved it in a more recent version?
>
> I think ice-9/slib.scm should only look for guile.init in it's normal,
> default upstream location.
>
OK.

> Has SLIB used both locations, or is one of them where the Debian SLIB
> package moves the file?  If the latter, then I'd be inclined to let
> Debian handle that in the Debian diff rather than add a distribution
> specific adjustment to Guile's code.
>
The latter. I agree that doing this in the Debian diff is
cleaner/preferable.

Regards, Rotty
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://rotty.uttx.net    | GnuPG Key: http://rotty.uttx.net/gpg.asc
Fingerprint              | C38A 39C5 16D7 B69F 33A3  6993 22C8 27F7 35A9 92E7
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

A. Because it breaks the logical sequence of discussion
Q. Why is top posting bad?


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-13 15:56           ` Andreas Rottmann
@ 2007-09-15  9:10             ` Ludovic Courtès
  2007-09-15 11:30               ` Greg Troxel
  2007-09-16  1:41               ` Rob Browning
  0 siblings, 2 replies; 16+ messages in thread
From: Ludovic Courtès @ 2007-09-15  9:10 UTC (permalink / raw)
  To: guile-devel

Hi,

Andreas Rottmann <a.rottmann@gmx.at> writes:

> The latter. I agree that doing this in the Debian diff is
> cleaner/preferable.

So `(load-from-path "guile.init")' (rather than "slib/guile.init") is OK
for everyone?

On Debian, this needs to be changed to
`(load "/usr/share/slib/init/guile.init")'.

Thanks,
Ludo'.



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-15  9:10             ` Ludovic Courtès
@ 2007-09-15 11:30               ` Greg Troxel
  2007-09-15 17:23                 ` Ludovic Courtès
  2007-09-16  1:41               ` Rob Browning
  1 sibling, 1 reply; 16+ messages in thread
From: Greg Troxel @ 2007-09-15 11:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

ludo@gnu.org (Ludovic Courtès) writes:

> So `(load-from-path "guile.init")' (rather than "slib/guile.init") is OK
> for everyone?

No, on pkgsrc(NetBSD), which isn't trying to change paths, you need
slib/guile.init.  Real data follows because it's too hard to say
unambigiously "the slib dir is in the default search path".

poblano gdt 36 ~ > guile
guile> %load-path
("/usr/pkg/share/guile/site" "/usr/pkg/share/guile/1.8" "/usr/pkg/share/guile")

poblano gdt 38 ~ > ls -l /usr/pkg/share/guile/site/slib
lrwxr-xr-x  1 root  wheel  19 Jul 20 13:04 /usr/pkg/share/guile/site/slib -> ../../../share/slib

poblano gdt 41 ~ > ls -l /usr/pkg/share/slib/guile.init 
-r--r--r--  1 root  wheel  19273 Jun 13 14:11 /usr/pkg/share/slib/guile.init

So it's /usr/pkg/share not /usr/share, because pkgsrc uses /usr/pkg as
PREFIX, but that's not the problem.  slib itself, unmodified, puts
guile.init in the same single directory as everything else, and that's
the debian change.

Now, I think the next issue that you are raising: guile.init vs
slib/guile.init is more subtle.  The pkgsrc way for guile/slib has been
for a very long time not to include the slib dir in %load-path.  After
(use-modules (ice-9 slib)), it still isn't in the path, and then to load
pretty-print, one uses require and not load.

So I think the slib dir should appear in %load-path, but be located in
some directory which is in %load-path

The slib instructions don't seem to address this; they tell you to run
guile with an explicit load of guile.init:

 - Implementation: Guile
     `guile -l ${SCHEME_LIBRARY_PATH}guile.init'



Finally, I think what pkgsrc has done is the guilish way to integrate
slib.  That symlink (which is the 'guile-slib' package, along with
catalog generation) places the slib code in the natural place for guile,
as if it had been a written-for-guile scheme module.

Hope this helps....


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-15 11:30               ` Greg Troxel
@ 2007-09-15 17:23                 ` Ludovic Courtès
  2007-09-16  0:36                   ` Greg Troxel
  2007-10-02  3:25                   ` Ludovic Courtès
  0 siblings, 2 replies; 16+ messages in thread
From: Ludovic Courtès @ 2007-09-15 17:23 UTC (permalink / raw)
  To: guile-devel

Hi,

Greg Troxel <gdt@ir.bbn.com> writes:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> So `(load-from-path "guile.init")' (rather than "slib/guile.init") is OK
>> for everyone?
>
> No, on pkgsrc(NetBSD), which isn't trying to change paths, you need
> slib/guile.init.

What you're saying seems to be specific to pkgsrc.

Leaving packaging systems aside, instructions in the Guile manual read
this:

  1. Unpack slib somewhere, e.g., `/usr/local/share/slib'.

  2. Create a symlink in the Guile site directory to slib, e.g.,:

          ln -s /usr/local/share/slib /usr/local/share/guile/site/slib


So `(load-from-path "slib/guile.init")' would be consistent with these
instructions.

Thanks,
Ludovic.



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-15 17:23                 ` Ludovic Courtès
@ 2007-09-16  0:36                   ` Greg Troxel
  2007-10-02  3:25                   ` Ludovic Courtès
  1 sibling, 0 replies; 16+ messages in thread
From: Greg Troxel @ 2007-09-16  0:36 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

ludo@gnu.org (Ludovic Courtès) writes:

> What you're saying seems to be specific to pkgsrc.
>
> Leaving packaging systems aside, instructions in the Guile manual read
> this:
>
>   1. Unpack slib somewhere, e.g., `/usr/local/share/slib'.
>
>   2. Create a symlink in the Guile site directory to slib, e.g.,:
>
>           ln -s /usr/local/share/slib /usr/local/share/guile/site/slib

That is exactly what pkgsrc does.

> So `(load-from-path "slib/guile.init")' would be consistent with these
> instructions.

Yes, and that works fine, which is what I meant to say.

Thanks for your guile-slib efforts.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-15  9:10             ` Ludovic Courtès
  2007-09-15 11:30               ` Greg Troxel
@ 2007-09-16  1:41               ` Rob Browning
  1 sibling, 0 replies; 16+ messages in thread
From: Rob Browning @ 2007-09-16  1:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

ludo@gnu.org (Ludovic Courtès) writes:

> Hi,
>
> Andreas Rottmann <a.rottmann@gmx.at> writes:
>
>> The latter. I agree that doing this in the Debian diff is
>> cleaner/preferable.
>
> So `(load-from-path "guile.init")' (rather than "slib/guile.init") is OK
> for everyone?

I would say something like (load-from-path "slib/guile.init"), which
is where it looks like the SLIB upstream puts the file.

For historical reasons, Debian would patch this to be (load-from-path
"slib/init/guile.init").

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-12 15:30 ` Andreas Rottmann
  2007-09-13  7:40   ` Ludovic Courtès
@ 2007-09-16  1:53   ` Rob Browning
  1 sibling, 0 replies; 16+ messages in thread
From: Rob Browning @ 2007-09-16  1:53 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: Guile Developers

Andreas Rottmann <a.rottmann@gmx.at> writes:

> I've now prepared a patch (attached) that's hopefully good enough
> for upstream use.

> +(define-module (ice-9 slib)
> +  :export (slib:load slib:load-source defmacro:load
> +	   implementation-vicinity library-vicinity home-vicinity
> +	   scheme-implementation-type scheme-implementation-version
> +	   output-port-width output-port-height array-indexes
> +	   make-random-state
> +	   -1+ <? <=? =? >? >=?
> +	   require slib:error slib:exit slib:warn slib:eval
> +	   defmacro:eval logical:logand logical:logior logical:logxor
> +	   logical:lognot logical:ash logical:logcount logical:integer-length
> +	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
> +	   slib:eval-load slib:tab slib:form-feed difftime offset-time
> +	   software-type)
> +  :replace (provide provided?)
> +  :no-backtrace)
> +
> +\f
> +(load "@SLIB_LOCATION@/init/guile.init")

In the long run, or perhaps even in the short run if Aubrey Jaffer's
interested in a patch and can make a fairly quick release, I wondered
if we might want to go even further, i.e. change it so that the *only*
thing in ice-9/slib.scm is

  (load-from-path "slib/guile.init")

I suggest this in part because I believe SLIB already has code (which
might or might not need adjustment) to handle defining the module,
making the exports, etc.  It's just conditionalized on the Guile
version.

If I recall correctly, SLIB's module related code is fairly automated
and is actually part of an implementation independent module
framework.  So the definition in ice-9/slib.scm is probably just a
duplication of effort.

Given that, it seemed like it might be better to just work with Aubrey
Jaffer to maintain all of the code in one place.

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: SLIB support
  2007-09-15 17:23                 ` Ludovic Courtès
  2007-09-16  0:36                   ` Greg Troxel
@ 2007-10-02  3:25                   ` Ludovic Courtès
  1 sibling, 0 replies; 16+ messages in thread
From: Ludovic Courtès @ 2007-10-02  3:25 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

Hello!

I committed the attached patch that appears to solve the `(ice-9 slib)'
problem.  Note that I also updated the instructions in the manual.
Feedback welcome!

Thanks,
Ludovic.


[-- Attachment #2: The patch --]
[-- Type: text/x-patch, Size: 18422 bytes --]

--- orig/ChangeLog
+++ mod/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-02  Ludovic Courtès  <ludo@gnu.org>
+
+	* NEWS: Mention `(ice-9 slib)' fix.
+
 2007-09-03  Ludovic Courtès  <ludo@gnu.org>
 
 	* NEWS: Mention alignment-related bug fixes.


--- orig/NEWS
+++ mod/NEWS
@@ -41,6 +41,7 @@
 
 * Bugs fixed
 
+** The `(ice-9 slib)' module now works as expected
 ** Expressions like "(set! 'x #t)" no longer yield a crash
 ** Warnings about duplicate bindings now go to stderr
 ** A memory leak in `make-socket-address' was fixed


--- orig/doc/ref/ChangeLog
+++ mod/doc/ref/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-02  Ludovic Courtès  <ludo@gnu.org>
+
+	* slib.texi (SLIB installation): Don't recommend using the site
+	directory for the symlink; instead, suggest either adding a
+	symlink in `/.../share/guile/1.8' (because slib will look for
+	its files in the implementation vicinity by default) or defining
+	`SCHEME_LIBRARY_PATH'.  Mention `new-catalog'.
+
 2007-08-11  Ludovic Courtès  <ludo@gnu.org>
 
 	* srfi-modules.texi (SRFI-34): New node.


--- orig/doc/ref/slib.texi
+++ mod/doc/ref/slib.texi
@@ -23,7 +23,7 @@
 @example
 (use-modules (ice-9 slib))
 (require 'primes)
-(probably-prime? 13)
+(prime? 13)
 @result{} #t
 @end example
 
@@ -31,7 +31,7 @@
 example the SLIB version of @code{delete-file} returns a boolean
 indicating success or failure, whereas the Guile core version throws
 an error for failure.  In general (and as might be expected) when SLIB
-is loaded it's the SLIB specifications which are followed.
+is loaded it's the SLIB specifications that are followed.
 
 @menu
 * SLIB installation::
@@ -41,17 +41,30 @@
 @node SLIB installation
 @subsection SLIB installation
 
-The following seems to work (e.g., with slib versions 2c7 and 2d2):
+The following procedure works, e.g., with SLIB version 3a3
+(@pxref{Installation, SLIB installation,, slib, The SLIB Portable Scheme
+Library}):
 
 @enumerate
 @item
-Unpack slib somewhere, e.g., @file{/usr/local/share/slib}.
+Unpack SLIB and install it using @code{make install} from its directory.
+By default, this will install SLIB in @file{/usr/local/lib/slib/}.
+Running @code{make installinfo} installs its documentation, by default
+under @file{/usr/local/info/}.
 
 @item
-Create a symlink in the Guile site directory to slib, e.g.,:
+Define the @code{SCHEME_LIBRARY_PATH} environment variable:
 
 @example
-ln -s /usr/local/share/slib /usr/local/share/guile/site/slib
+$ SCHEME_LIBRARY_PATH=/usr/local/lib/slib/
+$ export SCHEME_LIBRARY_PATH
+@end example
+
+Alternatively, you can create a symlink in the Guile directory to SLIB,
+e.g.:
+
+@example
+ln -s /usr/local/lib/slib /usr/local/share/guile/1.8/slib
 @end example
 
 @item
@@ -60,12 +73,12 @@
 @example
 # guile
 guile> (use-modules (ice-9 slib))
-guile> (load "/usr/local/share/slib/mklibcat.scm")
+guile> (require 'new-catalog)
 guile> (quit)
 @end example
 
 The catalog data should now be in
-@file{/usr/local/share/guile/site/slibcat}.
+@file{/usr/local/share/guile/1.8/slibcat}.
 
 If instead you get an error such as:
 
@@ -77,15 +90,6 @@
 or to modify @file{ice-9/slib.scm} to use @code{define-public} for the
 offending variables.
 
-@item
-Install the documentation:
-
-@example
-cd /usr/local/share/slib
-rm /usr/local/info/slib.info*
-cp slib.info /usr/local/info
-install-info slib.info /usr/local/info/dir
-@end example
 @end enumerate
 
 @node JACAL


--- orig/ice-9/ChangeLog
+++ mod/ice-9/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-02  Ludovic Courtès  <ludo@gnu.org>
+
+	* slib.scm: Let SLIB's `guile.init' do most of the job.  See the
+	`guile-devel@gnu.org' mailing list archive for details.
+
 2007-09-01  Andy Wingo  <wingo@pobox.com>
 
 	* boot-9.scm (duplicate-handlers)[warn, warn-override-core]:


--- orig/ice-9/slib.scm
+++ mod/ice-9/slib.scm
@@ -1,17 +1,17 @@
 ;;;; slib.scm --- definitions needed to get SLIB to work with Guile
 ;;;;
-;;;;	Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+;;;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
 ;;;; version 2.1 of the License, or (at your option) any later version.
-;;;; 
+;;;;
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ;;;; Lesser General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU Lesser General Public
 ;;;; License along with this library; if not, write to the Free Software
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -29,386 +29,14 @@
 	   logical:bit-extract logical:integer-expt logical:ipow-by-squaring
 	   slib:eval-load slib:tab slib:form-feed difftime offset-time
 	   software-type)
-  :replace (delete-file open-file provide provided? system)
   :no-backtrace)
 
 \f
+;; Initialize SLIB.
+(load-from-path "slib/guile.init")
 
-(define (eval-load <filename> evl)
-  (if (not (file-exists? <filename>))
-      (set! <filename> (string-append <filename> (scheme-file-suffix))))
-  (call-with-input-file <filename>
-    (lambda (port)
-      (let ((old-load-pathname *load-pathname*))
-	(set! *load-pathname* <filename>)
-	(do ((o (read port) (read port)))
-	    ((eof-object? o))
-	  (evl o))
-	(set! *load-pathname* old-load-pathname)))))
-
-\f
-
-(define slib:exit quit)
-(define slib:error error)
-(define slib:warn warn)
-(define slib:eval (lambda (x) (eval x slib-module)))
-(define defmacro:eval (lambda (x) (eval x (interaction-environment))))
-(define logical:logand logand)
-(define logical:logior logior)
-(define logical:logxor logxor)
-(define logical:lognot lognot)
-(define logical:ash ash)
-(define logical:logcount logcount)
-(define logical:integer-length integer-length)
-(define logical:bit-extract bit-extract)
-(define logical:integer-expt integer-expt)
-(define slib:eval-load eval-load)
-(define slib:tab #\tab)
-(define slib:form-feed #\page)
-
-(define slib-module (current-module))
-
-(define (defined? symbol)
-  (module-defined? slib-module symbol))
-
-;;; *FEATURES* should be set to a list of symbols describing features
-;;; of this implementation.  Suggestions for features are:
-(set! *features*
-  (append
-      '(
-	source				;can load scheme source files
-					;(slib:load-source "filename")
-;	compiled			;can load compiled files
-					;(slib:load-compiled "filename")
-
-		       ;; Scheme report features
-
-;	rev5-report			;conforms to
-	eval				;R5RS two-argument eval
-;	values				;R5RS multiple values
-	dynamic-wind			;R5RS dynamic-wind
-;	macro				;R5RS high level macros
-	delay				;has DELAY and FORCE
-	multiarg-apply			;APPLY can take more than 2 args.
-;	rationalize
-	rev4-optional-procedures	;LIST-TAIL, STRING->LIST,
-					;LIST->STRING, STRING-COPY,
-					;STRING-FILL!, LIST->VECTOR,
-					;VECTOR->LIST, and VECTOR-FILL!
-
-;	rev4-report			;conforms to
-
-;	ieee-p1178			;conforms to
-
-;	rev3-report			;conforms to
-
-	rev2-procedures			;SUBSTRING-MOVE-LEFT!,
-					;SUBSTRING-MOVE-RIGHT!,
-					;SUBSTRING-FILL!,
-					;STRING-NULL?, APPEND!, 1+,
-					;-1+, <?, <=?, =?, >?, >=?
-;	object-hash			;has OBJECT-HASH
-
-	multiarg/and-			;/ and - can take more than 2 args.
-	with-file			;has WITH-INPUT-FROM-FILE and
-					;WITH-OUTPUT-FROM-FILE
-;	transcript			;TRANSCRIPT-ON and TRANSCRIPT-OFF
-;	ieee-floating-point		;conforms to IEEE Standard 754-1985
-					;IEEE Standard for Binary
-					;Floating-Point Arithmetic.
-	full-continuation		;can return multiple times
-
-			;; Other common features
-
-;	srfi				;srfi-0, COND-EXPAND finds all srfi-*
-;	sicp				;runs code from Structure and
-					;Interpretation of Computer
-					;Programs by Abelson and Sussman.
-	defmacro			;has Common Lisp DEFMACRO
-;	record				;has user defined data structures
-	string-port			;has CALL-WITH-INPUT-STRING and
-					;CALL-WITH-OUTPUT-STRING
-;	sort
-;	pretty-print
-;	object->string
-;	format				;Common-lisp output formatting
-;	trace				;has macros: TRACE and UNTRACE
-;	compiler			;has (COMPILER)
-;	ed				;(ED) is editor
-
-	;; core definitions compatible, plus `make-random-state' below
-	random
-	)
-
-	(if (defined? 'getenv)
-	    '(getenv)
-	    '())
-
-	(if (defined? 'current-time)
-	    '(current-time)
-	    '())
-
-	(if (defined? 'system)
-	    '(system)
-	    '())
-
-	(if (defined? 'char-ready?)
-	    '(char-ready?)
-	    '())
-
-	*features*))
-
-;; The array module specified by slib 3a1 is not the same as what guile
-;; provides, so we must remove `array' from the features list.
-;;
-;; The main difference is `create-array' which is similar to
-;; `make-uniform-array', but the `Ac64' etc prototype procedures incorporate
-;; an initial fill element into the prototype.
-;;
-;; Believe the array-for-each module will need to be taken from slib when
-;; the array module is taken from there, since what the array module creates
-;; won't be understood by the guile functions.  So remove `array-for-each'
-;; from the features list too.
-;;
-;; Also, slib 3a1 array-for-each specifies an `array-map' which is not in
-;; guile (but could be implemented quite easily).
-;;
-;; ENHANCE-ME: It'd be nice to implement what's necessary, since the guile
-;; functions should be more efficient than the implementation in slib.
-;;
-;; FIXME: Since the *features* variable is shared by slib and the guile
-;; core, removing these feature symbols has the unhappy effect of making it
-;; look like they aren't in the core either.  Let's assume that arrays have
-;; been present unconditionally long enough that no guile-specific code will
-;; bother to test.  An alternative would be to make a new separate
-;; *features* variable which the slib stuff operated on, leaving the core
-;; mechanism alone.  That might be a good thing anyway.
-;;
-(set! *features* (delq 'array          *features*))
-(set! *features* (delq 'array-for-each *features*))
-
-;; The random module in slib 3a1 provides a `random:chunk' which is used by
-;; the random-inexact module.  Guile doesn't provide random:chunk so we must
-;; remove 'random from `*features*' to use the slib code.
-;;
-;; ENHANCE-ME: Maybe Guile could provide a `random:chunk', the rest of the
-;; random module is already the same as Guile.
-;;
-;; FIXME: As per the array bits above, *features* is shared by slib and the
-;; guile core, so removing 'random has the unhappy effect of making it look
-;; like this isn't in the core.  Let's assume random numbers have been
-;; present unconditionally long enough that no guile-specific code will
-;; bother to test.
-;;
-(set! *features* (delq 'random *features*))
-
-
-;;; FIXME: Because uers want require to search the path, this uses
-;;; load-from-path, which probably isn't a hot idea.  slib
-;;; doesn't expect this function to search a path, so I expect to get
-;;; bug reports at some point complaining that the wrong file gets
-;;; loaded when something accidentally appears in the path before
-;;; slib, etc. ad nauseum.  However, the right fix seems to involve
-;;; changing catalog:get in slib/require.scm, and I don't expect
-;;; Aubrey will integrate such a change.  So I'm just going to punt
-;;; for the time being.
-(define (slib:load name)
-  (save-module-excursion
-   (lambda ()
-     (set-current-module slib-module)
-     (let ((errinfo (catch 'system-error
-			   (lambda ()
-			     (load-from-path name)
-			     #f)
-			   (lambda args args))))
-       (if (and errinfo
-		(catch 'system-error
-		       (lambda ()
-			 (load-from-path
-			  (string-append name ".scm"))
-			 #f)
-		       (lambda args args)))
-	   (apply throw errinfo))))))
-
-(define slib:load-source slib:load)
-(define defmacro:load slib:load)
-
-(define slib-parent-dir
-  (let* ((path (%search-load-path "slib/require.scm")))
-    (if path
-	(substring path 0 (- (string-length path) 17))
-	(error "Could not find slib/require.scm in " %load-path))))
-
-(define (implementation-vicinity)
-  (string-append slib-parent-dir "/"))
-(define (library-vicinity)
-  (string-append (implementation-vicinity) "slib/"))
-(define home-vicinity
-  (let ((home-path (getenv "HOME")))
-    (lambda () home-path)))
-(define (scheme-implementation-type) 'guile)
-(define scheme-implementation-version version)
-;;; (scheme-implementation-home-page) should return a (string) URI
-;;; (Uniform Resource Identifier) for this scheme implementation's home
-;;; page; or false if there isn't one.
-(define (scheme-implementation-home-page)
-  "http://www.gnu.org/software/guile/guile.html")
-
-;; legacy from r3rs, but slib says all implementations provide these
-;; ("Legacy" section of the "Miscellany" node in the manual)
-(define-public t   #t)
-(define-public nil #f)
-
-;; ENHANCE-ME: Could call ioctl TIOCGWINSZ to get the size of a tty (see
-;; "man 4 tty_ioctl" on a GNU/Linux system), on systems with that.
-(define (output-port-width . arg) 80)
-(define (output-port-height . arg) 24)
-
-;; slib 3a1 and up, straight from Template.scm
-(define-public (call-with-open-ports . ports)
-  (define proc (car ports))
-  (cond ((procedure? proc) (set! ports (cdr ports)))
-	(else (set! ports (reverse ports))
-	      (set! proc (car ports))
-	      (set! ports (reverse (cdr ports)))))
-  (let ((ans (apply proc ports)))
-    (for-each close-port ports)
-    ans))
-
-;; slib (version 3a1) requires open-file accept a symbol r, rb, w or wb for
-;; MODES, so extend the guile core open-file accordingly.
-;;
-;; slib (version 3a1) also calls open-file with strings "rb" or "wb", not
-;; sure if that's intentional, but in any case this extension continues to
-;; accept strings to make that work.
-;;
-(define-public (open-file filename modes)
-  (if (symbol? modes)
-      (set! modes (symbol->string modes)))
-  ((@ (guile) open-file) filename modes))
-
-;; returning #t/#f instead of throwing an error for failure
-(define-public (delete-file filename)
-  (catch 'system-error
-    (lambda () ((@ (guile) delete-file) filename) #t)
-    (lambda args #f)))
-
-;; Nothing special to do for this, so straight from Template.scm.  Maybe
-;; "sensible-browser" for a debian system would be worth trying too (and
-;; would be good on a tty).
-(define-public (browse-url url)
-  (define (try cmd end) (zero? (system (string-append cmd url end))))
-  (or (try "netscape-remote -remote 'openURL(" ")'")
-      (try "netscape -remote 'openURL(" ")'")
-      (try "netscape '" "'&")
-      (try "netscape '" "'")))
-
-;;; {array-for-each}
-(define (array-indexes ra)
-  (let ((ra0 (apply make-array '() (array-shape ra))))
-    (array-index-map! ra0 list)
-    ra0))
-
-;;; {Random numbers}
-;;;
-(define (make-random-state . args)
-  (let ((seed (if (null? args) *random-state* (car args))))
-    (cond ((string? seed))
-	  ((number? seed) (set! seed (number->string seed)))
-	  (else (let ()
-		  (require 'object->string)
-		  (set! seed (object->limited-string seed 50)))))
-    (seed->random-state seed)))
-
-;;; {rev2-procedures}
-;;;
-
-(define -1+ 1-)
-(define <?  <)
-(define <=? <=)
-(define =?  =)
-(define >?  >)
-(define >=? >=)
-
-;;; {system}
-;;;
-;; If the program run is killed by a signal, the shell normally gives an
-;; exit code of 128+signum.  If the shell itself is killed by a signal then
-;; we do the same 128+signum here.
-;;
-;; "stop-sig" shouldn't arise here, since system shouldn't be calling
-;; waitpid with WUNTRACED, but allow for it anyway, just in case.
-;;
-(if (memq 'system *features*)
-    (define-public system
-      (lambda (str)
-	(let ((st ((@ (guile) system) str)))
-	  (or (status:exit-val st)
-	      (+ 128 (or (status:term-sig st)
-			 (status:stop-sig st))))))))
-
-;;; {Time}
-;;;
-
-(define difftime -)
-(define offset-time +)
-
-\f
-(define define
-  (procedure->memoizing-macro
-   (lambda (exp env)
-     (if (= (length env) 1)
-	 `(define-public ,@(cdr exp))
-	 `(define-private ,@(cdr exp))))))
-
-;;; Hack to make syncase macros work in the slib module
-(if (nested-ref the-root-module '(app modules ice-9 syncase))
-    (set-object-property! (module-local-variable (current-module) 'define)
-			  '*sc-expander*
-			  '(define)))
-
-(define (software-type)
-  "Return a symbol describing the current platform's operating system.
-This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2,
-THINKC, AMIGA, ATARIST, MACH, or ACORN.
-
-Note that most varieties of Unix are considered to be simply \"UNIX\".
-That is because when a program depends on features that are not present
-on every operating system, it is usually better to test for the presence
-or absence of that specific feature.  The return value of
-@code{software-type} should only be used for this purpose when there is
-no other easy or unambiguous way of detecting such features."
- 'UNIX)
-
-(slib:load (in-vicinity (library-vicinity) "require.scm"))
-
-(define require require:require)
-
-;; {Extensions to the require system so that the user can add new
-;;  require modules easily.}
-
-(define *vicinity-table*
-  (list
-   (cons 'implementation (implementation-vicinity))
-   (cons 'library (library-vicinity))))
-
-(define (install-require-vicinity name vicinity)
-  (let ((entry (assq name *vicinity-table*)))
-    (if entry
-	(set-cdr! entry vicinity)
-	(set! *vicinity-table*
-	      (acons name vicinity *vicinity-table*)))))
-
-(define (install-require-module name vicinity-name file-name)
-  (if (not *catalog*)	     ;Fix which loads catalog in slib
-      (catalog:get 'random)) ;(doesn't load the feature 'random)
-  (let ((entry (assq name *catalog*))
-	(vicinity (cdr (assq vicinity-name *vicinity-table*))))
-    (let ((path-name (in-vicinity vicinity file-name)))
-      (if entry
-	  (set-cdr! entry path-name)
-	  (set! *catalog*
-		(acons name path-name *catalog*))))))
-
-(define (make-exchanger obj)
-  (lambda (rep) (let ((old obj)) (set! obj rep) old)))
+;; SLIB redefines a few core symbols based on their default definition.
+;; Thus, we only replace them at this point so that their previous definition
+;; is visible when `guile.init' is loaded.
+(module-replace! (current-module)
+                 '(delete-file open-file provide provided? system))




[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-10-02  3:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-11 17:49 SLIB support Andreas Rottmann
2007-09-12 15:29 ` Andreas Rottmann
2007-09-12 15:30 ` Andreas Rottmann
2007-09-13  7:40   ` Ludovic Courtès
2007-09-13 13:14     ` Andreas Rottmann
2007-09-13 14:15       ` Greg Troxel
2007-09-13 14:35         ` Andreas Rottmann
2007-09-13 15:39         ` Rob Browning
2007-09-13 15:56           ` Andreas Rottmann
2007-09-15  9:10             ` Ludovic Courtès
2007-09-15 11:30               ` Greg Troxel
2007-09-15 17:23                 ` Ludovic Courtès
2007-09-16  0:36                   ` Greg Troxel
2007-10-02  3:25                   ` Ludovic Courtès
2007-09-16  1:41               ` Rob Browning
2007-09-16  1:53   ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).