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

Expand required macros in macroexpand-all #1664

Merged
merged 3 commits into from
Aug 3, 2018

Conversation

brandonwillard
Copy link
Member

Minor change that allows macroexpand-all to expand required macros.

See this discussion for some context.

@brandonwillard brandonwillard changed the title Require in macroexpand-all Expand required macros in macroexpand-all Jul 25, 2018
@Kodiologist
Copy link
Member

  1. Spin out the unrelated style edits to walk.hy into their own commit.
  2. Put the test macro into one of the existing files in tests/resources instead of its own file.
  3. I think the test is too brittle because it depends on require expanding to None. Instead, try something like (assert (= (last (macroexpand-all '(require-macro))) '(setv blah 1))).
  4. Update NEWS and AUTHORS.

Otherwise, this looks good.

@brandonwillard
Copy link
Member Author

Ha, yeah, I forgot about those docstring edits; I'll just retract them.

@brandonwillard
Copy link
Member Author

Also, I wasn't sure whether or not it was desirable to have a require expand to None. It doesn't seem to hurt anything, but does produces a rather redundant expression (e.g. an unnecessary (do None ...)).

We could easily filter-out those Nones, but that would introduce topics like expression simplification/normalization, canonical forms, etc., and none of that was going on in the module already.

@Kodiologist
Copy link
Member

Right. Don't attempt to remove it for now.

@brandonwillard brandonwillard force-pushed the require-in-macroexpand-all branch from 285dde1 to 0ed3d5e Compare July 25, 2018 22:17
This change enables further macro expansion for cases in which a macro
`require`s other macros within its body.
@brandonwillard brandonwillard force-pushed the require-in-macroexpand-all branch from 0ed3d5e to a46cc39 Compare July 25, 2018 22:23
@brandonwillard
Copy link
Member Author

Also, before I forget, that require in walk isn't side effect-free, in that it adds the required macros to the calling module, which seems less than ideal.

I considered creating a temporary shallow copy of the calling module (or at least the hy.macros._hy_macros dicts) for a side-effect free version, but didn't because it appeared to relate to @gilch's comments on namespace enhancements and possibly other fundamental changes that would facilitate such an implementation.

Copy link
Member

@Kodiologist Kodiologist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to the Hyve!

@brandonwillard
Copy link
Member Author

brandonwillard commented Jul 27, 2018

Thanks; I look forward to helping everyone get Hy! (My apologies, in advance)

@gilch gilch merged commit 109c0b0 into hylang:master Aug 3, 2018
@brandonwillard brandonwillard deleted the require-in-macroexpand-all branch August 4, 2018 23:15
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.

3 participants