-
Notifications
You must be signed in to change notification settings - Fork 10
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
how to hit index for packages? #3
Comments
This is due more to package-name not actually being a symbol: > (package-name (find-package 'cl-user))
"COMMON-LISP-USER"
> But strings (or packages) aren't indexed; only symbols. There are probably a few ways to handle what you want to do. Adding strings to indexes is probably not the best idea, since it'd be ambiguous about how to handle equality, decoding, etc. First, note that conspack isn't a format, but an encoding: you don't necessarily have to have a 1:1 correspondence between CL types and your format. So you could:
The first option is a quick and easy solution; if you don't need packages, you don't save anything by sending encoded symbols. If you can't always predict your package, then you need to communicate the package somehow anyway, so even a predefined index of packages doesn't really solve the problem. With the second option, you could actually provide a query protocol that would send an enumeration of symbols you could then use as an index. This could be as dynamic as you want, e.g. sending a protocol version in each message, and replying with protocol-is-outdated message should something change etc etc. If you're going to send tons of otherwise-small messages, this is possibly ideal for minimizing size. A few small messages or very large messages, and the package name is probably not going to make much difference. The final option is the simplest and most dynamic, of course. |
Thanks for quick and thorough reply. As I wrote, it's for RPC so all used packages can be predicted in advance. I came up with this patch which seems to work fine - if symbol has a package, its name is interned as a keyword and put into the index as such. I can then use (cpk:with-index (:common-lisp-user) ...) No change is needed at decoder. If it is acceptable (or as an option) will make pull request.
|
Sorry for the late response, this is probably fine, I'll change this along with amending SPEC to make package take a string designator for package, much like CL itself. Most package names end up interned as keywords at some point anyway, I think. I suppose one could check to see if it's already interned, though. |
Hello, it appears encoder does try to look up the package in the index, but I cannot get it to work. I intend to use cl-conspack for RPC and it would be nice if package is not transmitted all the time with the symbols. Perhaps passing package object instead of its name in #'encode-symbol might be a bug.
The text was updated successfully, but these errors were encountered: