An experimental named parameters implementation using build macros.
haxelib git named https://github.com/skial/named.git
And add -lib named
to your hxml
file.
You have two options, use Named with Klas or not.
package ;
class Main implements Klas {
public function new() {
var result = long(@:g 'World', @b 'Hello');
}
public function long(?a:String, ?b:String, ?c:String, ?d:String, ?e:String, ?f:String, ?g:String):String {
// Do something.
}
}
package ;
@:autoBuild( uhx.macro.NamedArgs.build() )
class Main {
public function new() {
var result = long(@:g 'World', @b 'Hello');
}
public function long(?a:String, ?b:String, ?c:String, ?d:String, ?e:String, ?f:String, ?g:String):String {
// Do something.
}
}
An experiment to implement named parameters using a build macro.
- You can use either style of meta tags, runtime
@name
or compile time@:name
, it doesn't matter. - You have to name the meta tag the same as the parameter name.
- It can be used with both optional or non optional parameters.
You can find Named tests in the uhu-spec library.