haxe icon indicating copy to clipboard operation
haxe copied to clipboard

use namespaced metadata for targets

Open nadako opened this issue 6 years ago • 3 comments

As briefly discussed in Slack, maybe it makes sense to refactor all the target-specific metadata (@:jsRequire/@:cppInclude/etc.) into namespaced variants (@:js.require, @:cpp.include). If we go with that, we can slowly deprecate the old ones, making them hidden aliases for the new ones and eventually emitting a deprecation warning.

One question here is what to do with target-specific metadata that is shared between a couple different targets, like @:expose for JS and Lua, or @:functionCode for C++, C# and Java.

nadako avatar Feb 10 '19 09:02 nadako

I think it is a good idea to have it also in the target specific prefix. Just like js.expose / lua.expose. If you work in an IDE it can be help for selfdocumented autocomplete. Just type js. and you see expose in the autocomplete list.

lublak avatar May 08 '19 06:05 lublak

It's probably a good idea to give every platform their own namespaced metadata variant (e.g. @:lua.expose). Otherwise the compiler seems to guarantee that the metadata behavior for the targets will always be the same (I don't believe this is a guarantee we want to make).

It would also be nice to easily combine the namespaced metadata variants back into a single ad-hoc metadata if necessary, at least for projects where any platform differences don't matter. Here's some example code (with syntax I just threw together for illustration):

@:project_require = 
#if js 
@:js.require
#elseif lua
@:lua.require
#end

jdonaldson avatar May 20 '19 16:05 jdonaldson

Also wanted to reference methods like Compiler.includeFile : https://api.haxe.org/haxe/macro/Compiler.html#includeFile

It's another shared name/behavior between lua and js.

jdonaldson avatar May 20 '19 17:05 jdonaldson