@:macro Found something strange

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

@:macro Found something strange

theRemix
i do know that parts of neko that are in the ndll are not accessible from macros, i did not expect this behavior though.

WeirdMacro.hx   -neko


import neko.db.Sqlite;
import haxe.macro.Expr;
class WeirdMacro
{
public static function main(): Void
{
 WeirdMacro.someTrivialMacro();
}
@:macro public static function someTrivialMacro() : Expr
{
 return { expr : EConst(CString('')), pos : haxe.macro.Context.currentPos() }
}
}



compiling this will fail with the error message : "You cannot use the library 'sqlite' inside a macro. Aborted"

now if you comment out the import statement on line 1, OR if you comment out the macro call on line 7, the class will compile.

i thought that the rule only applied if i use neko.db.Sqlite inside of the macro definition, on line 10.

when i move the macro into it's own class though, (MyMacro.hx for example) it will compile just fine as expected.

just an observation... i'll keep my macro functions separate.

-+> theRemix

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: @:macro Found something strange

Yanis Benson

When you call macro the macro system is initialized which raises error, that's why removing macro call affects error. If you want to do it this way, you should put your import in #if !macro, I guess.

On 15 Oct 2011 11:05, "Jon Borgonia" <[hidden email]> wrote:
i do know that parts of neko that are in the ndll are not accessible from macros, i did not expect this behavior though.

WeirdMacro.hx   -neko


import neko.db.Sqlite;
import haxe.macro.Expr;
class WeirdMacro
{
public static function main(): Void
{
 WeirdMacro.someTrivialMacro();
}
@:macro public static function someTrivialMacro() : Expr
{
 return { expr : EConst(CString('')), pos : haxe.macro.Context.currentPos() }
}
}



compiling this will fail with the error message : "You cannot use the library 'sqlite' inside a macro. Aborted"

now if you comment out the import statement on line 1, OR if you comment out the macro call on line 7, the class will compile.

i thought that the rule only applied if i use neko.db.Sqlite inside of the macro definition, on line 10.

when i move the macro into it's own class though, (MyMacro.hx for example) it will compile just fine as expected.

just an observation... i'll keep my macro functions separate.

-+> theRemix

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: @:macro Found something strange

theRemix
oh cool, i didn't know you could do #if -macro

that's helpful, thanks!

-+> theRemix


On Sat, Oct 15, 2011 at 6:00 AM, Yanis Benson <[hidden email]> wrote:

When you call macro the macro system is initialized which raises error, that's why removing macro call affects error. If you want to do it this way, you should put your import in #if !macro, I guess.

On 15 Oct 2011 11:05, "Jon Borgonia" <[hidden email]> wrote:
i do know that parts of neko that are in the ndll are not accessible from macros, i did not expect this behavior though.

WeirdMacro.hx   -neko


import neko.db.Sqlite;
import haxe.macro.Expr;
class WeirdMacro
{
public static function main(): Void
{
 WeirdMacro.someTrivialMacro();
}
@:macro public static function someTrivialMacro() : Expr
{
 return { expr : EConst(CString('')), pos : haxe.macro.Context.currentPos() }
}
}



compiling this will fail with the error message : "You cannot use the library 'sqlite' inside a macro. Aborted"

now if you comment out the import statement on line 1, OR if you comment out the macro call on line 7, the class will compile.

i thought that the rule only applied if i use neko.db.Sqlite inside of the macro definition, on line 10.

when i move the macro into it's own class though, (MyMacro.hx for example) it will compile just fine as expected.

just an observation... i'll keep my macro functions separate.

-+> theRemix

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org