Becomes/zh CN: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | := | |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | - | ||
| 5 | 4 | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 5 | + | 符号 _** := **_ (符号 [[Colon|冒号]] 跟着符号 [[Equal|等号]], 中间没空格或其他字符) 读作 _**成为(变成)**_ ,在 [[Pascal]] 中意思是 _被赋值为..._ : | |
| 15 | 6 | ``` | |
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 7 | + | A := 4 ; | |
| 8 | + | Circle_Area := Pi * Diameter ; | |
| 9 | + | Name := 'Smith' ; | |
| 10 | + | C := 1000 - C div 2 ; | |
| 11 | + | ``` | |
| 23 | 12 | ||
| 24 | - | ||
| 13 | + | 使用两个符号,冒号加等号(而不是只用一种,比如说光用=等号)是为了区分赋值与相等比较。 | |
| 25 | 14 | ||
| 26 | - | ||
| 15 | + | 例如,在Pascal以外的语言您可以写 | |
| 27 | 16 | ||
| 28 | - | ||
| 17 | + | A = B = D ; | |
| 18 | + | 或 | |
| 19 | + | A = B = D | |
| 29 | 20 | ||
| 30 | - | ||
| 21 | + | 取决与分号在那种语言中是否必要。 | |
| 31 | 22 | ||
| 32 | - | ||
| 23 | + | 该表达式的含义取决于语言。例如,在Fortran和Basic中,该表达式意思是将A赋值为“B和D相等吗?” 在C语言中,该表达式意思是将变量A和B的值赋值给D。这种类型的指令错误在C语言中再常见不过了以至于这种表达式经常被编译器标识一个警告,除非您通过在表达式两旁加括号告诉编译器您是有意这么做(多重赋值)。在C语言中测试相等的正确做法是使用 _**A = B == D;**_ | |
| 33 | 24 | ||
| 34 | - | ||
| 25 | + | 在Pascal中这种混淆不会发生的,因为该语句非法。您可以写 | |
| 26 | + | ``` | |
| 35 | 27 | A := B = D; | |
| 36 | 28 | ``` | |
| 37 | 29 | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 30 | + | 意思与FORTRAN或BASIC相同,就是将A赋值为“B和D相等吗?” | |
| 44 | 31 | ||
| 45 | - | ||
| 32 | + | 要将A,B,D赋予相同的值需要显式的分开赋值形式 | |
| 46 | 33 | ||
| 47 | - | ||
| 34 | + | A := D ; B := D ; | |
| 35 | + | 或 | |
| 36 | + | B := D ; A := B ; | |
| 37 | + | 或 | |
| 38 | + | A := D ; B := A ; | |
| 48 | 39 | ||
| 49 | - | ||
| 40 | + | 取决于在执行中是否有差异或有副作用 (D 可以式一个动态变量,比方说一个系统 [port](</index.php?title=Port&action=edit&redlink=1> "Port \(page does not exist\)"), 一个 [[Function|函数]] 或是一个[[Object|对象]] 的 [[Property|属性]] ,因此 [[Identifier|标识符]] D 在第一和第二个赋值示例中可能会有所不同) | |
| 50 | 41 | ||
| 51 | - | ||
| 42 | + | ||
| 52 | 43 | ||
| 53 | - | ||
| 44 | + | navigation bar: topic: Pascal symbols single characters | [`+` (plus)](</index.php?title=Plus/zh_CN&action=edit&redlink=1> "Plus/zh CN \(page does not exist\)") • [`-` (minus)](</index.php?title=Minus/zh_CN&action=edit&redlink=1> "Minus/zh CN \(page does not exist\)") • [`*` (asterisk)](</index.php?title=*/zh_CN&action=edit&redlink=1> "*/zh CN \(page does not exist\)") • [`/` (slash)](</index.php?title=Slash/zh_CN&action=edit&redlink=1> "Slash/zh CN \(page does not exist\)") | |
| 45 | + | [`=` (equal)](</index.php?title=Equal/zh_CN&action=edit&redlink=1> "Equal/zh CN \(page does not exist\)") • [`>` (greater than)](</index.php?title=Greater_than/zh_CN&action=edit&redlink=1> "Greater than/zh CN \(page does not exist\)") • [`<` (less than)](</index.php?title=Less_than/zh_CN&action=edit&redlink=1> "Less than/zh CN \(page does not exist\)") | |
| 46 | + | [`.` (period)](</index.php?title=period/zh_CN&action=edit&redlink=1> "period/zh CN \(page does not exist\)") • [[Colon/zh CN|`:` (colon)]] • [`;` (semi colon)](</index.php?title=;/zh_CN&action=edit&redlink=1> ";/zh CN \(page does not exist\)") | |
| 47 | + | [`^` (hat)](</index.php?title=%5E/zh_CN&action=edit&redlink=1> "^/zh CN \(page does not exist\)") • [`@` (at)](</index.php?title=@/zh_CN&action=edit&redlink=1> "@/zh CN \(page does not exist\)") | |
| 48 | + | [`$` (dollar sign)](</index.php?title=Dollar_sign/zh_CN&action=edit&redlink=1> "Dollar sign/zh CN \(page does not exist\)") • [`&` (ampersand)](</index.php?title=%26/zh_CN&action=edit&redlink=1> "&/zh CN \(page does not exist\)") • [`#` (hash)](</index.php?title=Hash/zh_CN&action=edit&redlink=1> "Hash/zh CN \(page does not exist\)") | |
| 49 | + | [`'` (single quote)](</index.php?title=%27/zh_CN&action=edit&redlink=1> "'/zh CN \(page does not exist\)") | |
| 50 | + | ---|--- | |
| 51 | + | character pairs | [`<>` (not equal)](</index.php?title=Not_equal/zh_CN&action=edit&redlink=1> "Not equal/zh CN \(page does not exist\)") • [`<=` (less than or equal)](</index.php?title=Less_than_or_equal/zh_CN&action=edit&redlink=1> "Less than or equal/zh CN \(page does not exist\)") • `:=` (becomes) • [`>=` (greater than or equal)](</index.php?title=Greater_than_or_equal/zh_CN&action=edit&redlink=1> "Greater than or equal/zh CN \(page does not exist\)") • [[symmetric difference|`><` (symmetric difference)]] • [[Slash|`//` (double slash)]] | |
| 52 | + | ||
| 53 | + | ||
| 54 | + | **** | |
| 54 | 55 | ||
| 55 | 56 | --- | |
| 56 | - | ||
| 57 | + | *From the Free Pascal wiki, page "Becomes/zh CN", as the Internet Archive kept it on 2023-04-06. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
