项目作者: skial

项目描述 :
Named parameters using meta and macros.
高级语言: Haxe
项目地址: git://github.com/skial/named.git
创建时间: 2014-01-14T12:55:24Z
项目社区:https://github.com/skial/named

开源协议:

下载


Named

An experimental named parameters implementation using build macros.

Install

haxelib git named https://github.com/skial/named.git

And add -lib named to your hxml file.

Usage

You have two options, use Named with Klas or not.

With Klas

  1. package ;
  2. class Main implements Klas {
  3. public function new() {
  4. var result = long(@:g 'World', @b 'Hello');
  5. }
  6. public function long(?a:String, ?b:String, ?c:String, ?d:String, ?e:String, ?f:String, ?g:String):String {
  7. // Do something.
  8. }
  9. }

Without Klas

  1. package ;
  2. @:autoBuild( uhx.macro.NamedArgs.build() )
  3. class Main {
  4. public function new() {
  5. var result = long(@:g 'World', @b 'Hello');
  6. }
  7. public function long(?a:String, ?b:String, ?c:String, ?d:String, ?e:String, ?f:String, ?g:String):String {
  8. // Do something.
  9. }
  10. }

Explanation

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.

Tests

You can find Named tests in the uhu-spec library.