我正在编写脚本语言,但是我需要帮助确定一些语法。我主要是在决定两件事情时遇到问题。哪个更适合数组的语法?
首先,调用数组中的部件的语法。我正在考虑两种选择之一,但如果你愿意的话,给我一些建议。
比方说,我有一个数组在Javascript中可表示为
var people = [
["Joe",34],
["Bill",29],
["Steve",36]
];
的选项
Option One
people[2][1]
returns 36
Option Two
people[2,1]
returns 36
二,语法调用函数。我正在考虑两种选择之一,但如果你愿意的话,给我一些建议。
比方说,我有一个在Javascript将表示一个功能
function foo(bar,hi) {
return bar;
}
的选项
Option One
The same as Javascript
example:
function foo(bar,hi) {
return bar
}
Option Two
The same as Javascript, but
- separating each private variable with it's own set of parentheses
- no need to state "function" in front
example:
foo(bar)(hi){
return bar
}
Option Three
The same as Javascript, but
- a colon to separate the namespace from the private variables
- no parentheses due to the lack of need
example:
foo:bar,hi{
return bar
}
任何和所有的意见和建议将是非常有帮助!我希望你们能够提出一些很好的想法来做到这一点,并且请为语法提供任何建议。我仍然需要其他一些帮助,但这些并不是什么大的决定。
在此先感谢!