Osc*_*Ryz 9 language-agnostic programming-languages operators control-structure
喜欢Smalltalk还是Lisp?
编辑
控制结构如下:
Java Python
if( condition ) { if cond:
doSomething doSomething
}
Run Code Online (Sandbox Code Playgroud)
要么
Java Python
while( true ) { while True:
print("Hello"); print "Hello"
}
Run Code Online (Sandbox Code Playgroud)
和运营商
Java, Python
1 + 2 // + operator
2 * 5 // * op
Run Code Online (Sandbox Code Playgroud)
在Smalltalk(如果我是正确的)那将是:
condition ifTrue:[
doSomething
]
True whileTrue:[
"Hello" print
]
1 + 2 // + is a method of 1 and the parameter is 2 like 1.add(2)
2 * 5 // same thing
Run Code Online (Sandbox Code Playgroud)
为什么你以前从未听说过口齿不清?
你是说没有特殊的语法来达到同样的目的?
许多语言都有控制结构和运算符,它们"真正"是某种形式的消息传递或功能调用系统,可以重新定义.大多数"纯粹的"对象语言和纯函数语言符合要求.但他们仍然会有你的"+"和某种形式的代码块 - 包括SmallTalk! - 所以你的问题有点误导.
| 归档时间: |
|
| 查看次数: |
1751 次 |
| 最近记录: |