-
Notifications
You must be signed in to change notification settings - Fork 1
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
Expressions not valid in hash-set creation #2
Comments
While #{...} can handle non-immediate-value expressions, hash set does handle lists in an unexpected manner. CL-USER> (let ((reader:*set-function* 'hash-set:list-to-hs)) ; hash-set:list-to-hs converts lists to hash-sets
(hash-set:dohashset (x (eval (read-from-string "#{(list 1 2)}")))
(princ x)))
#<HASH-SET of count: 2 {1042E1B5C3}>
NIL
CL-USER> (let ((reader:*set-function* 'hash-set:list-to-hs)) ; #{...} can handle non-immediate values
(hash-set:dohashset (x (eval (read-from-string "#{(+ 2 3)}")))
(princ x)))
5
NIL One could write their own function that behaves as expected: CL-USER> (defun our-list-to-hash-set (list &key test)
(declare (ignore test))
(let ((hs (hash-set:make-hash-set)))
(loop :for item :in list
:do (hash-set:hs-ninsert hs item))
hs))
OUR-LIST-TO-HASH-SET
CL-USER> (let ((reader:*set-function* 'our-list-to-hash-set))
(hash-set:dohashset (x (eval (read-from-string "#{(list 1 2)}")))
(princ x)))
(1 2)
NIL |
With the latest commit removing the hash-set dependency, I suppose this issue is now obsolete. That said, before closing it, since you already went through the work of writing a version that works. I'm wondering if it makes sense to you to add a contrib/ directory, with a system for hash-set, that you include/use when you want to use hash-set with this library. Then pull requests could be made similarly for adding systems for fset and whatever other data structure libraries the user cares for. |
Looks like #{...} can often only accept immediate values. For example:
The text was updated successfully, but these errors were encountered: