[Ecls-list] About name collisions

Juan Jose Garcia-Ripoll jjgarcia at users.sourceforge.net
Fri Feb 1 11:20:56 UTC 2008


The current naming algorithm is shown below. It is currently being tested.

Libraries built on the same system should never collide and libraries
built on different systems will also not collide if built on
sufficiently different dates or files have sufficiently different
pathnames. Since name collisions typically happen when building a
single FASL file out of some lisp library, and this is typically done
by the same machine, this seems to be enough. However, once we get a
more or less portable way to get the hostname or some identifier for
the machine, its hash key can be included in the function name.

(defun encode-number-in-name (number)
  (declare (si::c-local))
  (cond ((zerop number) "0")
	((minusp number) (encode-number-in-name (- number)))
	(t
	 (do* ((code "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
	       (base (length code))
	       (output '())
	       (digit 0))
	      ((zerop number) (concatenate 'string (nreverse output)))
	   (multiple-value-setq (number digit) (floor number base))
	   (push (char code digit) output)))))

(defun unique-init-name (pathname)
  (let ((tag (concatenate 'base-string
			  "_ecl"
			  (encode-number-in-name (sxhash pathname))
			  "_"
			  (encode-number-in-name (get-universal-time)))))
    (cmpnote "Creating tag: ~S" tag)
    tag))

-- 
Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list