Closed
Description
Scope of Change
The XP Compiler will be extended to support compile-time metaprogramming
Rationale
Build libraries like xp-forge/partial
into compiler.
Functionality
<<value>>
class Person {
private int $id;
private string $name;
}
The compiler finds an implementation which was previously registered via Transformations::register()
for class nodes. The function gets executed and transforms the above to the following PHP:
class Person implements \lang\Value {
private $id;
private $name;
public function __construct(int $id, string $name) {
$this->id= $id;
$this->name= $name;
}
public function id() { return $this->id; }
public function name() { return $this->name; }
// toString(), hashCode() and compareTo() omitted for brevity
}
Security considerations
Speed impact
Dependencies
Related documents
https://dzone.com/articles/compile-time-metaprogramming
http://groovy-lang.org/metaprogramming.html#_available_ast_transformations
http://groovy-lang.org/metaprogramming.html#developing-ast-xforms
http://notatube.blogspot.de/2010/12/project-lombok-creating-custom.html
xp-framework/compiler#15
https://wiki.php.net/rfc/parser-extension-api
microsoft/TypeScript#5595