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

Are arrow macros valid places? #4

Open
phoe opened this issue Nov 20, 2020 · 4 comments
Open

Are arrow macros valid places? #4

phoe opened this issue Nov 20, 2020 · 4 comments

Comments

@phoe
Copy link

phoe commented Nov 20, 2020

There is a question whether a call to e.g. -> or -<> is a valid place and therefore passable to setf.

What do you think about this? It should be possible to define proper setf expanders for those in order to deal with the fact that the PR from #3 turns them into let* forms which are not valid places.

@phoe phoe mentioned this issue Nov 20, 2020
3 tasks
@phoe
Copy link
Author

phoe commented Nov 20, 2020

The current implementation of arrows already makes it possible to use arrow forms as places with the exception of diamond macros with multiple diamonds (which is an extension, anyway). It might be possible to get this last one to work using a custom setf expansion; hence I'll keep this issue open.

@Harleqin
Copy link
Owner

I must admit that I never thought about this. I struggle a bit with coming up with use cases in the cases where the expansion has let bindings and/or conditionals, though.

@phoe
Copy link
Author

phoe commented Nov 21, 2020

Conditionals make it possible to set different places. As for named bindings, likely the same use cases as non-setf cases apply.

@phoe
Copy link
Author

phoe commented Nov 21, 2020

Example for conditionals:

BINDING-ARROWS> (let ((cons (cons (cons 1 2) 3)))
                  (setf (cond-> cons
                          (t car)
                          (t cdr))
                        42)
                  cons)
((1 . 42) . 3)

BINDING-ARROWS> (let ((cons (cons (cons 1 2) 3)))
                  (setf (cond-> cons
                          (nil car)
                          (t cdr))
                        42)
                  cons)
((1 . 2) . 42)

BINDING-ARROWS> (let ((cons (cons (cons 1 2) 3)))
                  (setf (cond-> cons
                          (t car)
                          (nil cdr))
                        42)
                  cons)
(42 . 3)

BINDING-ARROWS> (let ((cons (cons (cons 1 2) 3)))
                  (setf (cond-> cons
                          (nil car)
                          (nil cdr))
                        42)
                  cons)
42

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