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

Add/Extend Macro Documentation #453

Closed
scolsen opened this issue May 20, 2019 · 3 comments
Closed

Add/Extend Macro Documentation #453

scolsen opened this issue May 20, 2019 · 3 comments
Assignees

Comments

@scolsen
Copy link
Contributor

scolsen commented May 20, 2019

I think it'd be worthwhile to have a doc page dedicated to writing macros in Carp--there are some restrictions when it comes to writing macros that may not be immediately obvious to new users:

  • If one wants to recur in a macro, one needs(Or so it seems? I might be wrong about this.) to define a dynamic function using defndynamic -- macros themselves cannot recur.
  • Not all special forms are supported in macros--this is mentioned in passing in the Language Guide, but it'd be nice to have a definitive list. For example the is not supported (afaik).
  • Macros can't be called in macros (at least that's my observation from my scant experience defining them when I tried using e.g. case in the definition of another macro, it resulted in unexpected unable to find symbol errors on the argument passed to case. Then again, I may have made a tangential error that caused this and the actual use may not be problematic.
  • expand is a super useful function to be aware of when writing macros, but you have to do some digging to find out it exists. (as it turns out, it's documented in the docs for Dynamic. I wound up finding it through a search in the source. So this is a lesser point--but I do think giving it a bit more exposure would be a benefit).

Since my observations are highly anecdotal, there may be some other explanations for the restrictions/behaviors I'm citing here, but I think a dedicated doc would help clarify macro definition and usage!

I'm happy to work on this, but I will probably need to call in reinforcements for elaboration on some points and a healthy dose of peer-editing.

Here are the existing available macro docs (that I'm aware of):

I think pooling together some of the knowledge in each of these resources into a general Macros reference doc is a good first step.

@eriksvedang
Copy link
Collaborator

I hadn't really thought about this at all, but you're absolutely right – of course we need such a document!

While I hope that some of these idiosyncrasies you mention will be removed in the future, many things will of course stay the same and until they are fixed it's very good to have some docs on it, for sure.

All in all – feel free to open a PR with a draft of this document and I'll make sure to chime in!

@hellerve
Copy link
Member

I’m more than happy to help as well. Sadly blog posts are prone to aging and they get outdated fairly quickly, so an up-to-date-by-default document would be great!

@eriksvedang
Copy link
Collaborator

This document exists now!

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

3 participants