Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arguments 在异步函数中无法使用的问题 #73

Open
hthubert opened this issue Sep 26, 2012 · 1 comment
Open

arguments 在异步函数中无法使用的问题 #73

hthubert opened this issue Sep 26, 2012 · 1 comment
Assignees
Milestone

Comments

@hthubert
Copy link

由于代码编译后,运行上下文发生变化 arguments 对象语义也发生变化,所以用 arguments 判断参数的方法已无法使用了,这个不是大问题也很容易解决,可还是会引起一些麻烦,希望能给一个编程规范来避免这样的问题

源代码

eval(Wind.compile("async", function(/*[String], Date*/){
        var seg, date;
        switch (arguments.length){
            case 0:
                date = Date.now();
                break;
            case 1:
                date = arguments[0];
                break;
        }
});

编译后的代码

/* async << function () { */                     (function () {
                                                     var _builder_$0 = Wind.builders["async"];
                                                     return _builder_$0.Start(this,
                                                         _builder_$0.Delay(function () {
/*     var seg, date; */                                     var seg, date;
/*     switch (arguments.length) { */                        switch (arguments.length) {
/*         case 0: */                                            case 0:
/*             date = Date.now(); */                                 date = Date.now();
/*             break; */                                             break;
/*         case 1: */                                            case 1:
/*             date = arguments[0]; */                               date = arguments[0];
/*             break; */                                             break;
/*     } */                                                  }
                                                         })
                                                     );
/* } */                                          })
@JeffreyZhao
Copy link
Owner

还真是这样,多谢。

@ghost ghost assigned JeffreyZhao Sep 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants