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

[RFC] Extend and export CCL::CONDITIONAL-STORE #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eugeneia
Copy link
Contributor

@eugeneia eugeneia commented Jun 27, 2017

I made use of this hidden gem to implement CAS based queues for Erlangen (Erlangen extends CCL a bit to support this code). It has some rough edges, but I feel like a polished conditional-store would make a fine addition to the CCL API. What do you think?

So far I have

  • added some code to deal with type annotated structure slots (i.e. conditional-store on a slot with a type specified would fail, because it could not handle the emitted the forms)
  • added clauses for car and cdr places that call out to ccl::%rplaca-conditional and ccl::%rplacd-conditional respectively
  • added conditional-store to the list of symbols exported from the CCL package and wrote some documentation for conditional-store

Some issues remain:

  • it does not work with with-slots due to the type uncertainty at run-time. (i.e. we know the slot name, but not the type of the structure object
  • it does not work on array references (could be low hanging fruit?)

I don’t fully understand why/how this macro works on the types of places it does, and not on others. This is mainly due to my lack of understanding how slot accesses are implemented. Any hints to what I have to watch out for when dealing with places is appreciated. For instance this is the first time I have used &environment, and suddenly there are so many questions. Like, who deals with (the ...) forms, what do I break when I mess with these during macro expansion?

Example usage:

? (defstruct foo (x 0) (y 1 :type fixnum))
FOO
? (let ((c (cons :a :b))
        (f (make-foo)))
   (ccl:conditional-store (car c) :a :c)
   (ccl:conditional-store (cdr c) :b :d)
   (ccl:conditional-store (foo-x f) 0 2)
   (ccl:conditional-store (foo-y f) 1 3)
   (values c f))
(:C . :D)
#S(FOO :X 2 :Y 3)

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

Successfully merging this pull request may close these issues.

None yet

1 participant