This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: '#/some/list' `read' different?


> Date: Thu, 2 Jul 1998 20:06:00 -0400
> From: Keith Wright <kwright@tiac.net>
> 
> To fix the bug at the source, patch the place you learned
> this syntax with a comment that says don't do it.
> The only reason to do this is to make things look like
> file paths.

looks like 1.3a docs do mention deprecation of #/ list notation.  at
the end of this post are two (incompatible) patches to 19980705
ice-9/boot-9.scm.  the first just puts warning comments near where #/
is handled.  the second deletes.

for me, under /usr/local/share/guile, there are 82 instances where
`#/some/list' needed to be changed to `(some list)'.  i used:

 $ find . -name '*.scm' -print | xargs grep -l '#/' > all-files

here is some elisp that helps to make the conversion; save it as
"convert-pound-slash-to-list.el".  invoke like:

 $ emacs -batch -l convert-pound-slash-to-list.el `cat all-files`

;; convert-pound-slash-to-list.el, created 19980507, author <ttn@netcom.com>
(mapcar
 #'(lambda (file)
     (set-buffer (find-file file))
     (widen)
     (let* ((fullname    (buffer-file-name (current-buffer)))
	    (handle-vc-p (vc-registered fullname)))
       (and handle-vc-p (vc-checkout fullname t))
       (goto-char (point-min))
       (while (re-search-forward "#/[^ \t\n)]+" (point-max) t)
	 (let ((beg (match-beginning 0))
	       (end (match-end 0)))
	   (goto-char beg)
	   (while (search-forward "/" end t)
	     (delete-char -1) (insert " "))
	   (goto-char beg) (delete-char 2) (insert "(")
	   (goto-char (1- end)) (insert ")")))
       (and handle-vc-p (vc-checkin fullname nil
				    "Converted pound-slash list notation.")))
     (save-buffer)
     (kill-buffer (current-buffer)))
 (let ((all-files command-line-args))
   (while (not (string-match "convert-pound-slash-to-list.el" (car all-files)))
     (setq all-files (cdr all-files)))
   (setq all-files (cdr all-files))))

the elisp was tested on my system's installed files.  i don't have
version control for installed files, so you may have to debug that
part.

thi

-----
this is file boot-9.scm.warning.patch:

997a998,999
> ;;; !!! Warning: The #/ list notation is deprecated.
> ;;; !!! This procedure will go away.
1046a1049,1050
> ;; !!! Warning: The #/ list notation is deprecated.
> ;; !!! This reader extension will go away.


------
this is the file boot-9.scm.deleted.patch

997,1024d996
< ;;; Parse the portion of a #/ list that comes after the first slash.
< (define (read-path-list-notation slash port)
<   (letrec 
<       
<       ;; Is C a delimiter?
<       ((delimiter? (lambda (c) (or (eof-object? c)
< 				   (char-whitespace? c)
< 				   (string-index "()\";" c))))
< 
<        ;; Read and return one component of a path list.
<        (read-component
< 	(lambda ()
< 	  (let loop ((reversed-chars '()))
< 	    (let ((c (peek-char port)))
< 	      (if (or (delimiter? c)
< 		      (char=? c #\/))
< 		  (string->symbol (list->string (reverse reversed-chars)))
< 		  (loop (cons (read-char port) reversed-chars))))))))
< 
<     ;; Read and return a path list.
<     (let loop ((reversed-path (list (read-component))))
<       (let ((c (peek-char port)))
< 	(if (and (char? c) (char=? c #\/))
< 	    (begin
< 	      (read-char port)
< 	      (loop (cons (read-component) reversed-path)))
< 	    (reverse reversed-path))))))
< 
1044,1047d1015
< 
< ;; pushed to the beginning of the alist since it's used more than the
< ;; others at present.
< (read-hash-extend #\/ read-path-list-notation)

-----
end of patches