Syntax 对于数组的语法,哪一个更好?

Syntax 对于数组的语法,哪一个更好?,syntax,command,Syntax,Command,我正在制作一种脚本语言,但我需要一些语法方面的帮助。我主要在决定两件事上有问题 首先,调用数组中的部件的语法。我在考虑两种选择中的一种,但如果你愿意,请给我一些建议 假设我有一个数组,在Javascript中表示为 var people = [ ["Joe",34], ["Bill",29], ["Steve",36] ]; function foo(bar,hi) { return bar; } 选择是 Option One people[2][1]

我正在制作一种脚本语言,但我需要一些语法方面的帮助。我主要在决定两件事上有问题

首先,调用数组中的部件的语法。我在考虑两种选择中的一种,但如果你愿意,请给我一些建议

假设我有一个数组,在Javascript中表示为

var people = [
    ["Joe",34],
    ["Bill",29],
    ["Steve",36]
];
function foo(bar,hi) {
    return bar;
}
选择是

Option One
    people[2][1]
    returns 36

Option Two
    people[2,1]
    returns 36
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
    }
第二,调用函数的语法。我在考虑两种选择中的一种,但如果你愿意,请给我一些建议

假设我有一个函数,在Javascript中表示为

var people = [
    ["Joe",34],
    ["Bill",29],
    ["Steve",36]
];
function foo(bar,hi) {
    return bar;
}
选择是

Option One
    people[2][1]
    returns 36

Option Two
    people[2,1]
    returns 36
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
    }
任何和所有的意见和建议都会非常有用!我希望你们能想出一些很好的方法来做这件事,并请提出任何关于语法的建议。我还需要一些其他方面的帮助,但这些都不是什么大决定

提前感谢

1)决定因素不是语法——而是决定是否将2D数组作为基本类型。如果你的目标是写一个简单的语言,这肯定是过分的。嵌套数组已经足够好了(people[2][1])

2) 由于您必须自己解析这些函数模式(据我所知,您无法访问正则表达式),因此应根据解析的容易程度进行选择。对我来说,这显然是选项#1,因为任何函数声明(保留字“函数”)都有一个明确的起点。当您通过脚本进行解析时,如果您的令牌缓冲区只包含“函数”,那么您知道下面的代码位将是函数声明。你的其他任何一项建议都不能这样说