English 中文(简体)
哪一个阵列的辛子更好?
原标题:Which would be better for the syntax for an array?

I am making a scripting language, but I need help on deciding some syntax. I am mainly having issues deciding two things.

First, the syntax for calling an parts in the array. I was thinking one of two options, but give me suggestions if you want.

请允许我说,我有一阵列,在 Java文中,代表人数将相当于代表人数。

var people = [
    ["Joe",34],
    ["Bill",29],
    ["Steve",36]
];

备选办法如下:

Option One
    people[2][1]
    returns 36

Option Two
    people[2,1]
    returns 36

第二,要求发挥职能。 我正在考虑两种选择之一,但如果你愿意,我会提出建议。

请允许我说,我有一项职能是,在 Java文中代表 as人。

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
    }

任何意见和建议都会非常有益! 我希望你们提出一些伟大的想法,以便做到这一点。 我仍需要一些其他事情的帮助,但这些事情实际上不是任何重大决定。

<><>>>> 预产!

最佳回答

(1) 该决定不是星号,你正在决定是否将2D阵列列为基类。 如果你的目标是书写一种简单的语言,这无疑是多余的。 Nest鱼阵列足够好(人民12.1)。

2) 由于你不得不为这些职能模式 par平(以及我所收集的不定期表达方式),你应根据宽松的选择。 对我来说,这显然是选择第1号,因为你在宣布一项职能时有一个明确的起点(保留词“功能”)。 当你穿透文字时,如果你打入的缓冲只由“功能”组成,那么你知道下面的编码范围将成为功能声明。 你们的另外一项提案也不可能如此。

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

pdo database abstraction

Can someone help me to see what is going wrong with this setup I build the @sql query in the function below like this. The extra quotes are setup in the conditions array. $sql .= " WHERE $...

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to ...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY ...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != ...

热门标签