Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sexp.lisp: Option to omit a specific package prefix #6

Open
Ambrevar opened this issue Sep 30, 2019 · 4 comments
Open

sexp.lisp: Option to omit a specific package prefix #6

Ambrevar opened this issue Sep 30, 2019 · 4 comments

Comments

@Ambrevar
Copy link
Contributor

The symbol package prefix can get really verbose at times, it'd be nice to have an option to omit it.

For instance

(export '*local*)
(defvar *local-package* nil
  "If `*local-package*' designates a package instance, don't print the package
  prefix of its symbols.")

(defun print-symbol (symbol stream)
  (let ((package (symbol-package symbol))
	(name (prin1-to-string symbol)))
    (cond ((eq package +cl-package+) (write-string "CL:" stream))
	  ((eq package +keyword-package+) (write-char #\: stream))
          ((eq package *local-package*)
           ;; Don't print the package prefix.
           nil)
	  (package (s-xml:print-string-xml (package-name package) stream)
                   (write-string "::" stream))
          (t (write-string "#:" stream)))
    (if (char= (char name (1- (length name))) #\|)
        (write-string name stream :start (position #\| name))
      (write-string name stream :start (1+ (or (position #\: name :from-end t) -1))))))
@svetlyak40wt
Copy link
Member

Package prefix needed to deserialize the symbol propertly.

@Ambrevar
Copy link
Contributor Author

Ambrevar commented Sep 30, 2019 via email

@svetlyak40wt
Copy link
Member

It is hard to predict which package will be current when you'll restore the data. Prevalence's format is not designed to be readable by humans.

@Ambrevar
Copy link
Contributor Author

Ambrevar commented Sep 30, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants