-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This is the code we have to write in transformer to generate let Foo;:
let kind = VariableDeclarationKind::Let;
let declarations = {
let ident = BindingIdentifier::new(SPAN, name.clone());
let pattern_kind = self.ctx.ast.binding_pattern_identifier(ident);
let binding = self.ctx.ast.binding_pattern(pattern_kind, None, false);
let decl = self.ctx.ast.variable_declarator(SPAN, kind, binding, None, false);
self.ctx.ast.new_vec_single(decl)
};
Declaration::VariableDeclaration(self.ctx.ast.variable_declaration(
SPAN,
kind,
declarations,
Modifiers::empty(),
))Seems a bit bananas! Very long to write, and non-trivial to understand at first glance what the code is doing.
Surely we can find some way to reduce this.
Like: ast!{ let #name; }
The obvious problem is compile time impact of macros. Can we find some way to precompile macro expansion so we can enjoy a simpler code style without paying the compile-time price?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels