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

Sequence-reference variables with &map can't be recursive #184

Open
okamsn opened this issue Feb 11, 2024 · 1 comment
Open

Sequence-reference variables with &map can't be recursive #184

okamsn opened this issue Feb 11, 2024 · 1 comment
Labels
bug Something isn't working upstream Applies to a dependecy

Comments

@okamsn
Copy link
Owner

okamsn commented Feb 11, 2024

This a problem with the upstream implementation of the setf support for
map-elt. It currently passes through the map value instead of treating it
like a reference.

For example,

(let ((arr (vector 0 1 2 3 4 5 6)))
  (setf (map-elt (cl-subseq arr 3) 0)
        27)
  arr)

expands to

(let ((arr (vector 0 1 2 3 4 5 6)))
  (let* ((v arr))
    (condition-case nil
        (with-no-warnings
          (map-put! (cl-subseq v 3) 0 27 nil))
      (map-not-inplace
       (let* ((new (map-insert (cl-subseq v 3) 0 27)))
         (progn
           (cl-replace v new :start1 3 :end1 nil)
           new))
       27)))
  arr)

See how map-put! is being used instead of expanding into something more.

@okamsn okamsn added bug Something isn't working upstream Applies to a dependecy labels Feb 11, 2024
@okamsn
Copy link
Owner Author

okamsn commented Feb 11, 2024

This might also be a problem with cl-subseq, or some interaction of multiple
things.

elt also has this problem

;; = > [0 1 2 3 4 5 6]
(let ((arr (vector 0 1 2 3 4 5 6)))
  (setf (elt (cl-subseq arr 3) 0)
        27)
  arr)

but using the hash-table functions does not

;; => [27 1 2]
(let ((map (make-hash-table)))
  (puthash 3 (vector 0 1 2) map)
  (setf (elt (gethash 3 map) 0) 27)
  (gethash 3 map))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Applies to a dependecy
Projects
None yet
Development

No branches or pull requests

1 participant