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
This is an identity macro interpolation; the resulting Crystal code parses to the same object as node. Having those identities in the documentation is handy when writing macros that transform nodes, such as adding parameters to a Def or a Call's block. They are also a motivation behind #3274, in that every composite AST node should be expressible as an interpolation using its components. We should document those identities for all the other Crystal::Macros types.
There is in fact a long form of the above identity, which further decomposes node.name but without going through that temporary node:
{%begin%}
{% type_vars = node.type_vars %}
{{ node.kind }} {{ node.name(generic_args:false) }}{%unless type_vars.empty? %}(
{%for var, i in type_vars %}
{%if i == node.splat_index %}*{%end%}{{ var }},
{%end%}
){%end%}
{{ node.body }}
end
{%end%}
When an AST node has both a full decomposition like above, and a convenience identity interpolation (e.g. Def after #13082), we should probably document both forms.
The text was updated successfully, but these errors were encountered:
#14063 added the following documentation to
Crystal::Macros::ModuleDef
:This is an identity macro interpolation; the resulting Crystal code parses to the same object as
node
. Having those identities in the documentation is handy when writing macros that transform nodes, such as adding parameters to aDef
or aCall
's block. They are also a motivation behind #3274, in that every composite AST node should be expressible as an interpolation using its components. We should document those identities for all the otherCrystal::Macros
types.There is in fact a long form of the above identity, which further decomposes
node.name
but without going through that temporary node:When an AST node has both a full decomposition like above, and a convenience identity interpolation (e.g.
Def
after #13082), we should probably document both forms.The text was updated successfully, but these errors were encountered: