Closed waneck closed 11 years ago
[comment from ncanna...@gmail.com, published at 2011-11-11T19:44:54.000Z] This is similar to Scala proposal for quasiquotations right ? http://scalamacros.org/sips/quasiquotations.html
[comment from stephane...@gmail.com, published at 2011-11-11T20:32:46.000Z] Yes, I think this is an instance of quasi quotation. And to be frank; I though about it and what I've proposed here is ugly (wanted to propose something I though would be easier to do).
Quasi quotation look similar on more an more languages. The last implementation of stagging I have done brings us there https://github.com/sledorze/haxeExtensionBuilder/blob/master/src/StaggedTestMacros.hx But I don't like all the computations they involve and think Quasi quotation should be part of standard haxe macros; it's elegant, intuitive and cover a lot of macros use cases.
@:macro public static function forExample2(init : Expr, cond : Expr, inc : Expr, body : Expr, nb : Int = 5) : Expr return {
var arr = [];
for (ind in 0...5) {
var localExpr =
"{
trace('wow' + $ind);
}".stagged();
arr.push(
"{
trace('i ' + $ind);
$localExpr;
$init;
function oneTime() {
if ($cond) {
$body;
$inc;
oneTime();
}
}
oneTime();
}".stagged()
);
}
return { expr : EBlock(arr), pos : Context.currentPos() };
}
[comment from shedok...@gmail.com, published at 2011-11-26T15:11:35.000Z] Or use % instead of $.
[comment from ncanna...@gmail.com, published at 2012-01-24T10:18:47.000Z]
[comment from ncanna...@gmail.com, published at 2012-05-15T09:25:02.000Z] One of the thing I was thinking of would be to add "macro" as a keyword in Haxe 3.0 :
[comment from franco.p...@gmail.com, published at 2012-05-15T13:06:33.000Z] macro are already so important that they really seem to deserve a keyword.
[comment from stephane...@gmail.com, published at 2012-05-15T13:25:43.000Z]
@nicolas macro
[comment from ncanna...@gmail.com, published at 2012-06-17T13:40:36.000Z] I've added the following :
function foo() { var x = macro myVar; var block = macro { foo(); foo(); foo(); } var efor = macro for( $x in array ) $block; return efor; }
Some testing/feedback is required, thanks :)
[comment from ncanna...@gmail.com, published at 2012-07-14T11:51:10.000Z]
[Google Issue #562 : http://code.google.com/haxe/issues/detail?id=562] by stephane...@gmail.com, at 2011-11-01T21:53:14.000Z What steps will reproduce the problem?
What is the expected output? What do you see instead?
This is a proposal to introduce another Context method to substitue some identifiers with existing expressions while parsing. The subsitution candidates would be passed by an anonymous object.
@:macro public static function foo(a : Expr) : Expr {
}
Please complete the following class with minimal code reproducing the problem :
Please provide any additional information below.