Difference between revisions of "LSL 演算子"

From Second Life Wiki
Jump to navigation Jump to search
Line 59: Line 59:


'''Note:''' ブーリアン演算子の優先順位は不明瞭です。
'''Note:''' ブーリアン演算子の優先順位は不明瞭です。
式解析に優先順位に矛盾を生んだり、もしくは単純に '''||''' と '''&&''' の優先順位を同一と見なすかもしれない[http://jira.secondlife.com/browse/SVC-779 バグ]を含んでいるかもしれません。
式解析の優先順位に矛盾を生んだり、もしくは単純に '''||''' と '''&&''' の優先順位を同一と見なすかもしれない[http://jira.secondlife.com/browse/SVC-779 バグ]を含んでいるかもしれません。
 
{| {{Prettytable}}
{| {{Prettytable}}
|+
|+

Revision as of 06:03, 23 February 2009

Operators are used to cause an operation (or mathematical action) to be performed on two operands. The easy and common example is 1 + 2 where 1 and 2 are operands, and the + is the operator.

演算子は2つの被演算子の間で演算(もしくは数学的な作用)を実行するために用いられます。簡単で一般的な例として、1 + 2 の場合、1 と 2 が被演算子、 + が演算子です。

This concept can be extended much further with LSL since operands can be variables with the special case of the assignment operators requiring that the left hand side be a variable.

被演算子に変数が利用できること(特殊な例として代入演算子の左辺は変数でなければなりません)により、LSLの設計思想は大幅に拡張されました。

演算子 説明 使用例
() [] . 小カッコ(Parenthesis), 大カッコ(Brackets), ドット do this second (do this first)
(type) Typecasting message = "The result is:" + (string) result;
! ~ ++ -- NOT, One's Complement, Increment, Decrement counter++;
* / % 乗算/内積, 除算, 剰余/外積 rollover = (count + 1)%5;
- 減算 one = 3 - 2;
+ Addition or joining Strings two = 1+1;

text = "Hello" + "World";

+ Concatenation or joining Lists myList = [1, 2, 3] + [4, 5];

newList = oldList + addList;

<< >> Left Shift, Right Shift eight = 4 << 1;
< <= > >= Less Than, Less Than Or Equal To,

Greater Than, Greater Than or Equal To

isFalse = (6 <= 4);
==  != Comparison Equal, Comparison Not Equal isFalse = ("this" == "that");
& Bitwise AND zero = 4 & 2;

four = 4 & 4;

^ Bitwise XOR zero = 4 ^ 4;

six = 4 ^ 2;

| Bitwise OR four = 4 | 4;

six = 4 | 2;

|| Comparison OR isTrue = (FALSE || TRUE);
&& Comparison AND isFalse = (FALSE && TRUE);
= += -= *= /= %= Assignment four = 4;


Note: The order of precedence of boolean operators is unclear. It is possible that there is a bug in the expression parser, making precedence inconsistent, or it may simply be that || and && have equal precedence; testing is inconclusive. Thus, when in doubt, parenthesize.

Note: ブーリアン演算子の優先順位は不明瞭です。 式解析の優先順位に矛盾を生んだり、もしくは単純に ||&& の優先順位を同一と見なすかもしれないバグを含んでいるかもしれません。

+ 演算子

result = left + right

Left の型 Right の型 Result の型 説明
integer integer integer leftright を加算する
integer float float leftright を加算する
float integer float leftright を加算する
string string string Concatenates right onto the end of left.
list * list Concatenates right onto the end of left.
* list list Affixes left onto the start of right.
vector vector vector Adds left and right
rotation rotation rotation Adds left and right
Not useful for combining rotations, use * or / instead.