Skip to content

fixed issue with variadic ampersand symbol in macros #773

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

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

ikappaki
Copy link
Contributor

@ikappaki ikappaki commented Jan 1, 2024

HI,

could you please review patch to treat the ampersand operator in macros as a standalone symbol. Fixes #772.

Test included.

thanks

@chrisrink10
Copy link
Member

I acknowledge that this seems like a Basilisp bug, but this fix is concerning to me. It feels like it's in far too general of a placement to fix the bug it's fixing.

While I contemplate this patch, I believe you can do this to get around the issue:

(defmacro ^:private variadic-fn []
  `(fn [~'& r#] r#))

@ikappaki ikappaki force-pushed the issue/macro-ampersand branch from dcc36a7 to 5f42084 Compare January 2, 2024 18:50
@ikappaki
Copy link
Contributor Author

ikappaki commented Jan 2, 2024

I acknowledge that this seems like a Basilisp bug, but this fix is concerning to me. It feels like it's in far too general of a placement to fix the bug it's fixing.

While I contemplate this patch, I believe you can do this to get around the issue:

(defmacro ^:private variadic-fn []
  `(fn [~'& r#] r#))

Hi, I understand from the above that you do acknowledge the incompatibility with Clojure, and, maybe, that the current behavior is somehow confusing (very confusing to me in the case of defining macros that define fns).

I had a closer looks and a found a more targeted place to apply the patch with the latest commit, in the syntax quote logic.

This brings it closer to the Clojure behaviour (which covers the macro case), with one exception that explicitly namespace qualified ampersand is also treated as a quoted ampersand

basilisp

basilisp.user=> `&
&

basilisp.user=> `a
basilisp.user/a

basilisp.user=> `user/&
&

clojure

user> `&
&
user> `a
user/a
user> `user/&
user/&

It is not obvious to me how can I treat this case in the syntax-quote code, since the namespace is added by the reader if missing, and there is no indication whether it was specified by the user or the reader.

what do you think?

Thanks

@ikappaki ikappaki force-pushed the issue/macro-ampersand branch from 5f42084 to c9acc1f Compare January 2, 2024 19:07
@chrisrink10
Copy link
Member

I think your previous fix is probably fine after reviewing it again. I can see the problem with the latest patch and I don't see any easy way around it.

@ikappaki ikappaki force-pushed the issue/macro-ampersand branch from c9acc1f to 2bf22e2 Compare January 2, 2024 23:10
@ikappaki
Copy link
Contributor Author

ikappaki commented Jan 2, 2024

I think your previous fix is probably fine after reviewing it again. I can see the problem with the latest patch and I don't see any easy way around it.

I've reverted to the previous patch with some minor optimisation while adding the `xxx/& test case.

@chrisrink10 chrisrink10 merged commit cb16d60 into basilisp-lang:main Jan 3, 2024
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.

issue with variadic ampersand symbol in macros
2 participants