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

[suggestion] terminology in macro argument naming #9

Open
Technologicat opened this issue Oct 2, 2018 · 3 comments
Open

[suggestion] terminology in macro argument naming #9

Technologicat opened this issue Oct 2, 2018 · 3 comments

Comments

@Technologicat
Copy link

Block macros name their argument tree, although technically what gets passed in is a forest (as a list of trees). It would be more descriptive, if the argument name somehow indicated this.

As pointed out by @azazel75 in private communication, AST objects that accept a sequence of statements usually call it body; so we could use that name here, too.

From my own experience, the same convention applies in Racket - which is for the most part very pedantic about terminology - so body is likely the "correct" name as far as there is one.

So, in block macros, changing the argument name from tree to body would make the resulting code more self-explanatory. This applies only to block macros. Expr macros take one expression, and decorator macros take one function or class definition; these are trees.

On the other hand, the current single name has the advantage that it's the same for all three kinds of macros.

Another viewpoint is, on some occasions, it would be useful to name the argument subtree or something else (e.g. in an inner definition for a Walker). If the tree argument was passed positionally instead of by name, each call site could use the locally most appropriate name. But then there is no guarantee on any consistency in naming.

Thoughts?

@Technologicat
Copy link
Author

Noticed also that the documentation section on expansion order talks about trees in the context of block macros.

@catb0t
Copy link

catb0t commented Oct 3, 2018

List<tree> tree is unfortunate but i guess it is technically a tree of trees

why confuse "sequence of AST statements" with "forest" if they aren't the same? a list of trees being called "forest" is ~ •quirky• ~ and funny but not unordered as a forest would imply...

perhaps just trees then?

@Technologicat
Copy link
Author

I meant "forest" in the CS sense of a graph where each connected component is a tree... but you're right, that's isomorphic to an unordered set, not an ordered list, of trees.

I'd be fine with either body or trees.

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