You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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...
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.
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
tobody
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 aWalker
). If thetree
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?
The text was updated successfully, but these errors were encountered: